Skip to content

Commit 5e9f745

Browse files
authored
Support OPTIMADE v1.2.0 & drop Python 3.9 support (#294)
Support OPTIMADE v1.2.0 At least concerning the updated Structure resource model. Drop Python 3.9 support. Remove python version requirement in pre-commit config. Upgrade to v1 for all OTEAPI dependencies.
1 parent d54c290 commit 5e9f745

13 files changed

Lines changed: 118 additions & 78 deletions

File tree

.github/workflows/cd_release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
package_dirs: oteapi_optimade
2121
release_branch: main
2222
install_extras: "[dev]"
23-
python_version_build: "3.9"
23+
python_version_build: "3.10"
2424
build_libs: flit
2525
build_cmd: "flit build"
2626
build_dir: "dist"
@@ -29,8 +29,8 @@ jobs:
2929

3030
# Documentation
3131
update_docs: true
32-
python_version_docs: "3.9"
33-
doc_extras: "[doc]"
32+
python_version_docs: "3.10"
33+
doc_extras: "[docs]"
3434
changelog_exclude_labels: "skip_changelog,duplicate,question,invalid,wontfix"
3535

3636
secrets:

.github/workflows/ci_cd_updated_main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
update_python_api_ref: true
2323
update_docs_landing_page: true
2424
package_dirs: oteapi_optimade
25-
python_version: "3.9"
26-
doc_extras: "[doc]"
25+
python_version: "3.10"
26+
doc_extras: "[docs]"
2727
full_docs_dirs: models
2828
changelog_exclude_labels: "skip_changelog,duplicate,question,invalid,wontfix"
2929

.github/workflows/ci_tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
run_pre-commit: false
2020

2121
# pylint & safety
22-
python_version_pylint_safety: "3.9"
22+
python_version_pylint_safety: "3.10"
2323
run_pylint: false
2424

2525
run_safety: true
@@ -31,12 +31,12 @@ jobs:
3131
--ignore=70612
3232
3333
# Build dist
34-
python_version_package: "3.9"
34+
python_version_package: "3.10"
3535
build_libs: flit
3636
build_cmd: flit build
3737

3838
# Build documentation
39-
python_version_docs: "3.9"
39+
python_version_docs: "3.10"
4040
package_dirs: oteapi_optimade
4141
full_docs_dirs: "models"
4242

@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
fail-fast: false
4949
matrix:
50-
python-version: ["3.9", "3.10", "3.11", "3.12"]
50+
python-version: ["3.10", "3.11", "3.12"]
5151
os:
5252
- ["ubuntu-latest", "linux"]
5353
- ["windows-latest", "windows"]
@@ -111,10 +111,10 @@ jobs:
111111
with:
112112
fetch-depth: 2
113113

114-
- name: Set up Python 3.9
114+
- name: Set up Python 3.10
115115
uses: actions/setup-python@v5
116116
with:
117-
python-version: "3.9"
117+
python-version: "3.10"
118118

119119
- name: Install python dependencies
120120
run: |

.pre-commit-config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ ci:
1212
submodules: false
1313

1414
# hooks
15-
default_language_version:
16-
python: python3.9
17-
1815
repos:
1916
- repo: https://github.com/pre-commit/pre-commit-hooks
2017
rev: v5.0.0

docs/examples/dlite.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
},
185185
{
186186
"cell_type": "code",
187-
"execution_count": 42,
187+
"execution_count": null,
188188
"metadata": {},
189189
"outputs": [
190190
{

docs/examples/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Using OTElib should be done as a backend task in a web application, and the resu
1818

1919
### Prerequisites
2020

21-
To run the examples locally, you need to have the following tools available (in addition to a working Python 3.9+ installation):
21+
To run the examples locally, you need to have the following tools available (in addition to a working Python 3.10+ installation):
2222

2323
- [Jupyter](https://jupyter.org/)
2424
- [Docker](https://www.docker.com/) (or similar containerization tool)

entities/OPTIMADEStructure.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
uri: http://onto-ns.com/meta/1.0.1/OPTIMADEStructure
1+
uri: http://onto-ns.com/meta/1.2.0/OPTIMADEStructure
22
meta: http://onto-ns.com/meta/0.3/EntitySchema
33
description: An OPTIMADE structure.
44
dimensions: {}
@@ -8,7 +8,7 @@ properties:
88
description: The name of the type of an entry. Must always be 'structures'.
99
attributes:
1010
type: ref
11-
$ref: http://onto-ns.com/meta/1.0.1/OPTIMADEStructureAttributes
11+
$ref: http://onto-ns.com/meta/1.2.0/OPTIMADEStructureAttributes
1212
description: The attributes used to represent a structure, e.g. unit cell, atoms, positions.
1313
id:
1414
type: str

entities/OPTIMADEStructureAttributes.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
uri: http://onto-ns.com/meta/1.0.1/OPTIMADEStructureAttributes
1+
uri: http://onto-ns.com/meta/1.2.0/OPTIMADEStructureAttributes
22
meta: http://onto-ns.com/meta/0.3/EntitySchema
33
description: The attributes used to represent a structure, e.g. unit cell, atoms, positions.
44
dimensions:
55
nelements: Number of different elements in the structure as an integer.
66
dimensionality: Number of spatial dimensions. Must always be 3.
77
nsites: An integer specifying the length of the `cartesian_site_positions` property.
8+
nspace_group_symmetry_operations: Number of space group symmetry operations.
89
nspecies: Number of species.
910
nstructure_features: Number of structure features.
1011
properties:
@@ -40,6 +41,22 @@ properties:
4041
shape: [dimensionality, dimensionality]
4142
unit: Å
4243
description: The three lattice vectors in Cartesian coordinates, in ångström (Å).
44+
space_group_symmetry_operations_xyz:
45+
type: string
46+
shape: [nspace_group_symmetry_operations]
47+
description: List of symmetry operations given as general position x, y and z coordinates in algebraic form.
48+
space_group_symbol_hall:
49+
type: string
50+
description: A Hall space group symbol representing the symmetry of the structure as defined in (Hall, 1981, 1981a).
51+
space_group_symbol_hermann_mauguin:
52+
type: string
53+
description: A human- and machine-readable string containing the short Hermann-Mauguin (H-M) symbol which specifies the space group of the structure in the response.
54+
space_group_symbol_hermann_mauguin_extended:
55+
type: string
56+
description: A human- and machine-readable string containing the extended Hermann-Mauguin (H-M) symbol which specifies the space group of the structure in the response.
57+
space_group_it_number:
58+
type: int
59+
description: Space group number which specifies the space group of the structure as defined in the International Tables for Crystallography Vol. A. (IUCr, 2005).
4360
cartesian_site_positions:
4461
type: float
4562
shape: [nsites, dimensionality]

entities/OPTIMADEStructureResource.yaml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
uri: http://onto-ns.com/meta/1.0.1/OPTIMADEStructureResource
1+
uri: http://onto-ns.com/meta/1.2.0/OPTIMADEStructureResource
22
description: An OPTIMADE structure resource.
33
dimensions:
44
nelements: Number of different elements in the structure as an integer.
55
dimensionality: Number of spatial dimensions. Must always be 3.
66
nsites: An integer specifying the length of the `cartesian_site_positions` property.
77
nstructure_features: Number of structure features.
8-
## Uncomment when space_group attributes are implemented in OPT.
9-
# nspace_group_symmetry_operations: Number of space group symmetry operations.
8+
nspace_group_symmetry_operations: Number of space group symmetry operations.
109
nspecies: Number of species.
1110
nassemblies: Number of assemblies.
1211
properties:
@@ -59,23 +58,22 @@ properties:
5958
shape: [dimensionality, dimensionality]
6059
unit: Å
6160
description: The three lattice vectors in Cartesian coordinates, in ångström (Å).
62-
## Uncomment when space_group attributes are implemented in OPT.
63-
# space_group_symmetry_operations_xyz:
64-
# type: string
65-
# shape: [nspace_group_symmetry_operations]
66-
# description: List of symmetry operations given as general position x, y and z coordinates in algebraic form.
67-
# space_group_symbol_hall:
68-
# type: string
69-
# description: A Hall space group symbol representing the symmetry of the structure as defined in (Hall, 1981, 1981a).
70-
# space_group_symbol_hermann_mauguin:
71-
# type: string
72-
# description: A human- and machine-readable string containing the short Hermann-Mauguin (H-M) symbol which specifies the space group of the structure in the response.
73-
# space_group_symbol_hermann_mauguin_extended:
74-
# type: string
75-
# description: A human- and machine-readable string containing the extended Hermann-Mauguin (H-M) symbol which specifies the space group of the structure in the response.
76-
# space_group_it_number:
77-
# type: int
78-
# description: Space group number which specifies the space group of the structure as defined in the International Tables for Crystallography Vol. A. (IUCr, 2005).
61+
space_group_symmetry_operations_xyz:
62+
type: string
63+
shape: [nspace_group_symmetry_operations]
64+
description: List of symmetry operations given as general position x, y and z coordinates in algebraic form.
65+
space_group_symbol_hall:
66+
type: string
67+
description: A Hall space group symbol representing the symmetry of the structure as defined in (Hall, 1981, 1981a).
68+
space_group_symbol_hermann_mauguin:
69+
type: string
70+
description: A human- and machine-readable string containing the short Hermann-Mauguin (H-M) symbol which specifies the space group of the structure in the response.
71+
space_group_symbol_hermann_mauguin_extended:
72+
type: string
73+
description: A human- and machine-readable string containing the extended Hermann-Mauguin (H-M) symbol which specifies the space group of the structure in the response.
74+
space_group_it_number:
75+
type: int
76+
description: Space group number which specifies the space group of the structure as defined in the International Tables for Crystallography Vol. A. (IUCr, 2005).
7977
cartesian_site_positions:
8078
type: float
8179
shape: [nsites, dimensionality]

oteapi_optimade/dlite/parse.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
StructureResponseOne,
1515
Success,
1616
)
17-
from oteapi_dlite.models import DLiteSessionUpdate
17+
from oteapi_dlite.models import DLiteResult
1818
from oteapi_dlite.utils import get_collection, update_collection
1919
from pydantic import BaseModel, ValidationError
2020
from pydantic.dataclasses import dataclass
@@ -42,7 +42,7 @@ class OPTIMADEDLiteParseStrategy:
4242

4343
parse_config: OPTIMADEDLiteParseConfig
4444

45-
def initialize(self) -> DLiteSessionUpdate:
45+
def initialize(self) -> DLiteResult:
4646
"""Initialize strategy.
4747
4848
This method will be called through the `/initialize` endpoint of the OTE-API
@@ -53,7 +53,7 @@ def initialize(self) -> DLiteSessionUpdate:
5353
context from services.
5454
5555
"""
56-
return DLiteSessionUpdate(
56+
return DLiteResult(
5757
collection_id=get_collection(
5858
collection_id=self.parse_config.configuration.collection_id
5959
).uuid
@@ -386,6 +386,13 @@ def get(self) -> OPTIMADEParseResult:
386386
"nstructure_features": len(
387387
structure.attributes.structure_features
388388
),
389+
"nspace_group_symmetry_operations": (
390+
len(
391+
structure.attributes.space_group_symmetry_operations_xyz
392+
)
393+
if structure.attributes.space_group_symmetry_operations_xyz
394+
else 0
395+
),
389396
**single_entity_dimensions,
390397
},
391398
properties=new_structure_attributes,
@@ -414,6 +421,13 @@ def get(self) -> OPTIMADEParseResult:
414421
"nstructure_features": len(
415422
structure.attributes.structure_features
416423
),
424+
"nspace_group_symmetry_operations": (
425+
len(
426+
structure.attributes.space_group_symmetry_operations_xyz
427+
)
428+
if structure.attributes.space_group_symmetry_operations_xyz
429+
else 0
430+
),
417431
},
418432
properties=new_structure_attributes,
419433
),
@@ -423,6 +437,7 @@ def get(self) -> OPTIMADEParseResult:
423437
)
424438

425439
dlite_collection.add(label=structure.id, inst=new_structure)
440+
new_structure._incref()
426441

427442
update_collection(collection=dlite_collection)
428443

0 commit comments

Comments
 (0)