dsa-helpers 0.4.dev1__tar.gz → 0.4.dev3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dsa_helpers-0.4.dev1/dsa_helpers.egg-info → dsa_helpers-0.4.dev3}/PKG-INFO +1 -1
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/mongo_utils.py +10 -14
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3/dsa_helpers.egg-info}/PKG-INFO +1 -1
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/pyproject.toml +1 -1
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/.gitignore +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/LICENSE +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/README.md +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/app.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/__init__.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/dash/__init__.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/dash/header.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/dash/header_callbacks.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/girder_utils.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/image_utils.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/imread.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/imwrite.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/login.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/ml/__init__.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/ml/object_detection/__init__.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/ml/object_detection/get_pearce_roi_images.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/ml/object_detection/tile_image.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers/ml/object_detection/utils.py +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers.egg-info/SOURCES.txt +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers.egg-info/dependency_links.txt +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers.egg-info/requires.txt +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/dsa_helpers.egg-info/top_level.txt +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/readthedocs.yaml +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/requirements.txt +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/setup.cfg +0 -0
- {dsa_helpers-0.4.dev1 → dsa_helpers-0.4.dev3}/tests/test.ipynb +0 -0
|
@@ -13,7 +13,7 @@ def get_mongo_client(
|
|
|
13
13
|
username: str | None = None,
|
|
14
14
|
password: str | None = None,
|
|
15
15
|
port: int | None = None,
|
|
16
|
-
)
|
|
16
|
+
):
|
|
17
17
|
"""Get a mongo client by providing the key parts of the URL. By default
|
|
18
18
|
when the parameters are not passed, it sets them to default values first
|
|
19
19
|
by looking at key environment variables. If the environment variables are
|
|
@@ -36,7 +36,7 @@ def get_mongo_client(
|
|
|
36
36
|
missing it will default to 27017.
|
|
37
37
|
|
|
38
38
|
Returns:
|
|
39
|
-
|
|
39
|
+
The mongo client.
|
|
40
40
|
|
|
41
41
|
"""
|
|
42
42
|
if username is None:
|
|
@@ -67,7 +67,7 @@ def chunks(lst: list, n=500):
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def add_many_to_collection(
|
|
70
|
-
mongo_collection
|
|
70
|
+
mongo_collection,
|
|
71
71
|
items: dict | list,
|
|
72
72
|
key: str = "_id",
|
|
73
73
|
) -> dict[str | dict]:
|
|
@@ -75,7 +75,7 @@ def add_many_to_collection(
|
|
|
75
75
|
user key.
|
|
76
76
|
|
|
77
77
|
Args:
|
|
78
|
-
mongo_collection
|
|
78
|
+
mongo_collection: The mongo collection to add to.
|
|
79
79
|
items (dict | list): The items to add to the collection.
|
|
80
80
|
key (str): The key to use to identify the items.
|
|
81
81
|
|
|
@@ -89,10 +89,8 @@ def add_many_to_collection(
|
|
|
89
89
|
|
|
90
90
|
operations = []
|
|
91
91
|
|
|
92
|
-
for item in items:
|
|
93
|
-
operations.append(
|
|
94
|
-
pymongo.UpdateOne({"_id": item[key]}, {"$set": item}, upsert=True)
|
|
95
|
-
)
|
|
92
|
+
for _id, item in items.items():
|
|
93
|
+
operations.append(pymongo.UpdateOne({"_id": _id}, {"$set": item}, upsert=True))
|
|
96
94
|
|
|
97
95
|
for chunk in chunks(operations):
|
|
98
96
|
_ = mongo_collection.bulk_write(chunk)
|
|
@@ -100,13 +98,11 @@ def add_many_to_collection(
|
|
|
100
98
|
return items
|
|
101
99
|
|
|
102
100
|
|
|
103
|
-
def get_img_from_db(
|
|
104
|
-
mongo_db: pymongo.database.Database, img_id: str
|
|
105
|
-
) -> Union[np.ndarray, None]:
|
|
101
|
+
def get_img_from_db(mongo_db, img_id: str) -> Union[np.ndarray, None]:
|
|
106
102
|
"""Get an image from the database by its location id.
|
|
107
103
|
|
|
108
104
|
Args:
|
|
109
|
-
mongo_db
|
|
105
|
+
mongo_db: The mongo database.
|
|
110
106
|
img_loc (str): The image id in mongo.
|
|
111
107
|
|
|
112
108
|
Returns:
|
|
@@ -131,13 +127,13 @@ def get_img_from_db(
|
|
|
131
127
|
|
|
132
128
|
|
|
133
129
|
def add_img_to_db(
|
|
134
|
-
mongo_db
|
|
130
|
+
mongo_db,
|
|
135
131
|
img: Image.Image | np.ndarray,
|
|
136
132
|
) -> str:
|
|
137
133
|
"""Add an image to the database.
|
|
138
134
|
|
|
139
135
|
Args:
|
|
140
|
-
mongo_db
|
|
136
|
+
mongo_db: The mongo database.
|
|
141
137
|
img (np.ndarray or PIL.Image.Image): The image.
|
|
142
138
|
|
|
143
139
|
Returns:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|