-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_env.py
More file actions
42 lines (33 loc) · 1.24 KB
/
Copy pathdeploy_env.py
File metadata and controls
42 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Clone python-feature-pipeline into cited-content-env and install fastembed.
The F2 content job and the serving predictor both embed text, so both run on this
env. Run once (idempotent-ish: skips create if it already exists).
Run: python deploy_env.py
"""
from __future__ import annotations
from pathlib import Path
import hopsworks
ENV_NAME = "cited-content-env"
BASE = "python-feature-pipeline"
_here = Path(__file__).resolve()
_rel = str(_here).split("/hopsfs/", 1)[1].rsplit("/", 1)[0]
REQ = f"{_rel}/requirements-pipeline.txt"
def main() -> None:
proj = hopsworks.login()
ea = proj.get_environment_api()
try:
env = ea.get_environment(ENV_NAME)
except Exception:
env = None
if env is None:
print(f"creating {ENV_NAME} from {BASE} ...", flush=True)
env = ea.create_environment(ENV_NAME, base_environment_name=BASE, await_creation=True)
if env is None:
env = ea.get_environment(ENV_NAME)
print("created", flush=True)
else:
print(f"env {ENV_NAME} exists, reusing", flush=True)
print(f"installing {REQ} ...", flush=True)
env.install_requirements(REQ, await_installation=True)
print(f"env {ENV_NAME} ready", flush=True)
if __name__ == "__main__":
main()