-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to use a MongoDB. Through the `--mongo` option for `aiida-optimade init` the AiiDA-OPTIMADE server will be initialized with a MongoDB. All relevant fields will be added to each document, representing the relevant StructureData or CifData Node. The tests have been updated to reflect the new possibility, along with relevant code in the code base, where needed. The tests can be run with MongoDB by setting the env var PYTEST_OPTIMADE_CONFIG_FILE, the value being a path to the config file to be used. A new docker-compose-mongo.yml file has been created to instantiate both the AiiDA-OPTIMADE server service as well as a MongoDB 4.2 service. CI jobs have been added to test both pytest and different docker setups for the MongoDB backend.
- Loading branch information
Showing
29 changed files
with
1,054 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"page_limit": 15, | ||
"page_limit_max": 500, | ||
"base_url": null, | ||
"mongo_uri": "mongodb://docker.host.internal:27017", | ||
"use_real_mongo": true, | ||
"mongo_database": "aiida_optimade", | ||
"provider": { | ||
"prefix": "aiida", | ||
"name": "AiiDA", | ||
"description": "AiiDA: Automated Interactive Infrastructure and Database for Computational Science (http://www.aiida.net)", | ||
"homepage": "http://www.aiida.net", | ||
"index_base_url": null | ||
}, | ||
"implementation": { | ||
"name": "aiida-optimade", | ||
"version": "0.14.1", | ||
"source_url": "https://github.com/aiidateam/aiida-optimade", | ||
"maintainer": {"email": "casper.andersen@epfl.ch"} | ||
}, | ||
"provider_fields": { | ||
"structures": [ | ||
"ctime" | ||
] | ||
}, | ||
"aliases": { | ||
"structures": { | ||
"type": "node_type" | ||
} | ||
}, | ||
"log_level": "debug" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
from pathlib import Path | ||
import sys | ||
|
||
import bson.json_util | ||
from pymongo import MongoClient | ||
|
||
client = MongoClient("mongodb://localhost:27017") | ||
collection = client["aiida_optimade"]["structures"] | ||
|
||
with open(Path(__file__).parent.joinpath("test_structures_mongo.json")) as handle: | ||
data = bson.json_util.loads(handle.read()) | ||
|
||
try: | ||
print(f"Inserting {len(data)} structures into {collection.full_name}") | ||
collection.insert_many(data, ordered=False) | ||
except Exception as exc: # pylint: disable=broad-except | ||
print("An error occurred!") | ||
sys.exit(exc) | ||
else: | ||
print("Done!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../tests/static/test_structures_mongo.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.