Skip to content

Commit

Permalink
feat(ci): Make deploy script cleaner; use temp file, add logs (#2808)
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-parker committed Sep 16, 2024
1 parent 4de7567 commit cca00bb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import subprocess
import sys
import tempfile
import time
from pathlib import Path

Expand All @@ -14,6 +15,7 @@

try:
import yaml

except ImportError as e:
msg = (
f"pyyaml is not installed but required by ./deploy.py\n"
Expand All @@ -24,7 +26,6 @@

script_path = Path(__file__).resolve()
ROOT_DIR = script_path.parent
TEMP_DIR = ROOT_DIR / "temp"


CLUSTER_NAME = "testCluster"
Expand Down Expand Up @@ -247,18 +248,16 @@ def get_codespace_name():


def generate_configs(from_live=False):
TEMP_DIR.mkdir(parents=True, exist_ok=True)
temp_dir_path = Path(tempfile.mkdtemp())

# Delete all files in the temp directory
for file in TEMP_DIR.iterdir():
file.unlink()
print(f"Unprocessed config available in temp dir: {temp_dir_path}")

helm_chart = str(HELM_CHART_DIR)
codespace_name = get_codespace_name()

output_dir = ROOT_DIR / "website" / "tests" / "config"

backend_config_path = TEMP_DIR / "backend_config.json"
backend_config_path = temp_dir_path / "backend_config.json"
generate_config(
helm_chart,
"templates/loculus-backend-config.yaml",
Expand All @@ -267,7 +266,7 @@ def generate_configs(from_live=False):
from_live,
)

website_config_path = TEMP_DIR / "website_config.json"
website_config_path = temp_dir_path / "website_config.json"
generate_config(
helm_chart,
"templates/loculus-website-config.yaml",
Expand All @@ -276,7 +275,7 @@ def generate_configs(from_live=False):
from_live,
)

runtime_config_path = TEMP_DIR / "runtime_config.json"
runtime_config_path = temp_dir_path / "runtime_config.json"
generate_config(
helm_chart,
"templates/loculus-website-config.yaml",
Expand All @@ -285,9 +284,9 @@ def generate_configs(from_live=False):
from_live,
)

ingest_configmap_path = TEMP_DIR / "config.yaml"
ingest_configmap_path = temp_dir_path / "config.yaml"
ingest_template_path = "templates/ingest-config.yaml"
ingest_configout_path = TEMP_DIR / "ingest-config.yaml"
ingest_configout_path = temp_dir_path / "ingest-config.yaml"
generate_config(
helm_chart,
ingest_template_path,
Expand All @@ -297,9 +296,9 @@ def generate_configs(from_live=False):
ingest_configout_path,
)

prepro_configmap_path = TEMP_DIR / "preprocessing-config.yaml"
prepro_configmap_path = temp_dir_path / "preprocessing-config.yaml"
prepro_template_path = "templates/loculus-preprocessing-config.yaml"
prepro_configout_path = TEMP_DIR / "preprocessing-config.yaml"
prepro_configout_path = temp_dir_path / "preprocessing-config.yaml"
generate_config(
helm_chart,
prepro_template_path,
Expand All @@ -313,10 +312,11 @@ def generate_configs(from_live=False):
[
"python3",
"kubernetes/config-processor/config-processor.py",
TEMP_DIR,
temp_dir_path,
output_dir,
]
)
print(f"Config generation succeeded, processed config files available in {output_dir}")


def generate_config(
Expand Down

0 comments on commit cca00bb

Please sign in to comment.