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