Skip to content

Commit

Permalink
Merge branch 'master' into JPBergsma/return_2d_lattice
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Aug 12, 2022
2 parents fbd1725 + d47eec1 commit e7de5f4
Show file tree
Hide file tree
Showing 24 changed files with 285 additions and 130 deletions.
41 changes: 16 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'

- name: Install dependencies
run: |
Expand All @@ -46,10 +46,10 @@ jobs:
with:
submodules: true

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'

- name: Install dependencies
run: |
Expand All @@ -71,10 +71,10 @@ jobs:
with:
submodules: true

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'

- name: Install tools
run: |
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10']

services:
mongo:
Expand Down Expand Up @@ -211,16 +211,7 @@ jobs:
run: |
pip install -r requirements-client.txt
- name: Setup environment for AiiDA v1 (Python 3.7)
if: matrix.python-version == 3.7
env:
AIIDA_TEST_BACKEND: django
run: |
reentry scan
.github/aiida/setup_aiida.sh
- name: Setup environment for AiiDA v2 (Python 3.8+)
if: matrix.python-version != 3.7
- name: Setup environment for AiiDA
env:
AIIDA_TEST_BACKEND: psql_dos
run: |
Expand All @@ -230,20 +221,20 @@ jobs:
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/adapters/

- name: Run tests for validator only to assess coverage (mongomock)
if: matrix.python-version == 3.8
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'

- name: Run tests for validator only to assess coverage (Elasticsearch)
if: matrix.python-version == 3.8
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'elastic'
OPTIMADE_INSERT_TEST_DATA: false # Must be specified as previous steps will have already inserted the test data

- name: Run tests for validator only to assess coverage (MongoDB)
if: matrix.python-version == 3.8
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'
Expand Down Expand Up @@ -278,15 +269,15 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: matrix.python-version == 3.8 && github.repository == 'Materials-Consortia/optimade-python-tools'
if: matrix.python-version == '3.10' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: project
file: ./coverage.xml
flags: project

- name: Upload validator coverage to Codecov
if: matrix.python-version == 3.8 && github.repository == 'Materials-Consortia/optimade-python-tools'
if: matrix.python-version == '3.10' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: validator
Expand All @@ -303,7 +294,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'

- name: Install dependencies
run: |
Expand All @@ -329,10 +320,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'

- name: Install Python dependencies
run: |
Expand Down
18 changes: 0 additions & 18 deletions .readthedocs.yml

This file was deleted.

44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# Changelog

## [Unreleased](https://github.com/Materials-Consortia/optimade-python-tools/tree/HEAD)

[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.19.0...HEAD)

This minor release includes several usability improvements for the server and client arising from the OPTIMADE workshop.
This release also drops support for Python 3.7, which should allow us to streamline our dependencies going forward.

## [v0.19.0](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.19.0) (2022-07-18)

[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.18.0...v0.19.0)

This minor release includes several usability improvements for the server and client arising from the OPTIMADE workshop.
This release also drops support for Python 3.7, which should allow us to streamline our dependencies going forward.

**Implemented enhancements:**

- Support for Elasticsearch v7 [\#1216](https://github.com/Materials-Consortia/optimade-python-tools/pull/1216) ([markus1978](https://github.com/markus1978))

**Fixed bugs:**

- Landing page not loading [\#1256](https://github.com/Materials-Consortia/optimade-python-tools/issues/1256)
- Config values are not cached by `@classproperty` [\#1219](https://github.com/Materials-Consortia/optimade-python-tools/issues/1219)
- Prevent internal validator errors when entries are missing ID/type [\#1273](https://github.com/Materials-Consortia/optimade-python-tools/pull/1273) ([ml-evs](https://github.com/ml-evs))
- Improve error handling for client when updating provider list [\#1222](https://github.com/Materials-Consortia/optimade-python-tools/pull/1222) ([ml-evs](https://github.com/ml-evs))

**Closed issues:**

- Internal validator failures [\#1272](https://github.com/Materials-Consortia/optimade-python-tools/issues/1272)
- Use versioned Dockerfiles for CI services to allow dependabot to update them [\#1241](https://github.com/Materials-Consortia/optimade-python-tools/issues/1241)
- Wrong links to available endpoints [\#1214](https://github.com/Materials-Consortia/optimade-python-tools/issues/1214)
- The validator should check for `meta->schema` [\#1209](https://github.com/Materials-Consortia/optimade-python-tools/issues/1209)
- Add configurable `meta->schemas` field to reference server [\#1208](https://github.com/Materials-Consortia/optimade-python-tools/issues/1208)

**Merged pull requests:**

- Bump providers from `fb05359` to `a92e5bc` [\#1267](https://github.com/Materials-Consortia/optimade-python-tools/pull/1267) ([dependabot[bot]](https://github.com/apps/dependabot))
- Add schema parameter when calling meta\_values in landing.py [\#1257](https://github.com/Materials-Consortia/optimade-python-tools/pull/1257) ([JPBergsma](https://github.com/JPBergsma))
- Update `lark` dependency to new name [\#1231](https://github.com/Materials-Consortia/optimade-python-tools/pull/1231) ([ml-evs](https://github.com/ml-evs))
- Use Python 3.10 instead of 3.7 in installation instructions [\#1229](https://github.com/Materials-Consortia/optimade-python-tools/pull/1229) ([JPBergsma](https://github.com/JPBergsma))
- Optimisation: do not re-access mapper properties inside the request loop [\#1223](https://github.com/Materials-Consortia/optimade-python-tools/pull/1223) ([ml-evs](https://github.com/ml-evs))
- Add meta-\>schema validation warning [\#1211](https://github.com/Materials-Consortia/optimade-python-tools/pull/1211) ([ml-evs](https://github.com/ml-evs))
- Add configurable `schema_url` and `index_schema_url` options [\#1210](https://github.com/Materials-Consortia/optimade-python-tools/pull/1210) ([ml-evs](https://github.com/ml-evs))
- Drop support for Python 3.7 [\#1179](https://github.com/Materials-Consortia/optimade-python-tools/pull/1179) ([ml-evs](https://github.com/ml-evs))

## [v0.18.0](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.18.0) (2022-05-29)

[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.17.2...v0.18.0)
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ optimade-get --filter 'nsites = 1' --output-file results.json https://optimade.h
cat results.json
```

has the followng (truncated) output:
has the following (truncated) output:

```json
{
Expand Down
2 changes: 1 addition & 1 deletion docs/static/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"base_url": null,
"implementation": {
"name": "OPTIMADE Python Tools",
"version": "0.18.0",
"version": "0.19.0",
"source_url": "https://github.com/Materials-Consortia/optimade-python-tools",
"maintainer": {"email": "dev@optimade.org"}
},
Expand Down
2 changes: 1 addition & 1 deletion openapi/index_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.2",
"info": {
"title": "OPTIMADE API - Index meta-database",
"description": "The [Open Databases Integration for Materials Design (OPTIMADE) consortium](https://www.optimade.org/) aims to make materials databases interoperational by developing a common REST API.\nThis is the \"special\" index meta-database.\n\nThis specification is generated using [`optimade-python-tools`](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.18.0) v0.18.0.",
"description": "The [Open Databases Integration for Materials Design (OPTIMADE) consortium](https://www.optimade.org/) aims to make materials databases interoperational by developing a common REST API.\nThis is the \"special\" index meta-database.\n\nThis specification is generated using [`optimade-python-tools`](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.19.0) v0.19.0.",
"version": "1.1.0"
},
"paths": {
Expand Down
14 changes: 7 additions & 7 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.2",
"info": {
"title": "OPTIMADE API",
"description": "The [Open Databases Integration for Materials Design (OPTIMADE) consortium](https://www.optimade.org/) aims to make materials databases interoperational by developing a common REST API.\n\nThis specification is generated using [`optimade-python-tools`](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.18.0) v0.18.0.",
"description": "The [Open Databases Integration for Materials Design (OPTIMADE) consortium](https://www.optimade.org/) aims to make materials databases interoperational by developing a common REST API.\n\nThis specification is generated using [`optimade-python-tools`](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.19.0) v0.19.0.",
"version": "1.1.0"
},
"paths": {
Expand Down Expand Up @@ -3365,9 +3365,9 @@
"type": "number"
},
"description": "If present MUST be a list of floats expressed in a.m.u.\nElements denoting vacancies MUST have masses equal to 0.",
"x-optimade-unit": "a.m.u.",
"x-optimade-support": "optional",
"x-optimade-queryable": "optional"
"x-optimade-queryable": "optional",
"x-optimade-unit": "a.m.u."
},
"original_name": {
"title": "Original Name",
Expand Down Expand Up @@ -3645,9 +3645,9 @@
},
"description": "The three lattice vectors in Cartesian coordinates, in \u00e5ngstr\u00f6m (\u00c5).\n\n- **Type**: list of list of floats or unknown values.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - MUST be a list of three vectors *a*, *b*, and *c*, where each of the vectors MUST BE a list of the vector's coordinates along the x, y, and z Cartesian coordinates.\n (Therefore, the first index runs over the three lattice vectors and the second index runs over the x, y, z Cartesian coordinates).\n - For databases that do not define an absolute Cartesian system (e.g., only defining the length and angles between vectors), the first lattice vector SHOULD be set along *x* and the second on the *xy*-plane.\n - MUST always contain three vectors of three coordinates each, independently of the elements of property `dimension_types`.\n The vectors SHOULD by convention be chosen so the determinant of the `lattice_vectors` matrix is different from zero.\n The vectors in the non-periodic directions have no significance beyond fulfilling these requirements.\n - The coordinates of the lattice vectors of non-periodic dimensions (i.e., those dimensions for which `dimension_types` is `0`) MAY be given as a list of all `null` values.\n If a lattice vector contains the value `null`, all coordinates of that lattice vector MUST be `null`.\n\n- **Examples**:\n - `[[4.0,0.0,0.0],[0.0,4.0,0.0],[0.0,1.0,4.0]]` represents a cell, where the first vector is `(4, 0, 0)`, i.e., a vector aligned along the `x` axis of length 4 \u00c5; the second vector is `(0, 4, 0)`; and the third vector is `(0, 1, 4)`.",
"nullable": true,
"x-optimade-unit": "\u00c5",
"x-optimade-support": "should",
"x-optimade-queryable": "optional"
"x-optimade-queryable": "optional",
"x-optimade-unit": "\u00c5"
},
"cartesian_site_positions": {
"title": "Cartesian Site Positions",
Expand All @@ -3662,9 +3662,9 @@
},
"description": "Cartesian positions of each site in the structure.\nA site is usually used to describe positions of atoms; what atoms can be encountered at a given site is conveyed by the `species_at_sites` property, and the species themselves are described in the `species` property.\n\n- **Type**: list of list of floats\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - It MUST be a list of length equal to the number of sites in the structure, where every element is a list of the three Cartesian coordinates of a site expressed as float values in the unit angstrom (\u00c5).\n - An entry MAY have multiple sites at the same Cartesian position (for a relevant use of this, see e.g., the property `assemblies`).\n\n- **Examples**:\n - `[[0,0,0],[0,0,2]]` indicates a structure with two sites, one sitting at the origin and one along the (positive) *z*-axis, 2 \u00c5 away from the origin.",
"nullable": true,
"x-optimade-unit": "\u00c5",
"x-optimade-support": "should",
"x-optimade-queryable": "optional"
"x-optimade-queryable": "optional",
"x-optimade-unit": "\u00c5"
},
"nsites": {
"title": "Nsites",
Expand Down
19 changes: 1 addition & 18 deletions optimade/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
__version__ = "0.18.0"
__version__ = "0.19.0"
__api_version__ = "1.1.0"

import sys

if sys.version_info.minor == 7:
import warnings

warnings.filterwarnings(
action="once",
message=r"v0\.17 of the `optimade` package.*",
category=DeprecationWarning,
append=True,
)
warnings.warn(
"v0.17 of the `optimade` package will be the last to support Python 3.7. "
"Please upgrade to Python 3.8+ to use v0.18 and later versions of `optimade`.",
DeprecationWarning,
)
10 changes: 6 additions & 4 deletions optimade/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
and [`StructureResource`][optimade.models.structures.StructureResource]s, respectively.
"""
import re
from typing import Union, Dict, Callable, Any, Tuple, List
from typing import Union, Dict, Callable, Any, Tuple, List, Type

from pydantic import BaseModel # pylint: disable=no-name-in-module

Expand All @@ -33,14 +33,16 @@ class EntryAdapter:
Base class for lazy resource entry adapters.
Attributes:
ENTRY_RESOURCE (EntryResource): Entry resource to store entry as.
_type_converters (Dict[str, Callable]): Dictionary of valid conversion types for entry.
ENTRY_RESOURCE: Entry resource to store entry as.
_type_converters: Dictionary of valid conversion types for entry.
as_<_type_converters>: Convert entry to a type listed in `_type_converters`.
from_<_type_converters>: Convert an external type to the corresponding OPTIMADE model.
"""

ENTRY_RESOURCE: EntryResource = EntryResource
ENTRY_RESOURCE: Type[EntryResource] = EntryResource
_type_converters: Dict[str, Callable] = {}
_type_ingesters: Dict[str, Callable] = {}

def __init__(self, entry: dict) -> None:
"""
Expand Down
20 changes: 15 additions & 5 deletions optimade/adapters/structures/adapter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import Callable, Dict, Type
from optimade.models import StructureResource
from optimade.adapters.base import EntryAdapter

from .aiida import get_aiida_structure_data
from .ase import get_ase_atoms
from .cif import get_cif
from .proteindatabank import get_pdb, get_pdbx_mmcif
from .pymatgen import get_pymatgen
from .pymatgen import get_pymatgen, from_pymatgen
from .jarvis import get_jarvis_atoms


Expand All @@ -17,9 +18,9 @@ class Structure(EntryAdapter):
and properties.
Attributes:
ENTRY_RESOURCE (StructureResource): This adapter stores entry resources as
ENTRY_RESOURCE: This adapter stores entry resources as
[`StructureResource`][optimade.models.structures.StructureResource]s.
_type_converters (Dict[str, Callable]): Dictionary of valid conversion types for entry.
_type_converters: Dictionary of valid conversion types for entry.
Currently available types:
Expand All @@ -31,12 +32,17 @@ class Structure(EntryAdapter):
- `pymatgen`
- `jarvis`
_type_ingesters: Dictionary of valid ingesters.
as_<_type_converters>: Convert entry to a type listed in `_type_converters`.
from_<_type_converters>: Convert an external type to an OPTIMADE
[`StructureResourceAttributes`][optimade.models.structures.StructureResourceAttributes]
model.
"""

ENTRY_RESOURCE: StructureResource = StructureResource
_type_converters = {
ENTRY_RESOURCE: Type[StructureResource] = StructureResource
_type_converters: Dict[str, Callable] = {
"aiida_structuredata": get_aiida_structure_data,
"ase": get_ase_atoms,
"cif": get_cif,
Expand All @@ -45,3 +51,7 @@ class Structure(EntryAdapter):
"pymatgen": get_pymatgen,
"jarvis": get_jarvis_atoms,
}

_type_ingesters: Dict[str, Callable] = {
"pymatgen": from_pymatgen,
}
Loading

0 comments on commit e7de5f4

Please sign in to comment.