mongospawn is a tool to help spawn MongoDB resources given JSON Schema
specifications.
The primary near-term use case is support for the National Microbiome Data
Collaborative (NMDC) pilot project. In particular,
given a JSON Schema with all array-typed properties and with each array item a
$ref reference to one of the JSON Schema definitions (see NMDC
example),
mongospawn can generate MongoDB $jsonSchema documents to apply as validators
for collections in a database that correspond to each of the original JSON
Schema's array-typed properties. MongoDB's implementation of JSON Schema does
not support $ref, definitions, etc., so mongospawn expands references to
generate appropriate per-collection schema documents.
In addition to generating derived schema documents, mongospawn can spawn new
databases/collections, with schema validation set, via the pymongo driver, and
can also manage access to the spawned resources via mongogrant.
Setup
For development:
pip install -e .[dev]
To update dependency versions:
make update
To use pinned dependencies for reproducible testing:
make
Usage
Example using NMDC's JSON Schema:
from mongospawn.schema import dbschema_from_file, collschemas_for
from pymongo import MongoClient
client = MongoClient()
db = client.nmdc_test
dbschema = dbschema_from_file("nmdc.schema.json")
collschemas = collschemas_for(dbschema)
for name in collschemas:
db.drop_collection(name)
db.create_collection(name, validator={"$jsonSchema": collschemas[name]})
print(f"created {name} collection")
# created activity_set collection
# created biosample_set collection
# created data_object_set collection
# created omics_processing_set collection
# created study_set collection
Now, e.g. if you try to insert a non-conformant JSON document, a
pymongo.errors.WriteError will be raised:
db.biosample_set.insert_one({"not_a_real_field": 1})
# => WriteError: Document failed validation...
Metadata
Release files for mongospawn 0.5.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mongospawn-0.5.10.tar.gz | 18.6 kB | Without provenance | Details for mongospawn-0.5.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mongospawn-0.5.10-py2-none-any.whl | Python 2 | none | any | Details for mongospawn-0.5.10-py2-none-any.whl |
Total release size: 23.4 kB
Release files / mongospawn-0.5.10.tar.gz
| Download URL | mongospawn-0.5.10.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
992c26c825377ffd202783d6f39d3c369148ef3dd3b5b94512aabb81474037ff
|
|
BLAKE2b-256 checksum How to use checksums |
590f7c10b0dec61acc4ac471e1d8ee42838fc1f5decea7c29a57cb2fd8d8f9eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3.post20210118 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|
Release files / mongospawn-0.5.10-py2-none-any.whl
| Download URL | mongospawn-0.5.10-py2-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
54c7478ee8180267050ce095dd4ac7796d717028a01ce07e1300bec7a9b5ed98
|
|
BLAKE2b-256 checksum How to use checksums |
534255b275879e9aa09c5b4e008b7bf5fdd00bfe640510521f42cec7af480e9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3.post20210118 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|
Security for mongospawn 0.5.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.