Skip to content

Commit

Permalink
feat(deploy.py): Allow reconfiguring the live host pointed to (#2641)
Browse files Browse the repository at this point in the history
* Allow reconfiguring the live host pointed to

* Update deploy.py

* fixup

* update

* update
  • Loading branch information
theosanderson committed Sep 19, 2024
1 parent 61b8fde commit adf168d
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
help="Generate config files to point to the live cluster so we don`t need to run the cluster locally, only the website",
)

config_parser.add_argument(
"--live-host",
default="main.loculus.org",
help="The live server that should be pointed to, if --from-live is set",
)



args = parser.parse_args()


Expand All @@ -128,7 +136,7 @@ def main():
elif args.subcommand == "upgrade":
handle_helm_upgrade()
elif args.subcommand == "config":
generate_configs(args.from_live)
generate_configs(args.from_live, args.live_host)


def handle_cluster():
Expand Down Expand Up @@ -247,9 +255,10 @@ def get_codespace_name():
return os.environ.get("CODESPACE_NAME", None)


def generate_configs(from_live=False):
def generate_configs(from_live, live_host):
temp_dir_path = Path(tempfile.mkdtemp())


print(f"Unprocessed config available in temp dir: {temp_dir_path}")

helm_chart = str(HELM_CHART_DIR)
Expand All @@ -264,6 +273,7 @@ def generate_configs(from_live=False):
backend_config_path,
codespace_name,
from_live,
live_host
)

website_config_path = temp_dir_path / "website_config.json"
Expand All @@ -273,6 +283,7 @@ def generate_configs(from_live=False):
website_config_path,
codespace_name,
from_live,
live_host
)

runtime_config_path = temp_dir_path / "runtime_config.json"
Expand All @@ -282,6 +293,7 @@ def generate_configs(from_live=False):
runtime_config_path,
codespace_name,
from_live,
live_host
)

ingest_configmap_path = temp_dir_path / "config.yaml"
Expand All @@ -293,7 +305,8 @@ def generate_configs(from_live=False):
ingest_configmap_path,
codespace_name,
from_live,
ingest_configout_path,
live_host,
ingest_configout_path
)

prepro_configmap_path = temp_dir_path / "preprocessing-config.yaml"
Expand All @@ -305,7 +318,8 @@ def generate_configs(from_live=False):
prepro_configmap_path,
codespace_name,
from_live,
prepro_configout_path,
live_host,
prepro_configout_path
)

run_command(
Expand All @@ -325,8 +339,14 @@ def generate_config(
configmap_path,
codespace_name=None,
from_live=False,
live_host=None,
output_path=None,
):
if from_live and live_host:
number_of_dots = live_host.count(".")
if number_of_dots <= 2: # this is an imperfect hack
raise ValueError("Currently only subdomains are supported as live-hosts")
# To be able to cope with top level domains we need more logic to use the right subdomain separator - but we should probably avoid this anyway as we shouldn't use production domains
helm_template_cmd = [
"helm",
"template",
Expand All @@ -346,7 +366,7 @@ def generate_config(
helm_template_cmd.extend(["--set", "disableBackend=true"])
if from_live:
helm_template_cmd.extend(["--set", "environment=server"])
helm_template_cmd.extend(["--set", "host=main.loculus.org"])
helm_template_cmd.extend(["--set", f"host={live_host}"])
helm_template_cmd.extend(["--set", "usePublicRuntimeConfigAsServerSide=true"])
else:
helm_template_cmd.extend(["--set", "environment=local"])
Expand Down

0 comments on commit adf168d

Please sign in to comment.