dayhoff-tools 1.1.42__py3-none-any.whl → 1.2.0__py3-none-any.whl

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.
dayhoff_tools/__init__.py CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
dayhoff_tools/cli/main.py CHANGED
File without changes
File without changes
File without changes
@@ -281,7 +281,7 @@ def run_container(config: dict, image_uri: str, mode: str) -> None:
281
281
  4. Handles container logs for detached mode
282
282
 
283
283
  The container name is generated using:
284
- - Username (from LOCAL_USER env var)
284
+ - Username (from LOCAL_USER or USER env var)
285
285
  - Timestamp (YYYYMMDD_HHMMSS format)
286
286
 
287
287
  Args:
@@ -299,7 +299,7 @@ def run_container(config: dict, image_uri: str, mode: str) -> None:
299
299
  )
300
300
 
301
301
  # Generate unique container name
302
- username = os.getenv("LOCAL_USER", "unknown_user")
302
+ username = os.getenv("LOCAL_USER") or os.getenv("USER", "unknown_user")
303
303
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
304
304
  container_name = f"{username}_job_{timestamp}"
305
305
 
File without changes
File without changes
File without changes
File without changes
@@ -128,23 +128,58 @@ def publish_cards(
128
128
  names: List[str],
129
129
  firestore_collection: str,
130
130
  ):
131
- """Publish cards to Firebase. Expects a list of filenames (not full paths),
132
- which will each be published as a new document in the collection."""
131
+ """Publish cards to Firebase using batch writes for optimal performance.
132
+
133
+ Expects a list of filenames (not full paths), which will each be published
134
+ as a new document in the collection. Uses Firestore batch writes to minimize
135
+ network round-trips and improve performance.
136
+
137
+ Args:
138
+ names: List of packet filenames to publish as cards
139
+ firestore_collection: Name of the Firestore collection to write to
140
+ """
141
+ if not names:
142
+ print("No cards to upload.")
143
+ return
133
144
 
134
145
  initialize_firebase()
135
- collection = firestore.client().collection(firestore_collection)
146
+ db = firestore.client()
147
+ collection = db.collection(firestore_collection)
148
+
149
+ # Firestore batch limit is 500 operations
150
+ BATCH_SIZE = 500
151
+ total_cards = len(names)
152
+ cards_processed = 0
153
+
154
+ # Process names in batches of up to 500
155
+ for i in range(0, total_cards, BATCH_SIZE):
156
+ batch = db.batch()
157
+ batch_names = names[i : i + BATCH_SIZE]
158
+
159
+ # Add all operations for this batch
160
+ for name in batch_names:
161
+ doc_ref = collection.document() # Auto-generate document ID
162
+ batch.set(
163
+ doc_ref,
164
+ {
165
+ "status": "available",
166
+ "packet_filename": name,
167
+ "created": datetime.now(ZoneInfo("America/Los_Angeles")),
168
+ },
169
+ )
136
170
 
137
- for name in names:
138
- collection.document().set(
139
- {
140
- "status": "available",
141
- "packet_filename": name,
142
- "created": datetime.now(ZoneInfo("America/Los_Angeles")),
143
- }
171
+ # Commit the entire batch atomically
172
+ batch.commit()
173
+ cards_processed += len(batch_names)
174
+
175
+ print(
176
+ f"Batch {i // BATCH_SIZE + 1}: Created {len(batch_names)} cards "
177
+ f"({cards_processed}/{total_cards} total)"
144
178
  )
145
- print(f"Creating card {name}")
146
179
 
147
- print(f"Uploaded {len(names)} cards.")
180
+ print(
181
+ f"Successfully uploaded {total_cards} cards in {(total_cards + BATCH_SIZE - 1) // BATCH_SIZE} batch(es)."
182
+ )
148
183
 
149
184
 
150
185
  @transactional
File without changes
dayhoff_tools/fasta.py CHANGED
File without changes
dayhoff_tools/file_ops.py CHANGED
File without changes
dayhoff_tools/h5.py CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
dayhoff_tools/logs.py CHANGED
File without changes
dayhoff_tools/sqlite.py CHANGED
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dayhoff-tools
3
- Version: 1.1.42
3
+ Version: 1.2.0
4
4
  Summary: Common tools for all the repos at Dayhoff Labs
5
5
  Author: Daniel Martin-Alarcon
6
6
  Author-email: dma@dayhofflabs.com
@@ -6,13 +6,13 @@ dayhoff_tools/cli/cloud_commands.py,sha256=NGux28-cjDyCADF-L1tjdEMzkCMYX8V4xNvpK
6
6
  dayhoff_tools/cli/main.py,sha256=47EGb28ALaYFc7oAUGlY1D66AIDmc4RZiXxN-gPVrpQ,4519
7
7
  dayhoff_tools/cli/swarm_commands.py,sha256=5EyKj8yietvT5lfoz8Zx0iQvVaNgc3SJX1z2zQR6o6M,5614
8
8
  dayhoff_tools/cli/utility_commands.py,sha256=ER4VrJt4hu904MwrcltUXjwBWT4uFrP-aPXjdXyT3F8,24685
9
- dayhoff_tools/deployment/base.py,sha256=8tXwsPYvRo-zV-aNhHw1c7Rji-KWg8S5xoCCznFnVVI,17412
9
+ dayhoff_tools/deployment/base.py,sha256=mYp560l6hSDFtyY2H42VoM8k9VUzfwuiyh9Knqpgc28,17441
10
10
  dayhoff_tools/deployment/deploy_aws.py,sha256=GvZpE2YIFA5Dl9rkAljFjtUypmPDNbWgw8NicHYTP24,18265
11
11
  dayhoff_tools/deployment/deploy_gcp.py,sha256=xgaOVsUDmP6wSEMYNkm1yRNcVskfdz80qJtCulkBIAM,8860
12
12
  dayhoff_tools/deployment/deploy_utils.py,sha256=StFwbqnr2_FWiKVg3xnJF4kagTHzndqqDkpaIOaAn_4,26027
13
13
  dayhoff_tools/deployment/job_runner.py,sha256=hljvFpH2Bw96uYyUup5Ths72PZRL_X27KxlYzBMgguo,5086
14
14
  dayhoff_tools/deployment/processors.py,sha256=LM0CQbr4XCb3AtLbrcuDQm4tYPXsoNqgVJ4WQYDjzJc,12406
15
- dayhoff_tools/deployment/swarm.py,sha256=MGcS2_x4RNFtnVjWlU_SwNfhICz8NlGYr9cYBK4ZKDA,21688
15
+ dayhoff_tools/deployment/swarm.py,sha256=YJfvVOcAS8cYcIj2fiN4qwC2leh0I9w5A4px8ZWSF6g,22833
16
16
  dayhoff_tools/embedders.py,sha256=fRkyWjHo8OmbNUBY_FwrgfvyiLqpmrpI57UAb1Szn1Y,36609
17
17
  dayhoff_tools/fasta.py,sha256=_kA2Cpiy7JAGbBqLrjElkzbcUD_p-nO2d5Aj1LVmOvc,50509
18
18
  dayhoff_tools/file_ops.py,sha256=JlGowvr-CUJFidV-4g_JmhUTN9bsYuaxtqKmnKomm-Q,8506
@@ -26,7 +26,7 @@ dayhoff_tools/intake/uniprot.py,sha256=BZYJQF63OtPcBBnQ7_P9gulxzJtqyorgyuDiPeOJq
26
26
  dayhoff_tools/logs.py,sha256=DKdeP0k0kliRcilwvX0mUB2eipO5BdWUeHwh-VnsICs,838
27
27
  dayhoff_tools/sqlite.py,sha256=jV55ikF8VpTfeQqqlHSbY8OgfyfHj8zgHNpZjBLos_E,18672
28
28
  dayhoff_tools/warehouse.py,sha256=TqV8nex1AluNaL4JuXH5zuu9P7qmE89lSo6f_oViy6U,14965
29
- dayhoff_tools-1.1.42.dist-info/METADATA,sha256=tXnXIVVY3rpyNqyzl8cfzciGdW8ajHlJPpdliTYMD0M,2843
30
- dayhoff_tools-1.1.42.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
31
- dayhoff_tools-1.1.42.dist-info/entry_points.txt,sha256=iAf4jteNqW3cJm6CO6czLxjW3vxYKsyGLZ8WGmxamSc,49
32
- dayhoff_tools-1.1.42.dist-info/RECORD,,
29
+ dayhoff_tools-1.2.0.dist-info/METADATA,sha256=X6kZf9yrTT0RrpDQCv2SrkRElXDocXcdhOGXhMTZO84,2842
30
+ dayhoff_tools-1.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
31
+ dayhoff_tools-1.2.0.dist-info/entry_points.txt,sha256=iAf4jteNqW3cJm6CO6czLxjW3vxYKsyGLZ8WGmxamSc,49
32
+ dayhoff_tools-1.2.0.dist-info/RECORD,,