Skip to content

Commit daf992c

Browse files
Changes for release (#245)
1 parent fe34e3e commit daf992c

2 files changed

Lines changed: 14 additions & 37 deletions

File tree

lfric_macros/apply_macros.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ def apply_macros_main(
12921292
apps: Path = Path(".").absolute(),
12931293
core: str | None = None,
12941294
jules: str | None = None,
1295+
nproc: int = 4,
12951296
) -> None:
12961297
"""
12971298
Main function for this program
@@ -1303,10 +1304,10 @@ def apply_macros_main(
13031304

13041305
# Pre-process macros
13051306
banner_print("Pre-Processing Macros")
1306-
macro_object.preprocess_macros(args.processes)
1307+
macro_object.preprocess_macros(nproc)
13071308

13081309
# Upgrade Rose Stem Apps
1309-
macro_object.upgrade_apps(args.processes)
1310+
macro_object.upgrade_apps(nproc)
13101311

13111312
# Clean up temporary directories
13121313
for repo, directory in macro_object.temp_dirs.items():
@@ -1329,5 +1330,11 @@ def apply_macros_main(
13291330
if __name__ == "__main__":
13301331
args = parse_args()
13311332
apply_macros_main(
1332-
args.tag, args.cname, args.version, args.apps, args.core, args.jules
1333+
args.tag,
1334+
args.cname,
1335+
args.version,
1336+
args.apps,
1337+
args.core,
1338+
args.jules,
1339+
args.processes,
13331340
)

lfric_macros/release_lfric.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import argparse
2020
import getpass
2121
import re
22-
import socket
2322
import subprocess
2423
import shutil
2524
import shlex
@@ -77,35 +76,6 @@ def raise_exception(result: subprocess.CompletedProcess, command: str) -> None:
7776
raise Exception(f"[FAIL] Error running command: '{command}'\n{result.stderr}")
7877

7978

80-
def set_dependency_path(apps: Path, core: Path) -> None:
81-
"""
82-
Edit an LFRic Apps dependencies.sh file so that it points at the provided
83-
LFRic Core source
84-
"""
85-
86-
print("[INFO] Updating dependencies.yaml Core source")
87-
88-
hostname = socket.gethostname()
89-
dep_path = apps / "dependencies.yaml"
90-
with open(dep_path) as f:
91-
lines = f.readlines()
92-
in_core = False
93-
for i, line in enumerate(lines):
94-
if line.strip().startswith("lfric_core"):
95-
in_core = True
96-
elif in_core and "source:" in line:
97-
prefix, _, _ = line.partition("source:")
98-
line = f"{prefix}source: {hostname}:{core}\n"
99-
elif in_core and "ref:" in line:
100-
prefix, _, _ = line.partition("ref:")
101-
line = f"{prefix}ref:"
102-
elif in_core:
103-
break
104-
lines[i] = line
105-
with open(dep_path, "w") as f:
106-
f.write("".join(x for x in lines))
107-
108-
10979
def find_meta_dirs(paths: list[Path], exclude_dirs: tuple[str] = ()) -> set[Path]:
11080
"""
11181
Return a set of rose-metadata directories that can be found in the apps and
@@ -232,11 +202,9 @@ def copy_head_meta(meta_dirs: list[Path], apps: Path, core: Path, version: str)
232202
shutil.copytree(head, new)
233203
if core in new.parents:
234204
new = new.relative_to(core)
235-
print(new)
236205
command = f"git -C {core} add {new}"
237206
elif apps in new.parents:
238207
new = new.relative_to(apps)
239-
print(new)
240208
command = f"git -C {apps} add {new}"
241209
_ = run_command(command)
242210

@@ -446,6 +414,9 @@ def parse_args() -> argparse.Namespace:
446414
type=Path,
447415
help="Path to the LFRic Core working copy being used.",
448416
)
417+
parser.add_argument(
418+
"-p", "--processes", type=int, default=4, help="Number of processes to use"
419+
)
449420
args = parser.parse_args()
450421

451422
args.apps = get_root_path(args.apps)
@@ -468,8 +439,6 @@ def main() -> None:
468439
args.core,
469440
)
470441

471-
set_dependency_path(args.apps, args.core)
472-
473442
# Find all metadata directories, excluing lfric-inputs as this has metadata but no
474443
# macros.
475444
exclude_dirs = (
@@ -495,6 +464,7 @@ def main() -> None:
495464
args.old_version,
496465
args.apps,
497466
args.core,
467+
nproc=args.processes,
498468
)
499469
print("\n[INFO] Successfully upgraded apps")
500470

0 commit comments

Comments
 (0)