Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize package #113

Merged
merged 3 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/index_openapi_diff.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
# Note: This returns exit code 0, if the two specs agree, otherwise exit code 1
docker run -t -v $(pwd):/specs:ro quen2404/openapi-diff /specs/index_openapi.json /specs/local_index_openapi.json
docker run -t -v $(pwd):/specs:ro quen2404/openapi-diff /specs/openapi/index_openapi.json /specs/openapi/local_index_openapi.json
4 changes: 2 additions & 2 deletions .ci/json_diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
python -c "from optimade.server.main import app, update_schema; update_schema(app)"
python -c "from optimade.server.main_index import app, update_schema; update_schema(app)"

diff=$(jsondiff openapi.json local_openapi.json);
index_diff=$(jsondiff index_openapi.json local_index_openapi.json);
diff=$(jsondiff ./openapi/openapi.json ./openapi/local_openapi.json);
index_diff=$(jsondiff ./openapi/index_openapi.json ./openapi/local_index_openapi.json);

if [ ! "$diff" = "{}" ]; then
echo -e "Generated OpenAPI spec for test server did not match committed version.\nRun 'invoke update_openapijson' and re-commit.\nDiff:\n$diff";
Expand Down
2 changes: 1 addition & 1 deletion .ci/openapi_diff.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
# Note: This returns exit code 0, if the two specs agree, otherwise exit code 1
docker run -t -v $(pwd):/specs:ro quen2404/openapi-diff /specs/openapi.json /specs/local_openapi.json
docker run -t -v $(pwd):/specs:ro quen2404/openapi-diff /specs/openapi/openapi.json /specs/openapi/local_openapi.json
File renamed without changes.
16 changes: 11 additions & 5 deletions .github/workflows/deps_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,19 @@ jobs:
docker pull quen2404/openapi-diff

- name: Validate OpenAPI specifications
run: openapi-spec-validator openapi.json
run: |
openapi-spec-validator openapi/openapi.json
openapi-spec-validator openapi/index_openapi.json

- name: Update OpenAPI schema
run: python -c "from optimade.server.main import app, update_schema; update_schema(app)"
- name: Update OpenAPI schemes
run: |
python -c "from optimade.server.main import app, update_schema; update_schema(app)"
python -c "from optimade.server.main_index import app, update_schema; update_schema(app)"

- name: Check if OpenAPI schemes match
run: .ci/openapi_diff.sh
run: |
.ci/openapi_diff.sh
.ci/index_openapi_diff.sh

deps_static:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,7 +122,7 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
yml: ./codecov.yml
yml: ./.codecov.yml

deps_eager:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ start
# Assumes graphviz installed on system (e.g. `conda install -c anaconda graphviz`) and `pip install pydot`
from lark.tree import pydot__tree_to_png

pydot__tree_to_png(tree, "exampletree.png")
pydot__tree_to_png(tree, "images/exampletree.png")
```
![example tree](exampletree.png)
![example tree](images/exampletree.png)

#### Flow for Parsing User-Supplied Filter and Converting to Backend Query

Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Empty file.
12 changes: 4 additions & 8 deletions optimade/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@


test_paths = {
"structures": Path(__file__)
.resolve()
.parent.joinpath("tests/test_structures.json"),
"references": Path(__file__)
.resolve()
.parent.joinpath("tests/test_references.json"),
"links": Path(__file__).resolve().parent.joinpath("tests/test_links.json"),
"structures": Path(__file__).resolve().parent.joinpath("data/test_structures.json"),
"references": Path(__file__).resolve().parent.joinpath("data/test_references.json"),
"links": Path(__file__).resolve().parent.joinpath("data/test_links.json"),
}
if not CONFIG.use_real_mongo and (path.exists() for path in test_paths.values()):
import bson.json_util
Expand Down Expand Up @@ -93,7 +89,7 @@ def load_entries(endpoint_name: str, endpoint_collection: MongoCollection):

def update_schema(app):
"""Update OpenAPI schema in file 'local_openapi.json'"""
with open("local_openapi.json", "w") as f:
with open("openapi/local_openapi.json", "w") as f:
json.dump(app.openapi(), f, indent=2)


Expand Down
2 changes: 1 addition & 1 deletion optimade/server/main_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

def update_schema(app):
"""Update OpenAPI schema in file 'local_index_openapi.json'"""
with open("local_index_openapi.json", "w") as f:
with open("openapi/local_index_openapi.json", "w") as f:
json.dump(app.openapi(), f, indent=2)


Expand Down
Empty file.
Binary file removed optimade_general_procedure.jpg
Binary file not shown.
Binary file removed optimade_to_mongodb_procedure.jpg
Binary file not shown.
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ def setver(_, patch=False, new_ver=""):

@task
def update_openapijson(c):
c.run("cp local_openapi.json openapi.json")
c.run("cp local_index_openapi.json index_openapi.json")
c.run("cp openapi/local_openapi.json openapi/openapi.json")
c.run("cp openapi/local_index_openapi.json openapi/index_openapi.json")
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_good_structures(self):
test_structures_path = (
Path(__file__)
.resolve()
.parent.joinpath("../../server/tests/test_structures.json")
.parent.joinpath("../../optimade/server/data/test_structures.json")
)
with open(test_structures_path, "r") as f:
good_structures = json.load(f)
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_good_references(self):
test_refs_path = (
Path(__file__)
.resolve()
.parent.joinpath("../../server/tests/test_references.json")
.parent.joinpath("../../optimade/server/data/test_references.json")
)
with open(test_refs_path, "r") as f:
good_refs = json.load(f)
Expand Down
File renamed without changes.