Spaces:
Running
Running
Get forwarded environment variables lazily.
Browse files
lynxkite-bio/src/lynxkite_bio/k8s.py
CHANGED
@@ -19,7 +19,7 @@ Use `k8s.needs()` to declare a Kubernetes dependency for an operation. For examp
|
|
19 |
port=8000,
|
20 |
args=["--model", "google/gemma-3-1b-it"],
|
21 |
health_probe="/health",
|
22 |
-
|
23 |
storage_path="/root/.cache/huggingface",
|
24 |
storage_size="10Gi",
|
25 |
)
|
@@ -49,6 +49,7 @@ def _run(
|
|
49 |
storage_size,
|
50 |
storage_path,
|
51 |
health_probe,
|
|
|
52 |
**kwargs,
|
53 |
):
|
54 |
print(f"Starting {name} in namespace {namespace}...")
|
@@ -72,6 +73,10 @@ def _run(
|
|
72 |
),
|
73 |
)
|
74 |
)
|
|
|
|
|
|
|
|
|
75 |
container = client.V1Container(
|
76 |
name=name,
|
77 |
image=image,
|
@@ -192,17 +197,13 @@ def _pvc_exists(name: str, namespace: str = "default") -> bool:
|
|
192 |
raise
|
193 |
|
194 |
|
195 |
-
def env_vars(*names: str):
|
196 |
-
"""A convenient way to pass local environment variables to the microservice."""
|
197 |
-
return [{"name": name, "value": os.environ[name]} for name in names]
|
198 |
-
|
199 |
-
|
200 |
def needs(
|
201 |
name: str,
|
202 |
image: str,
|
203 |
port: int,
|
204 |
args: list = None,
|
205 |
env: list = None,
|
|
|
206 |
health_probe: str = None,
|
207 |
storage_size: str = None,
|
208 |
storage_path: str = "/data",
|
@@ -222,6 +223,7 @@ def needs(
|
|
222 |
port=port,
|
223 |
args=args or [],
|
224 |
env=env or [],
|
|
|
225 |
health_probe=health_probe,
|
226 |
storage_size=storage_size,
|
227 |
storage_path=storage_path,
|
|
|
19 |
port=8000,
|
20 |
args=["--model", "google/gemma-3-1b-it"],
|
21 |
health_probe="/health",
|
22 |
+
forward_env=["HUGGING_FACE_HUB_TOKEN"],
|
23 |
storage_path="/root/.cache/huggingface",
|
24 |
storage_size="10Gi",
|
25 |
)
|
|
|
49 |
storage_size,
|
50 |
storage_path,
|
51 |
health_probe,
|
52 |
+
forward_env,
|
53 |
**kwargs,
|
54 |
):
|
55 |
print(f"Starting {name} in namespace {namespace}...")
|
|
|
73 |
),
|
74 |
)
|
75 |
)
|
76 |
+
# Forward local environment variables to the container.
|
77 |
+
kwargs.setdefault("env", []).extend(
|
78 |
+
[{"name": name, "value": os.environ[name]} for name in forward_env]
|
79 |
+
)
|
80 |
container = client.V1Container(
|
81 |
name=name,
|
82 |
image=image,
|
|
|
197 |
raise
|
198 |
|
199 |
|
|
|
|
|
|
|
|
|
|
|
200 |
def needs(
|
201 |
name: str,
|
202 |
image: str,
|
203 |
port: int,
|
204 |
args: list = None,
|
205 |
env: list = None,
|
206 |
+
forward_env: list = None,
|
207 |
health_probe: str = None,
|
208 |
storage_size: str = None,
|
209 |
storage_path: str = "/data",
|
|
|
223 |
port=port,
|
224 |
args=args or [],
|
225 |
env=env or [],
|
226 |
+
forward_env=forward_env or [],
|
227 |
health_probe=health_probe,
|
228 |
storage_size=storage_size,
|
229 |
storage_path=storage_path,
|
lynxkite-bio/src/lynxkite_bio/llm.py
CHANGED
@@ -22,7 +22,7 @@ op = ops.op_registration(ENV)
|
|
22 |
port=8000,
|
23 |
args=["--model", "google/gemma-3-1b-it"],
|
24 |
health_probe="/health",
|
25 |
-
|
26 |
storage_path="/root/.cache/huggingface",
|
27 |
storage_size="10Gi",
|
28 |
)
|
|
|
22 |
port=8000,
|
23 |
args=["--model", "google/gemma-3-1b-it"],
|
24 |
health_probe="/health",
|
25 |
+
forward_env=["HUGGING_FACE_HUB_TOKEN"],
|
26 |
storage_path="/root/.cache/huggingface",
|
27 |
storage_size="10Gi",
|
28 |
)
|