dayhoff-tools 1.2.2__py3-none-any.whl → 1.2.4__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.
@@ -126,12 +126,32 @@ def import_from_warehouse_typer() -> None:
126
126
  import questionary
127
127
  from dayhoff_tools.warehouse import import_from_warehouse
128
128
 
129
- # Ensure execution from root
130
- cwd = Path(os.getcwd())
131
- if cwd.parent.name != "workspaces" or str(cwd.parent.parent) != cwd.root:
132
- raise Exception(
133
- f"This command must be executed from the repo's root directory (/workspaces/reponame). Current directory: {cwd}"
134
- )
129
+ # Check if we're in Lightning Studio
130
+ if _is_lightning_studio():
131
+ # Lightning Studio behavior
132
+ _check_dvc_initialized()
133
+ _configure_studio_cache()
134
+
135
+ # Ensure we're running from repo root using REPO_ROOT env var
136
+ repo_root = os.environ.get("REPO_ROOT")
137
+ if not repo_root:
138
+ raise Exception(
139
+ "REPO_ROOT environment variable not set. Make sure you're in a repo with an active UV virtual environment."
140
+ )
141
+
142
+ current_dir = os.getcwd()
143
+ if current_dir != repo_root:
144
+ raise Exception(
145
+ f"This command must be run from the repo root. "
146
+ f"Current directory: {current_dir}, Expected: {repo_root}"
147
+ )
148
+ else:
149
+ # Original devcontainer behavior - ensure execution from root
150
+ cwd = Path(os.getcwd())
151
+ if cwd.parent.name != "workspaces" or str(cwd.parent.parent) != cwd.root:
152
+ raise Exception(
153
+ f"This command must be executed from the repo's root directory (/workspaces/reponame). Current directory: {cwd}"
154
+ )
135
155
 
136
156
  # Use questionary for prompts instead of typer
137
157
  warehouse_path = questionary.text("Warehouse path:").ask()
@@ -172,12 +192,32 @@ def add_to_warehouse_typer() -> None:
172
192
  import questionary
173
193
  from dayhoff_tools.warehouse import add_to_warehouse
174
194
 
175
- # Ensure execution from root
176
- cwd = Path(os.getcwd())
177
- if cwd.parent.name != "workspaces" or str(cwd.parent.parent) != cwd.root:
178
- raise Exception(
179
- f"This command must be executed from the repo's root directory (/workspaces/reponame). Current directory: {cwd}"
180
- )
195
+ # Check if we're in Lightning Studio
196
+ if _is_lightning_studio():
197
+ # Lightning Studio behavior
198
+ _check_dvc_initialized()
199
+ _configure_studio_cache()
200
+
201
+ # Ensure we're running from repo root using REPO_ROOT env var
202
+ repo_root = os.environ.get("REPO_ROOT")
203
+ if not repo_root:
204
+ raise Exception(
205
+ "REPO_ROOT environment variable not set. Make sure you're in a repo with an active UV virtual environment."
206
+ )
207
+
208
+ current_dir = os.getcwd()
209
+ if current_dir != repo_root:
210
+ raise Exception(
211
+ f"This command must be run from the repo root. "
212
+ f"Current directory: {current_dir}, Expected: {repo_root}"
213
+ )
214
+ else:
215
+ # Original devcontainer behavior - ensure execution from root
216
+ cwd = Path(os.getcwd())
217
+ if cwd.parent.name != "workspaces" or str(cwd.parent.parent) != cwd.root:
218
+ raise Exception(
219
+ f"This command must be executed from the repo's root directory (/workspaces/reponame). Current directory: {cwd}"
220
+ )
181
221
 
182
222
  # Prompt for the data file path
183
223
  warehouse_path = questionary.text("Data file to be registered:").ask()
@@ -647,5 +687,46 @@ def update_dependencies(
647
687
 
648
688
 
649
689
  # ----------------------
650
- # Cloud credential guard
690
+ # Lightning Studio Commands
651
691
  # ----------------------
692
+
693
+
694
+ def _is_lightning_studio() -> bool:
695
+ """Check if we're running in Lightning Studio environment."""
696
+ return os.path.exists("/teamspace/studios/this_studio")
697
+
698
+
699
+ def _check_dvc_initialized() -> None:
700
+ """Check if DVC is initialized in the current directory."""
701
+ if not os.path.exists(".dvc"):
702
+ raise Exception(
703
+ "DVC is not initialized in this repository. Run 'dvc init' first."
704
+ )
705
+
706
+
707
+ def _configure_studio_cache() -> None:
708
+ """Configure DVC to use studio-level cache if not already configured."""
709
+ studio_cache_dir = "/teamspace/studios/this_studio/.dvc_cache"
710
+
711
+ # Create cache directory if it doesn't exist
712
+ os.makedirs(studio_cache_dir, exist_ok=True)
713
+
714
+ # Check current cache configuration
715
+ try:
716
+ result = subprocess.run(
717
+ ["dvc", "cache", "dir"], capture_output=True, text=True, check=True
718
+ )
719
+ current_cache = result.stdout.strip()
720
+
721
+ if current_cache != studio_cache_dir:
722
+ print(
723
+ f"Configuring DVC cache to use studio-level directory: {studio_cache_dir}"
724
+ )
725
+ # Use --local flag to save in .dvc/config.local (git-ignored)
726
+ subprocess.run(
727
+ ["dvc", "cache", "dir", studio_cache_dir, "--local"], check=True
728
+ )
729
+ print("✅ DVC cache configured for Lightning Studio (in .dvc/config.local)")
730
+ except subprocess.CalledProcessError:
731
+ # If cache dir command fails, try to set it anyway
732
+ subprocess.run(["dvc", "cache", "dir", studio_cache_dir, "--local"], check=True)
File without changes
@@ -282,6 +282,27 @@ def add_to_warehouse(
282
282
  # Change the working directory to the warehouse folder
283
283
  os.chdir("warehouse")
284
284
 
285
+ # Configure DVC cache for Lightning Studio if needed
286
+ if os.path.exists("/teamspace/studios/this_studio"):
287
+ studio_cache_dir = "/teamspace/studios/this_studio/.dvc_cache"
288
+ os.makedirs(studio_cache_dir, exist_ok=True)
289
+ try:
290
+ result = subprocess.run(
291
+ ["dvc", "cache", "dir"], capture_output=True, text=True, check=True
292
+ )
293
+ current_cache = result.stdout.strip()
294
+ if current_cache != studio_cache_dir:
295
+ subprocess.run(
296
+ ["dvc", "cache", "dir", studio_cache_dir, "--local"], check=True
297
+ )
298
+ print(
299
+ f"✅ Configured warehouse DVC cache for Lightning Studio: {studio_cache_dir}"
300
+ )
301
+ except subprocess.CalledProcessError:
302
+ subprocess.run(
303
+ ["dvc", "cache", "dir", studio_cache_dir, "--local"], check=True
304
+ )
305
+
285
306
  # Add and push the data file
286
307
  subprocess.run(["dvc", "add", warehouse_path], check=True)
287
308
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dayhoff-tools
3
- Version: 1.2.2
3
+ Version: 1.2.4
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
@@ -5,7 +5,7 @@ dayhoff_tools/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
5
5
  dayhoff_tools/cli/cloud_commands.py,sha256=33qcWLmq-FwEXMdL3F0OHm-5Stlh2r65CldyEZgQ1no,40904
6
6
  dayhoff_tools/cli/main.py,sha256=47EGb28ALaYFc7oAUGlY1D66AIDmc4RZiXxN-gPVrpQ,4519
7
7
  dayhoff_tools/cli/swarm_commands.py,sha256=5EyKj8yietvT5lfoz8Zx0iQvVaNgc3SJX1z2zQR6o6M,5614
8
- dayhoff_tools/cli/utility_commands.py,sha256=ER4VrJt4hu904MwrcltUXjwBWT4uFrP-aPXjdXyT3F8,24685
8
+ dayhoff_tools/cli/utility_commands.py,sha256=qs8vH9TBFHsOPC3X8cU3qZigM3dDn-2Ytq4o_F2WubU,27874
9
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
@@ -25,8 +25,8 @@ dayhoff_tools/intake/structure.py,sha256=ufN3gAodQxhnt7psK1VTQeu9rKERmo_PhoxIbB4
25
25
  dayhoff_tools/intake/uniprot.py,sha256=BZYJQF63OtPcBBnQ7_P9gulxzJtqyorgyuDiPeOJqE4,16456
26
26
  dayhoff_tools/logs.py,sha256=DKdeP0k0kliRcilwvX0mUB2eipO5BdWUeHwh-VnsICs,838
27
27
  dayhoff_tools/sqlite.py,sha256=jV55ikF8VpTfeQqqlHSbY8OgfyfHj8zgHNpZjBLos_E,18672
28
- dayhoff_tools/warehouse.py,sha256=TqV8nex1AluNaL4JuXH5zuu9P7qmE89lSo6f_oViy6U,14965
29
- dayhoff_tools-1.2.2.dist-info/METADATA,sha256=Nzm5NUYAl70l03hfAh446pXIxcFAW8epMWVJq3qrEtQ,2842
30
- dayhoff_tools-1.2.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
31
- dayhoff_tools-1.2.2.dist-info/entry_points.txt,sha256=iAf4jteNqW3cJm6CO6czLxjW3vxYKsyGLZ8WGmxamSc,49
32
- dayhoff_tools-1.2.2.dist-info/RECORD,,
28
+ dayhoff_tools/warehouse.py,sha256=8YbnQ--usrEgDQGfvpV4MrMji55A0rq2hZaOgFGh6ag,15896
29
+ dayhoff_tools-1.2.4.dist-info/METADATA,sha256=WhzGyg_sOZXiu0DpDuLCHDzjnDb2ltPpKWws8Sp1guM,2842
30
+ dayhoff_tools-1.2.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
31
+ dayhoff_tools-1.2.4.dist-info/entry_points.txt,sha256=iAf4jteNqW3cJm6CO6czLxjW3vxYKsyGLZ8WGmxamSc,49
32
+ dayhoff_tools-1.2.4.dist-info/RECORD,,