Skip to content

Commit

Permalink
Manually fix some more cases that ruff could not detect
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Feb 18, 2024
1 parent b735165 commit 60d2622
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 31 deletions.
1 change: 1 addition & 0 deletions src/maggma/stores/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ def rebuild_metadata_from_index(self, index_query: Optional[Dict] = None):
"""
Read data from the index store and populate the metadata of the Azure Blob.
Force all of the keys to be lower case to be Minio compatible
Args:
index_query: query on the index store.
"""
Expand Down
1 change: 1 addition & 0 deletions src/maggma/stores/compound_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def remove_docs(self, criteria: Dict):
def __eq__(self, other: object) -> bool:
"""
Check equality for JointStore
Args:
other: other JointStore to compare with.
"""
Expand Down
55 changes: 28 additions & 27 deletions src/maggma/stores/file_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def __init__(
**kwargs,
):
"""
Initializes a FileStore
Initializes a FileStore.
Args:
path: parent directory containing all files and subdirectories to process
file_filters: List of fnmatch patterns defining the files to be tracked by
Expand Down Expand Up @@ -177,20 +178,20 @@ def read(self) -> List[Dict]:
Iterate through all files in the Store folder and populate
the Store with dictionaries containing basic information about each file.
The keys of the documents added to the Store are
name: str = File name
path: Path = Absolute path of this file
parent: str = Name of the parent directory (if any)
file_id: str = Unique identifier for this file, computed from the hash
of its path relative to the base FileStore directory and
the file creation time. The key of this field is 'file_id'
by default but can be changed via the 'key' kwarg to
FileStore.__init__().
size: int = Size of this file in bytes
last_updated: datetime = Time this file was last modified
hash: str = Hash of the file contents
orphan: bool = Whether this record is an orphan
The keys of the documents added to the Store are:
- name: str = File name
- path: Path = Absolute path of this file
- parent: str = Name of the parent directory (if any)
- file_id: str = Unique identifier for this file, computed from the hash
of its path relative to the base FileStore directory and
the file creation time. The key of this field is 'file_id'
by default but can be changed via the 'key' kwarg to
`FileStore.__init__()`.
- size: int = Size of this file in bytes
- last_updated: datetime = Time this file was last modified
- hash: str = Hash of the file contents
- orphan: bool = Whether this record is an orphan
"""
file_list = []
# generate a list of files in subdirectories
Expand All @@ -214,18 +215,18 @@ def _create_record_from_file(self, f: Path) -> Dict:
basic information about that file. The keys in the returned dict
are:
name: str = File name
path: Path = Absolute path of this file
parent: str = Name of the parent directory (if any)
file_id: str = Unique identifier for this file, computed from the hash
of its path relative to the base FileStore directory and
the file creation time. The key of this field is 'file_id'
by default but can be changed via the 'key' kwarg to
FileStore.__init__().
size: int = Size of this file in bytes
last_updated: datetime = Time this file was last modified
hash: str = Hash of the file contents
orphan: bool = Whether this record is an orphan
- name: str = File name
- path: Path = Absolute path of this file
- parent: str = Name of the parent directory (if any)
- file_id: str = Unique identifier for this file, computed from the hash
of its path relative to the base FileStore directory and
the file creation time. The key of this field is 'file_id'
by default but can be changed via the 'key' kwarg to
FileStore.__init__().
- size: int = Size of this file in bytes
- last_updated: datetime = Time this file was last modified
- hash: str = Hash of the file contents
- orphan: bool = Whether this record is an orphan
"""
# compute the file_id from the relative path
relative_path = f.relative_to(self.path)
Expand Down
3 changes: 2 additions & 1 deletion src/maggma/stores/gridfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ def __init__(
**kwargs,
):
"""
Initializes a GridFS Store for binary data
Initializes a GridFS Store for binary data.
Args:
uri: MongoDB+SRV URI
database: database to connect to
Expand Down
6 changes: 4 additions & 2 deletions src/maggma/stores/mongolike.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def query( # type: ignore

def ensure_index(self, key: str, unique: Optional[bool] = False) -> bool:
"""
Tries to create an index and return true if it succeeded
Tries to create an index and return true if it succeeded.
Args:
key: single key to index
unique: Whether or not this index contains only unique keys.
Expand Down Expand Up @@ -516,7 +517,8 @@ class MemoryStore(MongoStore):

def __init__(self, collection_name: str = "memory_db", **kwargs):
"""
Initializes the Memory Store
Initializes the Memory Store.
Args:
collection_name: name for the collection in memory.
"""
Expand Down
1 change: 1 addition & 0 deletions src/maggma/stores/shared_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def get_store_index(self, store: Store) -> Optional[int]:
Note: this is not a search for an instance of a store,
but rather a search for a equivalent store
Args:
store: The store to find
Expand Down
1 change: 1 addition & 0 deletions tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_msonable(owner_store, pet_store):
def search_helper(payload, base: str = "/?", debug=True) -> Tuple[Response, Any]:
"""
Helper function to directly query search endpoints
Args:
store: store f
base: base of the query, default to /query?
Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_read_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def generate_hints(query):

def search_helper(payload, base: str = "/?", debug=True) -> Response:
"""
Helper function to directly query search endpoints
Helper function to directly query search endpoints.
Args:
store: store f
base: base of the query, default to /query?
Expand Down

0 comments on commit 60d2622

Please sign in to comment.