Skip to content

Commit 3a908bc

Browse files
committed
Merged changes from master.
2 parents 4c46f55 + 105b501 commit 3a908bc

File tree

127 files changed

+1312
-1046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1312
-1046
lines changed

.github/fly.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# fly.toml file generated for broken-field-1976 on 2022-11-21T21:37:55Z
2+
3+
app = "optimade"
4+
kill_signal = "SIGINT"
5+
kill_timeout = 5
6+
processes = []
7+
8+
[env]
9+
10+
[experimental]
11+
allowed_public_ports = []
12+
auto_rollback = true
13+
14+
[[services]]
15+
http_checks = []
16+
internal_port = 5000
17+
processes = ["app"]
18+
protocol = "tcp"
19+
script_checks = []
20+
[services.concurrency]
21+
hard_limit = 25
22+
soft_limit = 20
23+
type = "connections"
24+
25+
[[services.ports]]
26+
force_https = true
27+
handlers = ["http"]
28+
port = 80
29+
30+
[[services.ports]]
31+
handlers = ["tls", "http"]
32+
port = 443
33+
34+
[[services.tcp_checks]]
35+
grace_period = "1s"
36+
interval = "15s"
37+
restart_limit = 0
38+
timeout = "2s"

.github/workflows/ci.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- master
88
- 'push-action/**'
99

10+
env:
11+
PYTEST_ADDOPTS: "--color=yes"
12+
1013
# Cancel running workflows when additional changes are pushed
1114
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
1215
concurrency:
@@ -57,6 +60,7 @@ jobs:
5760
pip install -U setuptools wheel
5861
pip install -e .
5962
pip install -r requirements.txt
63+
pip install -r requirements-server.txt
6064
pip install -r requirements-dev.txt
6165
6266
- name: Run pre-commit
@@ -82,6 +86,7 @@ jobs:
8286
pip install -U setuptools wheel
8387
pip install -e .
8488
pip install -r requirements.txt
89+
pip install -r requirements-server.txt
8590
pip install -r requirements-dev.txt
8691
8792
- name: Pass generated OpenAPI schemas through validator.swagger.io
@@ -162,7 +167,7 @@ jobs:
162167
ports:
163168
- 5432:5432
164169
elasticsearch:
165-
image: elasticsearch:7.17.1
170+
image: elasticsearch:7.17.7
166171
ports:
167172
- 9200:9200
168173
- 9300:9300
@@ -191,25 +196,29 @@ jobs:
191196
pip install -r requirements-dev.txt
192197
pip install -r requirements-http-client.txt
193198
194-
- name: Run all tests (using `mongomock`)
195-
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml tests/
199+
- name: Run non-server tests
200+
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml tests/ --ignore tests/server
201+
202+
- name: Install latest server dependencies
203+
run: pip install -r requirements-server.txt
204+
205+
- name: Run server tests (using `mongomock`)
206+
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
196207
env:
197208
OPTIMADE_DATABASE_BACKEND: 'mongomock'
198209

199-
200210
- name: Run server tests (using a real MongoDB)
201-
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server
211+
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
202212
env:
203213
OPTIMADE_DATABASE_BACKEND: 'mongodb'
204214

205215
- name: Run server tests (using Elasticsearch)
206-
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server
216+
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
207217
env:
208218
OPTIMADE_DATABASE_BACKEND: 'elastic'
209219

210220
- name: Install adapter conversion dependencies
211-
run: |
212-
pip install -r requirements-client.txt
221+
run: pip install -r requirements-client.txt
213222

214223
- name: Setup environment for AiiDA
215224
env:
@@ -246,22 +255,22 @@ jobs:
246255
coverage run --append --source optimade optimade/client/cli.py \
247256
--filter 'nsites = 1' \
248257
--output-file test_get_async.json \
249-
https://optimade.herokuapp.com
258+
https://optimade.fly.dev
250259
test test_get_async.json
251260
252261
coverage run --append --source optimade optimade/client/cli.py \
253262
--filter 'nsites = 1' \
254263
--count \
255264
--output-file test_count.json \
256-
https://optimade.herokuapp.com
265+
https://optimade.fly.dev
257266
test test_count.json
258267
259268
coverage run --append --source optimade optimade/client/cli.py \
260269
--no-async \
261270
--filter 'nsites = 1' \
262271
--count \
263272
--output-file test_count_no_async.json \
264-
https://optimade.herokuapp.com
273+
https://optimade.fly.dev
265274
test test_count_no_async.json
266275
267276
diff test_count_no_async.json test_count.json
@@ -302,6 +311,7 @@ jobs:
302311
pip install -U setuptools wheel
303312
pip install -e .
304313
pip install -r requirements.txt
314+
pip install -r requirements-server.txt
305315
pip install -r requirements-dev.txt
306316
pip install -r requirements-http-client.txt
307317
pip install -r requirements-docs.txt

.github/workflows/ci_cd_updated_master.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,25 @@ jobs:
135135
sleep: 15
136136
force: ${{ env.FORCE_PUSH }}
137137

138-
deploy-heroku:
138+
deploy-fly:
139+
env:
140+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
141+
OPTIMADE_CONFIG_FILE: /app/tests/test_config.json
142+
OPTIMADE_BASE_URL: https://optimade.fly.dev
139143
runs-on: ubuntu-latest
140144
if: github.repository_owner == 'Materials-Consortia'
141145
steps:
142146
- name: Checkout repository
143147
uses: actions/checkout@v3
144-
145-
- name: Deploy to Heroku
146-
uses: akhileshns/heroku-deploy@v3.12.12
147148
with:
148-
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
149-
heroku_app_name: "optimade"
150-
heroku_email: ${{secrets.HEROKU_EMAIL}}
151-
branch: ${{env.DEFAULT_REPO_BRANCH}}
152-
env:
153-
HD_OPTIMADE_CONFIG_FILE: /app/tests/test_config.json
154-
HD_OPTIMADE_BASE_URL: https://optimade.herokuapp.com
149+
fetch-depth: 0
150+
submodules: true
151+
152+
- name: Set up Fly
153+
uses: superfly/flyctl-actions/setup-flyctl@master
154+
155+
- name: Deploy to Fly
156+
run: flyctl deploy --remote-only -c ./.github/fly.toml
155157

156158
publish_container_image:
157159
name: Publish container image

.pre-commit-config.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
name: Blacken
1010

1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.3.0
12+
rev: v4.4.0
1313
hooks:
1414
- id: check-symlinks
1515
- id: check-yaml
@@ -24,7 +24,7 @@ repos:
2424
args: [--markdown-linebreak-ext=md]
2525

2626
- repo: https://github.com/pycqa/flake8
27-
rev: '3.9.2'
27+
rev: '6.0.0'
2828
hooks:
2929
- id: flake8
3030

@@ -43,3 +43,16 @@ repos:
4343
pass_filenames: false
4444
files: ^optimade/.*\.py$
4545
description: Update the API Reference documentation whenever a Python file is touched in the code base.
46+
47+
- repo: https://github.com/pre-commit/mirrors-mypy
48+
rev: v0.991
49+
hooks:
50+
- id: mypy
51+
name: "MyPy"
52+
additional_dependencies: ["types-all", "pydantic~=1.10"]
53+
54+
- repo: https://github.com/PyCQA/isort
55+
rev: 5.10.1
56+
hooks:
57+
- id: isort
58+
name: "isort"

CHANGELOG.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,60 @@
22

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

5-
[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.19.4...HEAD)
5+
[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.20.0...HEAD)
66

7-
This is a hotfix release for #1335, a bug regarding chunked responses triggered when using the latest FastAPI version.
7+
This release continues the modularisation of the package by moving the server exceptions and warnings out into top-level modules, and removing the core dependency on FastAPI (now a server dependency only). This should allow for easier use of the `optimade.models` and `optimade.client` modules within other packages.
8+
9+
Aside from that, the package now supports Python 3.11, and our example server is now deployed at [Fly.io](https://optimade.fly.dev) rather than Heroku.
10+
11+
## [v0.20.0](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.20.0) (2022-11-29)
12+
13+
[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.19.4...v0.20.0)
14+
15+
This release continues the modularisation of the package by moving the server exceptions and warnings out into top-level modules, and removing the core dependency on FastAPI (now a server dependency only). This should allow for easier use of the `optimade.models` and `optimade.client` modules within other packages.
16+
17+
Aside from that, the package now supports Python 3.11, and our example server is now deployed at [Fly.io](https://optimade.fly.dev) rather than Heroku.
18+
19+
**Implemented enhancements:**
20+
21+
- Add support for Python 3.11 [\#1361](https://github.com/Materials-Consortia/optimade-python-tools/issues/1361)
22+
- Improve test diagnostics and fix deprecated Elasticsearch calls [\#1373](https://github.com/Materials-Consortia/optimade-python-tools/pull/1373) ([ml-evs](https://github.com/ml-evs))
23+
- Support Python 3.11 [\#1362](https://github.com/Materials-Consortia/optimade-python-tools/pull/1362) ([ml-evs](https://github.com/ml-evs))
824

925
**Fixed bugs:**
1026

11-
- UnboundLocalError - `chunk_size` is not always set in middleware method [\#1335](https://github.com/Materials-Consortia/optimade-python-tools/issues/1335)
27+
- Elasticsearch pytest oneliner in the docs is no longer working [\#1377](https://github.com/Materials-Consortia/optimade-python-tools/issues/1377)
28+
- Remote swagger validator has changed output format [\#1370](https://github.com/Materials-Consortia/optimade-python-tools/issues/1370)
29+
30+
**Closed issues:**
31+
32+
- Fully isolate server code from other submodules [\#1403](https://github.com/Materials-Consortia/optimade-python-tools/issues/1403)
33+
- Replace https://gitlab.com/pycqa/flake8 with https://github.com/pycqa/flake8 [\#1388](https://github.com/Materials-Consortia/optimade-python-tools/issues/1388)
34+
- OpenAPI schema should not enforce recommended constraint on `page_number` [\#1372](https://github.com/Materials-Consortia/optimade-python-tools/issues/1372)
35+
- Pydantic models docs are broken on the mkdocs site with new renderer [\#1353](https://github.com/Materials-Consortia/optimade-python-tools/issues/1353)
36+
- Migrate away from Heroku for demo server [\#1307](https://github.com/Materials-Consortia/optimade-python-tools/issues/1307)
37+
- FastAPI should not be a core dependency [\#1198](https://github.com/Materials-Consortia/optimade-python-tools/issues/1198)
38+
39+
**Merged pull requests:**
40+
41+
- Move exceptions and warnings out of server code and separate deps [\#1405](https://github.com/Materials-Consortia/optimade-python-tools/pull/1405) ([ml-evs](https://github.com/ml-evs))
42+
- Complete migration from Heroku to Fly [\#1400](https://github.com/Materials-Consortia/optimade-python-tools/pull/1400) ([ml-evs](https://github.com/ml-evs))
43+
- Add GH actions for deploying example server to Fly [\#1396](https://github.com/Materials-Consortia/optimade-python-tools/pull/1396) ([ml-evs](https://github.com/ml-evs))
44+
- Support new remote swagger.io validator format [\#1371](https://github.com/Materials-Consortia/optimade-python-tools/pull/1371) ([ml-evs](https://github.com/ml-evs))
45+
- Do not enforce minimum value of `page_number` at model level [\#1369](https://github.com/Materials-Consortia/optimade-python-tools/pull/1369) ([ml-evs](https://github.com/ml-evs))
46+
- Enable `mypy` and `isort` in pre-commit & CI [\#1346](https://github.com/Materials-Consortia/optimade-python-tools/pull/1346) ([ml-evs](https://github.com/ml-evs))
47+
- Remove randomness from structure utils tests [\#1338](https://github.com/Materials-Consortia/optimade-python-tools/pull/1338) ([ml-evs](https://github.com/ml-evs))
48+
- Demote FastAPI to a server dep only [\#1199](https://github.com/Materials-Consortia/optimade-python-tools/pull/1199) ([ml-evs](https://github.com/ml-evs))
1249

1350
## [v0.19.4](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.19.4) (2022-09-19)
1451

1552
[Full Changelog](https://github.com/Materials-Consortia/optimade-python-tools/compare/v0.19.3...v0.19.4)
1653

54+
This is a hotfix release for #1335, a bug regarding chunked responses triggered when using the latest FastAPI version.
55+
1756
**Fixed bugs:**
1857

58+
- UnboundLocalError - `chunk_size` is not always set in middleware method [\#1335](https://github.com/Materials-Consortia/optimade-python-tools/issues/1335)
1959
- Ensure `chunk_size` is properly set when chunking responses [\#1336](https://github.com/Materials-Consortia/optimade-python-tools/pull/1336) ([ml-evs](https://github.com/ml-evs))
2060

2161
## [v0.19.3](https://github.com/Materials-Consortia/optimade-python-tools/tree/v0.19.3) (2022-09-06)

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ These commands should be run from a local optimade-python-tools directory.
101101
The following command starts a local Elasticsearch v6 instance, runs the test suite, then stops and deletes the containers (required as the tests insert some data):
102102

103103
```shell
104-
docker run -d --name elasticsearch_test -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" elasticsearch:7.17.1 \
104+
docker run -d --name elasticsearch_test -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" elasticsearch:7.17.7 \
105105
&& sleep 10 \
106106
&& OPTIMADE_DATABASE_BACKEND="elastic" py.test; \
107107
docker container stop elasticsearch_test; docker container rm elasticsearch_test

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ OPTIMADE Python tools
3131
<td align="center">
3232
<a href="https://github.com/Materials-Consortia/optimade-python-tools/actions?query=branch%3Amaster+"><img alt="Build Status" src="https://img.shields.io/github/workflow/status/Materials-Consortia/optimade-python-tools/CI%20tests?logo=github"></a><br>
3333
<a href="https://codecov.io/gh/Materials-Consortia/optimade-python-tools"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/Materials-Consortia/optimade-python-tools?logo=codecov&logoColor=white&token=UJAtmqkZZO"></a><br>
34-
<a href="https://optimade.herokuapp.com"><img alt="Heroku App Status" src="https://heroku-shields.herokuapp.com/optimade??logo=heroku"></a>
3534
</td>
3635
<td align="center">
3736
<a href="https://github.com/Materials-Consortia/optimade-python-tools/pulse"><img alt="Commit Activity" src="https://img.shields.io/github/commit-activity/m/Materials-Consortia/optimade-python-tools?logo=github"></a><br>
@@ -50,7 +49,7 @@ This is to enable interoperability among databases that serve crystal structures
5049
This repository contains a library of tools for implementing and consuming [OPTIMADE APIs](https://www.optimade.org) using Python:
5150

5251
1. [pydantic](https://github.com/pydantic/pydantic) data models for all [OPTIMADE entry types](https://www.optimade.org/optimade-python-tools/latest/all_models/) and endpoint responses, and a [Lark](https://github.com/lark-parser/lark) [EBNF grammar](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) implementation for the OPTIMADE filter language.
53-
1. A configurable reference server implementation that can make use of either MongoDB or Elasticsearch database backends out-of-the-box, and is readily extensible to other backends. Try it out on the [demo site](https://optimade.herokuapp.com)! The OpenAPI schemas of the server are used to construct the [OPTIMADE schemas](https://schemas.optimade.org/) site.
52+
1. A configurable reference server implementation that can make use of either MongoDB or Elasticsearch database backends out-of-the-box, and is readily extensible to other backends. Try it out on the [demo site](https://optimade.fly.dev)! The OpenAPI schemas of the server are used to construct the [OPTIMADE schemas](https://schemas.optimade.org/) site.
5453
1. An [OPTIMADE client](https://www.optimade.org/optimade-python-tools/latest/getting_started/client/) (`optimade-get`) that can query multiple [OPTIMADE providers](https://optimade.org/providers-dashboard) concurrently with a given filter, at the command-line or from Python code.
5554
1. A fuzzy API validator tool, which may be called from the shell (`optimade-validator`) or used as a GitHub Action from [optimade-validator-action](https://github.com/Materials-Consortia/optimade-validator-action); this validator is used to construct the [providers dashboard](https://optimade.org/providers-dashboard).
5655

docs/api_reference/exceptions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# exceptions
2+
3+
::: optimade.exceptions

docs/api_reference/utils.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# utils
2+
3+
::: optimade.utils

docs/api_reference/warnings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# warnings
2+
3+
::: optimade.warnings

0 commit comments

Comments
 (0)