Skip to content

Commit

Permalink
Add OPTIMADE properties to the info endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Oct 2, 2023
1 parent a07b2a4 commit d7fe95b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mc_optimade/mc_optimade/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import tqdm
from optimade.models import EntryInfoResource, EntryResource
from optimade.server.schemas import ENTRY_INFO_SCHEMAS, retrieve_queryable_properties

from .config import Config, EntryConfig, ParsedFiles, PropertyDefinition
from .parsers import ENTRY_PARSERS, OPTIMADE_CONVERTERS, PROPERTY_PARSERS, TYPE_MAP
Expand All @@ -23,12 +24,17 @@ def _construct_entry_type_info(
) -> EntryInfoResource:
"""Take the provided property definitions and construct an entry info response.
TODO: Also insert the relevant default OPTIMADE fields.
Returns:
The full `EntryInfoResource` object.
"""

default_properties = {}
if type in ENTRY_INFO_SCHEMAS:
default_properties = retrieve_queryable_properties(
ENTRY_INFO_SCHEMAS[type](), {"id", "type", "attributes"}
)

info: dict[str, Any] = {"formats": ["json"], "description": type}
info["properties"] = {
f"_{provider_prefix}_{p.name}": {
Expand All @@ -39,6 +45,7 @@ def _construct_entry_type_info(
}
for p in properties
}
info["properties"].update(default_properties)
info["output_fields_by_format"] = {}
info["output_fields_by_format"]["json"] = list(info["properties"].keys())
return EntryInfoResource(**info)
Expand Down

0 comments on commit d7fe95b

Please sign in to comment.