Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lfric_macros/apply_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@ def apply_macros_main(
apps: Path = Path(".").absolute(),
core: str | None = None,
jules: str | None = None,
nproc: int = 4,
) -> None:
"""
Main function for this program
Expand All @@ -1299,10 +1300,10 @@ def apply_macros_main(

# Pre-process macros
banner_print("Pre-Processing Macros")
macro_object.preprocess_macros(args.processes)
macro_object.preprocess_macros(nproc)

# Upgrade Rose Stem Apps
macro_object.upgrade_apps(args.processes)
macro_object.upgrade_apps(nproc)

# Clean up temporary directories
for repo, directory in macro_object.temp_dirs.items():
Expand All @@ -1325,5 +1326,11 @@ def apply_macros_main(
if __name__ == "__main__":
args = parse_args()
apply_macros_main(
args.tag, args.cname, args.version, args.apps, args.core, args.jules
args.tag,
args.cname,
args.version,
args.apps,
args.core,
args.jules,
args.processes,
)
38 changes: 4 additions & 34 deletions lfric_macros/release_lfric.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import argparse
import getpass
import re
import socket
import subprocess
import shutil
import shlex
Expand Down Expand Up @@ -77,35 +76,6 @@ def raise_exception(result: subprocess.CompletedProcess, command: str) -> None:
raise Exception(f"[FAIL] Error running command: '{command}'\n{result.stderr}")


def set_dependency_path(apps: Path, core: Path) -> None:
"""
Edit an LFRic Apps dependencies.sh file so that it points at the provided
LFRic Core source
"""

print("[INFO] Updating dependencies.yaml Core source")

hostname = socket.gethostname()
dep_path = apps / "dependencies.yaml"
with open(dep_path) as f:
lines = f.readlines()
in_core = False
for i, line in enumerate(lines):
if line.strip().startswith("lfric_core"):
in_core = True
elif in_core and "source:" in line:
prefix, _, _ = line.partition("source:")
line = f"{prefix}source: {hostname}:{core}\n"
elif in_core and "ref:" in line:
prefix, _, _ = line.partition("ref:")
line = f"{prefix}ref:"
elif in_core:
break
lines[i] = line
with open(dep_path, "w") as f:
f.write("".join(x for x in lines))


def find_meta_dirs(paths: list[Path], exclude_dirs: tuple[str] = ()) -> set[Path]:
"""
Return a set of rose-metadata directories that can be found in the apps and
Expand Down Expand Up @@ -232,11 +202,9 @@ def copy_head_meta(meta_dirs: list[Path], apps: Path, core: Path, version: str)
shutil.copytree(head, new)
if core in new.parents:
new = new.relative_to(core)
print(new)
command = f"git -C {core} add {new}"
elif apps in new.parents:
new = new.relative_to(apps)
print(new)
command = f"git -C {apps} add {new}"
_ = run_command(command)

Expand Down Expand Up @@ -446,6 +414,9 @@ def parse_args() -> argparse.Namespace:
type=Path,
help="Path to the LFRic Core working copy being used.",
)
parser.add_argument(
"-p", "--processes", type=int, default=4, help="Number of processes to use"
)
args = parser.parse_args()

args.apps = get_root_path(args.apps)
Expand All @@ -468,8 +439,6 @@ def main() -> None:
args.core,
)

set_dependency_path(args.apps, args.core)

# Find all metadata directories, excluing lfric-inputs as this has metadata but no
# macros.
exclude_dirs = (
Expand All @@ -495,6 +464,7 @@ def main() -> None:
args.old_version,
args.apps,
args.core,
nproc=args.processes,
)
print("\n[INFO] Successfully upgraded apps")

Expand Down
Loading