Commit fae1fdc4 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Adapted to new version of optimade-python-tools.

parent f3cea97d
Subproject commit b9619d6b34a8f8e66120fb02f5fd3dbc16d26517
Subproject commit da84192020f08e8d1c847a83ffbfd20d532ae75d
......@@ -60,7 +60,7 @@ def base_request_args():
api = Api(
blueprint,
version='1.0', title='NOMAD\'s OPTiMaDe API implementation',
description='NOMAD\'s OPTiMaDe API implementation, version 0.10.0.',
description='NOMAD\'s OPTiMaDe API implementation, version 0.10.1.',
validate=True)
''' Provides the flask restplust api instance for the optimade api'''
......
......@@ -187,10 +187,10 @@ class Info(Resource):
'type': 'info',
'id': '/',
'attributes': {
'api_version': '0.10.0',
'api_version': '0.10.1',
'available_api_versions': [{
'url': url(),
'version': '0.10.0'
'url': url(version=None),
'version': '0.10.1'
}],
'formats': ['json'],
'entry_types_by_format': {
......
......@@ -25,7 +25,7 @@ class FilterException(Exception):
_quantities: Dict[str, Quantity] = None
_parser = LarkParser(version=(0, 10, 0))
_parser = LarkParser(version=(0, 10, 1))
_transformer = None
......
......@@ -37,10 +37,10 @@ class Info(Resource):
'type': 'info',
'id': '/',
'attributes': {
'api_version': '0.10.0',
'api_version': '0.10.1',
'available_api_versions': [{
'url': url(prefix='index'),
'version': '0.10.0'
'url': url(version=None, prefix='index'),
'version': '0.10.1'
}],
'formats': ['json'],
'entry_types_by_format': {
......@@ -75,7 +75,7 @@ class Links(Resource):
"name": config.meta.name,
"description": config.meta.description,
"base_url": {
"href": url(),
"href": url(version=None),
},
"homepage": config.meta.homepage
}
......
......@@ -112,15 +112,15 @@ class Meta():
def __init__(self, query: str, returned: int, available: int = None, last_id: str = None):
self.query = dict(representation=query)
self.api_version = '0.10.0'
self.api_version = '0.10.1'
self.time_stamp = datetime.datetime.now()
self.data_returned = returned
self.more_data_available = available > returned if available is not None else False
self.provider = dict(
name='NOMAD',
description='The NOvel MAterials Discovery project and database.',
name=config.meta.name,
description=config.meta.name,
prefix='nomad',
homepage='https//nomad-coe.eu',
homepage=config.meta.homepage,
index_base_url=base_url
)
......@@ -129,8 +129,8 @@ class Meta():
self.implementation = dict(
name='nomad@fairdi',
version=config.meta.version,
source_url='https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR',
maintainer=dict(email='markus.scheidgen@physik.hu-berlin.de'))
source_url=config.meta.source_url,
maintainer=dict(email=config.meta.maintainer_email))
class ToplevelLinks:
......@@ -174,7 +174,7 @@ def Links(endpoint: str, available: int, page_number: int, page_limit: int, **kw
rest.update(**{key: value for key, value in kwargs.items() if value is not None})
result = dict(
base_url=url(),
base_url=url(version=None),
first=url(endpoint, page_number=1, **rest),
last=url(endpoint, page_number=last_page, **rest))
......@@ -296,29 +296,16 @@ class StructureObject:
self.attributes = attrs
class ReferenceObject:
def __init__(self, calc: EntryMetadata):
attrs = dict(
immutable_id=calc.calc_id,
last_modified=calc.last_processing if calc.last_processing is not None else calc.upload_time,
authors=calc.authors)
# class ReferenceObject:
# def __init__(self, calc: EntryMetadata):
# attrs = dict(
# immutable_id=calc.calc_id,
# last_modified=calc.last_processing if calc.last_processing is not None else calc.upload_time,
# authors=calc.authors)
self.type = 'calculation'
self.id = calc.calc_id
self.attributes = attrs
class LinkObject:
def __init__(self, calc: EntryMetadata, page_number: int, **kwargs):
attrs = dict(
name='Calculation %s' % calc.calc_id,
description='Calculation entry in NOMAD database.',
base_url=url('structures', page_number=page_number, **kwargs),
homepage=url()
)
self.type = 'child'
self.id = calc.calc_id
self.attributes = attrs
# self.type = 'calculation'
# self.id = calc.calc_id
# self.attributes = attrs
class Property:
......
......@@ -269,7 +269,9 @@ meta = NomadConfig(
service='unknown nomad service',
name='novel materials discovery (NOMAD)',
description='A FAIR data sharing platform for materials science data',
homepage='https://nomad-coe.eu'
homepage='https://repository.nomad-coe.eu/v0.8',
source_url='https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR',
maintainer_email='markus.scheidgen@physik.hu-berlin.de'
)
auxfile_cutoff = 100
......
......@@ -41,7 +41,7 @@ def test_index(index_api):
rv = index_api.get('/links')
assert rv.status_code == 200
data = json.loads(rv.data)
assert data['data'][0]['attributes']['base_url']['href'].endswith('optimade/v0')
assert data['data'][0]['attributes']['base_url']['href'].endswith('optimade')
def test_get_entry(published: Upload):
......@@ -128,17 +128,19 @@ def example_structures(elastic_infra, mongo_infra, raw_files_infra):
('chemical_formula_descriptive CONTAINS "C" AND NOT chemical_formula_descriptive STARTS WITH "O"', 1),
('NOT chemical_formula_anonymous STARTS WITH "A"', 0),
('chemical_formula_anonymous CONTAINS "AB2" AND chemical_formula_anonymous ENDS WITH "C"', 1),
('nsites >=3 AND LENGTH elements = 2', 2),
('LENGTH elements = 2', 3),
('LENGTH elements = 3', 1),
('LENGTH dimension_types = 0', 3),
('LENGTH dimension_types = 1', 1),
('nelements = 2 AND LENGTH dimension_types = 1', 1),
('nelements = 3 AND LENGTH dimension_types = 1', 0),
('nelements = 3 OR LENGTH dimension_types = 1', 2),
('nelements > 1 OR LENGTH dimension_types = 1 AND nelements = 2', 4),
('(nelements > 1 OR LENGTH dimension_types = 1) AND nelements = 2', 3),
('NOT LENGTH dimension_types = 1', 3),
('nsites >=3 AND elements LENGTH = 2', 2),
('elements LENGTH = 2', 3),
('elements LENGTH 2', 3),
('elements LENGTH = 3', 1),
('dimension_types LENGTH = 0', 3),
('dimension_types LENGTH = 1', 1),
('nelements = 2 AND dimension_types LENGTH = 1', 1),
('nelements = 3 AND dimension_types LENGTH = 1', 0),
('nelements = 3 OR dimension_types LENGTH = 1', 2),
('nelements > 1 OR dimension_types LENGTH = 1 AND nelements = 2', 4),
('(nelements > 1 OR dimension_types LENGTH = 1) AND nelements = 2', 3),
('NOT dimension_types LENGTH 1', 3),
('nelements LENGTH = 1', -1),
('LENGTH nelements = 1', -1),
('chemical_formula_anonymous starts with "A"', -1),
('elements HAS ONY "H", "O"', -1)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment