dayhoff-tools 1.0.5__tar.gz → 1.0.7__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.
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/PKG-INFO +1 -1
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/cli/cloud_commands.py +92 -61
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/pyproject.toml +1 -1
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/README.md +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/__init__.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/chemistry/standardizer.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/chemistry/utils.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/cli/__init__.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/cli/main.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/cli/swarm_commands.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/cli/utility_commands.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/base.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/deploy_aws.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/deploy_gcp.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/deploy_utils.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/job_runner.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/processors.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/deployment/swarm.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/embedders.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/fasta.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/file_ops.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/gcp.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/h5.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/kegg.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/logs.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/mmseqs.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/sqlite.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/structure.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/uniprot.py +0 -0
- {dayhoff_tools-1.0.5 → dayhoff_tools-1.0.7}/dayhoff_tools/warehouse.py +0 -0
@@ -129,19 +129,25 @@ def _get_env_var(variable: str) -> Optional[str]:
|
|
129
129
|
|
130
130
|
# --- GCP Functions ---
|
131
131
|
def _is_gcp_user_authenticated() -> bool:
|
132
|
-
"""Check if
|
133
|
-
gcloud_path = _find_executable("gcloud")
|
134
|
-
cmd = [
|
135
|
-
gcloud_path,
|
136
|
-
"auth",
|
137
|
-
"list",
|
138
|
-
"--filter=status:ACTIVE",
|
139
|
-
"--format=value(account)",
|
140
|
-
]
|
141
|
-
_, stdout, _ = _run_command(cmd, capture=True, check=False)
|
132
|
+
"""Check if the current gcloud user authentication is valid and non-interactive.
|
142
133
|
|
143
|
-
|
144
|
-
|
134
|
+
Returns:
|
135
|
+
True if `gcloud auth print-access-token --quiet` succeeds (exit code 0),
|
136
|
+
False otherwise (indicating potential need for interactive login).
|
137
|
+
"""
|
138
|
+
try:
|
139
|
+
gcloud_path = _find_executable("gcloud")
|
140
|
+
# Attempt to get a token silently. If this fails, login is likely expired or needs interaction.
|
141
|
+
returncode, _, _ = _run_command(
|
142
|
+
[gcloud_path, "auth", "print-access-token", "--quiet"],
|
143
|
+
capture=True, # We don't need the token, just the exit code
|
144
|
+
check=False, # Don't raise on failure
|
145
|
+
suppress_output=True, # Hide any potential output/errors from this check
|
146
|
+
)
|
147
|
+
return returncode == 0
|
148
|
+
except FileNotFoundError:
|
149
|
+
# If gcloud isn't found, they are definitely not authenticated.
|
150
|
+
return False
|
145
151
|
|
146
152
|
|
147
153
|
def _get_current_gcp_user() -> str:
|
@@ -350,49 +356,62 @@ def gcp_use_devcon(
|
|
350
356
|
export: bool = typer.Option(
|
351
357
|
False, "--export", "-x", help="Print export commands for the current shell."
|
352
358
|
),
|
353
|
-
auth_first: bool = typer.Option(
|
354
|
-
False, "--auth", "-a", help="Authenticate user first if needed."
|
355
|
-
),
|
356
359
|
):
|
357
|
-
"""
|
360
|
+
"""Configure gcloud CLI to impersonate the devcon SA by setting RC file variables.
|
361
|
+
|
362
|
+
NOTE: This command DOES NOT automatically update Application Default Credentials (ADC).
|
363
|
+
After running this, or after sourcing the export commands, you may need to run:
|
364
|
+
'gcloud auth application-default login --impersonate-service-account=...' manually
|
365
|
+
if you need libraries (like DVC) to use these credentials.
|
366
|
+
|
367
|
+
Ensures the primary user login is valid first to allow potential impersonation.
|
368
|
+
"""
|
358
369
|
if not _is_gcp_user_authenticated():
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
file=sys.stderr,
|
369
|
-
)
|
370
|
-
sys.exit(1)
|
370
|
+
print(
|
371
|
+
f"{RED}Error: GCP user authentication is invalid or requires interactive login.{NC}",
|
372
|
+
file=sys.stderr,
|
373
|
+
)
|
374
|
+
print(
|
375
|
+
f"{YELLOW}Please run 'gcloud auth login' interactively first, then try this command again.{NC}",
|
376
|
+
file=sys.stderr,
|
377
|
+
)
|
378
|
+
sys.exit(1)
|
371
379
|
|
372
|
-
#
|
380
|
+
# Set gcloud CLI impersonation (persisted to RC files)
|
373
381
|
_modify_rc_files("CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT", f"'{GCP_DEVCON_SA}'")
|
374
382
|
_modify_rc_files("GOOGLE_CLOUD_PROJECT", f"'{GCP_PROJECT_ID}'")
|
375
383
|
|
376
384
|
if export:
|
377
|
-
# Print export commands for the current shell
|
385
|
+
# Print export commands for the current shell (for gcloud CLI)
|
378
386
|
print(f"export CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT='{GCP_DEVCON_SA}'")
|
379
387
|
print(f"export GOOGLE_CLOUD_PROJECT='{GCP_PROJECT_ID}'")
|
380
388
|
|
381
|
-
# Print confirmation
|
389
|
+
# Print confirmation and instructions for ADC to stderr
|
382
390
|
print(
|
383
|
-
f"{GREEN}GCP
|
391
|
+
f"{GREEN}GCP gcloud CLI impersonation for '{GCP_DEVCON_SA}' exported.{NC}",
|
384
392
|
file=sys.stderr,
|
385
393
|
)
|
386
|
-
print(f"{GREEN}You now have standard devcon permissions.{NC}", file=sys.stderr)
|
387
|
-
else:
|
388
|
-
# Just print confirmation
|
389
394
|
print(
|
390
|
-
f"{
|
395
|
+
f"{YELLOW}NOTE: ADC file not updated by export. To update ADC for libraries, run:{NC}",
|
396
|
+
file=sys.stderr,
|
391
397
|
)
|
392
398
|
print(
|
393
|
-
f"
|
399
|
+
f"{YELLOW} gcloud auth application-default login --impersonate-service-account={GCP_DEVCON_SA}{NC}",
|
400
|
+
file=sys.stderr,
|
394
401
|
)
|
402
|
+
else:
|
403
|
+
# Print confirmation
|
404
|
+
print(
|
405
|
+
f"{GREEN}RC files updated to use devcon SA for future gcloud CLI sessions.{NC}"
|
406
|
+
)
|
407
|
+
print(f"To apply gcloud CLI settings in current shell, run:")
|
395
408
|
print(f' {YELLOW}eval "$(dh gcp use-devcon --export)"{NC}')
|
409
|
+
print(
|
410
|
+
f"{YELLOW}NOTE: ADC file not updated. To update ADC for libraries, run:{NC}"
|
411
|
+
)
|
412
|
+
print(
|
413
|
+
f"{YELLOW} gcloud auth application-default login --impersonate-service-account={GCP_DEVCON_SA}{NC}"
|
414
|
+
)
|
396
415
|
|
397
416
|
|
398
417
|
@gcp_app.command("use-user")
|
@@ -400,48 +419,60 @@ def gcp_use_user(
|
|
400
419
|
export: bool = typer.Option(
|
401
420
|
False, "--export", "-x", help="Print export commands for the current shell."
|
402
421
|
),
|
403
|
-
auth_first: bool = typer.Option(
|
404
|
-
False, "--auth", "-a", help="Authenticate user first if needed."
|
405
|
-
),
|
406
422
|
):
|
407
|
-
"""
|
423
|
+
"""Configure gcloud CLI to use the personal user account by setting RC file variables.
|
424
|
+
|
425
|
+
NOTE: This command DOES NOT automatically update Application Default Credentials (ADC).
|
426
|
+
After running this, or after sourcing the export commands, you may need to run:
|
427
|
+
'gcloud auth application-default login' manually
|
428
|
+
if you need libraries (like DVC) to use your personal credentials.
|
429
|
+
|
430
|
+
Ensures the primary user login is valid first.
|
431
|
+
"""
|
408
432
|
if not _is_gcp_user_authenticated():
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
file=sys.stderr,
|
419
|
-
)
|
420
|
-
sys.exit(1)
|
433
|
+
print(
|
434
|
+
f"{RED}Error: GCP user authentication is invalid or requires interactive login.{NC}",
|
435
|
+
file=sys.stderr,
|
436
|
+
)
|
437
|
+
print(
|
438
|
+
f"{YELLOW}Please run 'gcloud auth login' interactively first, then try this command again.{NC}",
|
439
|
+
file=sys.stderr,
|
440
|
+
)
|
441
|
+
sys.exit(1)
|
421
442
|
|
422
|
-
#
|
443
|
+
# Unset gcloud CLI impersonation (persisted to RC files)
|
423
444
|
_modify_rc_files("CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT", None)
|
424
445
|
_modify_rc_files("GOOGLE_CLOUD_PROJECT", f"'{GCP_PROJECT_ID}'")
|
425
446
|
|
426
447
|
if export:
|
427
|
-
# Print export commands for the current shell
|
448
|
+
# Print export commands for the current shell (for gcloud CLI)
|
428
449
|
print(f"unset CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT")
|
429
450
|
print(f"export GOOGLE_CLOUD_PROJECT='{GCP_PROJECT_ID}'")
|
430
451
|
|
431
|
-
# Print confirmation
|
452
|
+
# Print confirmation and instructions for ADC to stderr
|
432
453
|
print(
|
433
|
-
f"{GREEN}
|
454
|
+
f"{GREEN}GCP gcloud CLI impersonation unset and exported.{NC}",
|
434
455
|
file=sys.stderr,
|
435
456
|
)
|
436
|
-
else:
|
437
|
-
# Just print confirmation
|
438
457
|
print(
|
439
|
-
f"{
|
458
|
+
f"{YELLOW}NOTE: ADC file not updated by export. To update ADC for libraries, run:{NC}",
|
459
|
+
file=sys.stderr,
|
440
460
|
)
|
441
461
|
print(
|
442
|
-
f"
|
462
|
+
f"{YELLOW} gcloud auth application-default login{NC}",
|
463
|
+
file=sys.stderr,
|
443
464
|
)
|
465
|
+
else:
|
466
|
+
# Print confirmation
|
467
|
+
print(
|
468
|
+
f"{GREEN}RC files updated to use personal account for future gcloud CLI sessions.{NC}"
|
469
|
+
)
|
470
|
+
print(f"To apply gcloud CLI settings in current shell, run:")
|
444
471
|
print(f' {YELLOW}eval "$(dh gcp use-user --export)"{NC}')
|
472
|
+
print(
|
473
|
+
f"{YELLOW}NOTE: ADC file not updated. To update ADC for libraries, run:{NC}"
|
474
|
+
)
|
475
|
+
print(f"{YELLOW} gcloud auth application-default login{NC}")
|
445
476
|
|
446
477
|
|
447
478
|
# --- AWS Commands ---
|
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
|
File without changes
|