info¶
CONFIG: ServerConfig = ServerConfig()
module-attribute
¶
This singleton loads the config from a hierarchy of sources (see
customise_sources
)
and makes it importable in the server code.
ENTRY_INFO_SCHEMAS: dict[str, type[EntryResource]] = {'structures': StructureResource, 'references': ReferenceResource}
module-attribute
¶
This dictionary is used to define the /info/<entry_type>
endpoints.
ERROR_RESPONSES: Optional[dict[int, dict[str, Any]]] = {err.status_code: {'model': ErrorResponse, 'description': err.title}for err in POSSIBLE_ERRORS}
module-attribute
¶
__api_version__ = '1.1.0'
module-attribute
¶
router = APIRouter(redirect_slashes=True)
module-attribute
¶
BaseInfoAttributes
¶
Bases: BaseModel
Attributes for Base URL Info endpoint
Source code in optimade/models/baseinfo.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
BaseInfoResource
¶
Bases: Resource
Source code in optimade/models/baseinfo.py
126 127 128 129 |
|
EntryInfoResource
¶
Bases: BaseModel
Source code in optimade/models/entries.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
EntryInfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
59 60 61 62 63 |
|
model_config = ConfigDict(json_encoders={datetime: lambda : v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
InfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
66 67 68 69 |
|
model_config = ConfigDict(json_encoders={datetime: lambda : v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
get_base_url(parsed_url_request)
¶
Get base URL for current server
Take the base URL from the config file, if it exists, otherwise use the request.
Source code in optimade/server/routers/utils.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
get_entry_info(request, entry)
¶
Source code in optimade/server/routers/info.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
get_info(request)
¶
Source code in optimade/server/routers/info.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
meta_values(url, data_returned, data_available, more_data_available, schema=None, **kwargs)
¶
Helper to initialize the meta values
Source code in optimade/server/routers/utils.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
retrieve_queryable_properties(schema, queryable_properties=None, entry_type=None)
¶
Recursively loops through a pydantic model, returning a dictionary of all the OPTIMADE-queryable properties of that model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
type[EntryResource]
|
The pydantic model. |
required |
queryable_properties |
Optional[Iterable[str]]
|
The list of properties to find in the schema. |
None
|
entry_type |
Optional[str]
|
An optional entry type for the model. Will be used to lookup schemas for any config-defined fields. |
None
|
Returns:
Type | Description |
---|---|
QueryableProperties
|
A flat dictionary with properties as keys, containing the field |
QueryableProperties
|
description, unit, sortability, support level, queryability |
QueryableProperties
|
and type, where provided. |
Source code in optimade/server/schemas.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|