dayhoff-tools 1.1.14__tar.gz → 1.1.15__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.1.14 → dayhoff_tools-1.1.15}/PKG-INFO +1 -1
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/cli/utility_commands.py +38 -61
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/pyproject.toml +1 -1
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/README.md +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/__init__.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/chemistry/standardizer.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/chemistry/utils.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/cli/__init__.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/cli/cloud_commands.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/cli/main.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/cli/swarm_commands.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/base.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/deploy_aws.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/deploy_gcp.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/deploy_utils.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/job_runner.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/processors.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/deployment/swarm.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/embedders.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/fasta.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/file_ops.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/h5.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/intake/gcp.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/intake/gtdb.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/intake/kegg.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/intake/mmseqs.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/intake/structure.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/intake/uniprot.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/logs.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/sqlite.py +0 -0
- {dayhoff_tools-1.1.14 → dayhoff_tools-1.1.15}/dayhoff_tools/warehouse.py +0 -0
@@ -6,7 +6,6 @@ import shutil
|
|
6
6
|
import subprocess
|
7
7
|
import sys
|
8
8
|
from pathlib import Path
|
9
|
-
from typing import Optional
|
10
9
|
|
11
10
|
import toml
|
12
11
|
import typer
|
@@ -15,6 +14,44 @@ import yaml
|
|
15
14
|
# Import cloud helper lazily inside functions to avoid heavy deps at module load
|
16
15
|
|
17
16
|
|
17
|
+
def _warn_if_gcp_default_sa(force_prompt: bool = False) -> None:
|
18
|
+
"""Warn the user when the active gcloud principal is the default VM service
|
19
|
+
account. See detailed docstring later in file (duplicate for early
|
20
|
+
availability)."""
|
21
|
+
|
22
|
+
from dayhoff_tools.cli import cloud_commands as _cc
|
23
|
+
|
24
|
+
try:
|
25
|
+
impersonation = _cc._get_current_gcp_impersonation()
|
26
|
+
user = _cc._get_current_gcp_user()
|
27
|
+
active = impersonation if impersonation != "None" else user
|
28
|
+
short = _cc._get_short_name(active)
|
29
|
+
except Exception:
|
30
|
+
return
|
31
|
+
|
32
|
+
if short != "default VM service account":
|
33
|
+
return
|
34
|
+
|
35
|
+
YELLOW = getattr(_cc, "YELLOW", "\033[0;33m")
|
36
|
+
BLUE = getattr(_cc, "BLUE", "\033[0;36m")
|
37
|
+
RED = getattr(_cc, "RED", "\033[0;31m")
|
38
|
+
NC = getattr(_cc, "NC", "\033[0m")
|
39
|
+
|
40
|
+
print(
|
41
|
+
f"{YELLOW}⚠ You are currently authenticated as the *default VM service account*.{NC}\n"
|
42
|
+
f"{YELLOW} This will block gsutil/DVC access to private buckets (e.g. warehouse).{NC}\n"
|
43
|
+
f"{YELLOW} Run {BLUE}dh gcp login{YELLOW} or {BLUE}dh gcp use-devcon{YELLOW} before retrying.{NC}",
|
44
|
+
file=sys.stderr,
|
45
|
+
)
|
46
|
+
|
47
|
+
if force_prompt and sys.stdin.isatty() and sys.stdout.isatty():
|
48
|
+
import questionary
|
49
|
+
|
50
|
+
if not questionary.confirm("Proceed anyway?", default=False).ask():
|
51
|
+
print(f"{RED}Aborted due to unsafe GCP credentials.{NC}", file=sys.stderr)
|
52
|
+
raise SystemExit(1)
|
53
|
+
|
54
|
+
|
18
55
|
def test_github_actions_locally():
|
19
56
|
"""Run the script test_pytest_in_github_actions_container.sh.sh."""
|
20
57
|
script_path = ".devcontainer/scripts/test_pytest_in_github_actions_container.sh"
|
@@ -571,63 +608,3 @@ def update_dependencies(
|
|
571
608
|
# ----------------------
|
572
609
|
# Cloud credential guard
|
573
610
|
# ----------------------
|
574
|
-
|
575
|
-
|
576
|
-
def _warn_if_gcp_default_sa(force_prompt: bool = False) -> None:
|
577
|
-
"""Warn the user when the active gcloud principal is the default VM service
|
578
|
-
account.
|
579
|
-
|
580
|
-
This situation prevents gsutil/DVC from accessing private buckets and is
|
581
|
-
almost never what we want when interacting with the warehouse. The
|
582
|
-
function prints a coloured warning and, when *force_prompt* is *True* and
|
583
|
-
the session is interactive, asks the user whether to continue or abort the
|
584
|
-
command.
|
585
|
-
|
586
|
-
Parameters
|
587
|
-
----------
|
588
|
-
force_prompt : bool, default False
|
589
|
-
When *True* and running in an interactive shell (stdin & stdout are
|
590
|
-
TTYs), display a yes/no prompt (via *questionary.confirm*) asking the
|
591
|
-
user whether to proceed. If the user declines, ``SystemExit(1)`` is
|
592
|
-
raised to stop the CLI command immediately. In non-interactive
|
593
|
-
contexts the function merely prints the warning without prompting.
|
594
|
-
"""
|
595
|
-
|
596
|
-
# Delay heavy import until the function is actually needed
|
597
|
-
from dayhoff_tools.cli import cloud_commands as _cc # local import to ease testing
|
598
|
-
|
599
|
-
try:
|
600
|
-
impersonation = _cc._get_current_gcp_impersonation()
|
601
|
-
user = _cc._get_current_gcp_user()
|
602
|
-
active = impersonation if impersonation != "None" else user
|
603
|
-
short_name = _cc._get_short_name(active)
|
604
|
-
except Exception:
|
605
|
-
# If gcloud is missing or some other unexpected error occurs, fail
|
606
|
-
# gracefully by doing nothing.
|
607
|
-
return
|
608
|
-
|
609
|
-
if short_name != "default VM service account":
|
610
|
-
# All good – nothing to warn about
|
611
|
-
return
|
612
|
-
|
613
|
-
# Colour constants – fall back to empty strings if not available
|
614
|
-
RED = getattr(_cc, "RED", "\033[0;31m")
|
615
|
-
YELLOW = getattr(_cc, "YELLOW", "\033[0;33m")
|
616
|
-
BLUE = getattr(_cc, "BLUE", "\033[0;36m")
|
617
|
-
NC = getattr(_cc, "NC", "\033[0m")
|
618
|
-
|
619
|
-
warning_msg = (
|
620
|
-
f"{YELLOW}⚠ You are currently authenticated as the *default VM service account*.{NC}\n"
|
621
|
-
f"{YELLOW} This will block gsutil/DVC access to private buckets (e.g. warehouse).{NC}\n"
|
622
|
-
f"{YELLOW} Run {BLUE}dh gcp login{YELLOW} or {BLUE}dh gcp use-devcon{YELLOW} before retrying.{NC}"
|
623
|
-
)
|
624
|
-
print(warning_msg, file=sys.stderr)
|
625
|
-
|
626
|
-
interactive = sys.stdin.isatty() and sys.stdout.isatty()
|
627
|
-
if force_prompt and interactive:
|
628
|
-
import questionary
|
629
|
-
|
630
|
-
proceed = questionary.confirm("Proceed anyway?", default=False).ask()
|
631
|
-
if not proceed:
|
632
|
-
print(f"{RED}Aborted due to unsafe GCP credentials.{NC}", file=sys.stderr)
|
633
|
-
raise SystemExit(1)
|
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
|
|
5
5
|
|
6
6
|
[project]
|
7
7
|
name = "dayhoff-tools"
|
8
|
-
version = "1.1.
|
8
|
+
version = "1.1.15"
|
9
9
|
description = "Common tools for all the repos at Dayhoff Labs"
|
10
10
|
authors = [
|
11
11
|
{name = "Daniel Martin-Alarcon", email = "dma@dayhofflabs.com"}
|
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
|
File without changes
|