Skip to content

Commit

Permalink
logic for fre pp install to compare configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Blanton authored and Chris Blanton committed Nov 26, 2024
1 parent 35ae479 commit de6c8c7
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions fre/pp/install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
''' fre pp install '''

from pathlib import Path
import os
import subprocess
import click

Expand All @@ -13,8 +15,26 @@ def _install_subtool(experiment, platform, target):
"""

name = experiment + '__' + platform + '__' + target
cmd = f"cylc install --no-run-name {name}"
subprocess.run(cmd, shell=True, check=True)
# if the cylc-run directory already exists,
# then check whether the cylc expanded definition (cylc config)
# is identical. If the same, good. If not, bad.
source_dir = Path(os.path.expanduser("~/cylc-src"), name)
install_dir = Path(os.path.expanduser("~/cylc-run"), name)
if os.path.isdir(install_dir):
installed_def = subprocess.run(["cylc", "config", name],capture_output=True).stdout
go_back_here = os.getcwd()
os.chdir(source_dir)
source_def = subprocess.run(['cylc', 'config', '.'], capture_output=True).stdout
if installed_def == source_def:
print(f"NOTE: Workflow '{install_dir}' already installed, and the definition is unchanged")
else:
print(f"ERROR: Workflow '{install_dir}' already installed, and the definition has changed!")
print(f"ERROR: Please manually remove or archive your workflow run directory '{install_dir}' and then run again")
raise Exception
else:
print(f"NOTE: About to install workflow into ~/cylc-run/{name}")
cmd = f"cylc install --no-run-name {name}"
subprocess.run(cmd, shell=True, check=True)

@click.command()
def install_subtool(experiment, platform, target):
Expand Down

0 comments on commit de6c8c7

Please sign in to comment.