diff --git a/docs/getting_started/advanced_stores.md b/docs/getting_started/advanced_stores.md index 409806408..5c08a1d39 100644 --- a/docs/getting_started/advanced_stores.md +++ b/docs/getting_started/advanced_stores.md @@ -40,10 +40,12 @@ Different S3 services might have different rules, but the limit is typically sma The `S3Store` should be constructed as follows: ```python -from maggma.stores import MongograntStore, S3Store -index = MongograntStore("ro:mongodb03/js_cathodes", - "atomate_aeccar0_fs_index", - key="fs_id") +from maggma.stores import MongoURIStore, S3Store +store = MongoURIStore( + "mongodb+srv://:@", + "atomate_aeccar0_fs_index", + key="fs_id", +) s3store = S3Store(index=index, bucket="<>", s3_profile="<>", diff --git a/docs/getting_started/stores.md b/docs/getting_started/stores.md index a4ff6bd13..308294fdd 100644 --- a/docs/getting_started/stores.md +++ b/docs/getting_started/stores.md @@ -8,21 +8,22 @@ The benefit of the `Store` interface is that you only have to write a `Builder` Current working and tested `Store` include: -- `MongoStore`: interfaces to a MongoDB Collection +- `MongoStore`: interfaces to a MongoDB Collection using port and hostname. +- `MongoURIStore`: interfaces to a MongoDB Collection using a "mongodb+srv://" URI. - `MemoryStore`: just a Store that exists temporarily in memory - `JSONStore`: builds a MemoryStore and then populates it with the contents of the given JSON files - `FileStore`: query and add metadata to files stored on disk as if they were in a database -- `GridFSStore`: interfaces to GridFS collection in MongoDB +- `GridFSStore`: interfaces to GridFS collection in MongoDB using port and hostname. +- `GridFSURIStore`: interfaces to GridFS collection in MongoDB using a "mongodb+srv://" URI. - `S3Store`: provides an interface to an S3 Bucket either on AWS or self-hosted solutions ([additional documentation](advanced_stores.md)) - `ConcatStore`: concatenates several Stores together so they look like one Store -- `MongoURIStore`: MongoDB Introduced advanced URIs including their special "mongodb+srv://" which uses a combination of SRV and TXT DNS records to fully setup the client. This store is to safely handle these kinds of URIs. -- `MongograntStore`: uses Mongogrant to get credentials for MongoDB database - `VaultStore`: uses Vault to get credentials for a MongoDB database - `AliasingStore`: aliases keys from the underlying store to new names - `SandboxStore: provides permission control to documents via a `_sbxn` sandbox key - `JointStore`: joins several MongoDB collections together, merging documents with the same `key`, so they look like one collection - `AzureBlobStore`: provides an interface to Azure Blobs for the storage of large amount of data - `MontyStore`: provides an interface to [montydb](https://github.com/davidlatwe/montydb) for in-memory or filesystem-based storage +- `MongograntStore`: (DEPRECATED) uses Mongogrant to get credentials for MongoDB database ## The `Store` interface diff --git a/pyproject.toml b/pyproject.toml index 2e233a499..08585720f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "pydantic>=2.0", "pydantic-settings>=2.0.3", "pymongo>=4.2.0", - "monty>=2023.9.25", + "monty>=2024.5.24", "mongomock>=3.10.0", "pydash>=4.1.0", "jsonschema>=3.1.1", diff --git a/src/maggma/stores/advanced_stores.py b/src/maggma/stores/advanced_stores.py index c0fc8b808..a93f72fe5 100644 --- a/src/maggma/stores/advanced_stores.py +++ b/src/maggma/stores/advanced_stores.py @@ -6,10 +6,7 @@ from collections.abc import Iterator from typing import Optional, Union -from mongogrant import Client -from mongogrant.client import check -from mongogrant.config import Config -from monty.dev import requires +from monty.dev import deprecated, requires from maggma.core import Sort, Store, StoreError from maggma.stores.mongolike import MongoStore @@ -19,8 +16,15 @@ import hvac except ImportError: hvac = None +try: + from mongogrant import Client + from mongogrant.client import check + from mongogrant.config import Config +except ImportError: + Client = None +@deprecated(MongoStore) class MongograntStore(MongoStore): """Initialize a Store with a mongogrant "``:``/``." spec. @@ -30,6 +34,10 @@ class MongograntStore(MongoStore): mongogrant documentation: https://github.com/materialsproject/mongogrant """ + @requires( + Client is not None, + "mongogrant is required to use MongoGrantStore. Please run `pip install maggma[mongogrant]", + ) def __init__( self, mongogrant_spec: str,