From c0f8dab4258d763a05870d93f55d87860bd5d84a Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:49:07 +0100 Subject: [PATCH 1/6] add jules source to apply_macros --- lfric_macros/apply_macros.py | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lfric_macros/apply_macros.py b/lfric_macros/apply_macros.py index d2af98ec..c891e155 100755 --- a/lfric_macros/apply_macros.py +++ b/lfric_macros/apply_macros.py @@ -251,6 +251,7 @@ def __init__( version: str, apps: Path, core: Path, + jules: Path, testing: bool = False, ) -> None: self.tag: str = tag @@ -266,7 +267,8 @@ def __init__( self.root_path: Path = apps else: self.root_path: Path = get_root_path(apps) - self.core_source: Path = self.get_dependency_paths(core) + self.core_source: Path = self.get_dependency_paths(core, "lfric_core") + self.jules_source: Path = self.get_dependency_paths(jules, "jules") self.set_rose_meta_path() if version is None: self.version: str = re.search(r".*vn(\d+\.\d+)(_.*)?", tag).group(1) @@ -285,13 +287,15 @@ def __init__( def set_rose_meta_path(self) -> None: """ - Set up the ROSE_META_PATH environment variable in order to use the Core - metadata. We also add the clone root path as this should allow the script to be - run from anywhere. + Set up the ROSE_META_PATH environment variable in order to use the Core and + Jules metadata. We also add the clone root path as this should allow the script + to be run from anywhere. Edit 02/2026 - remove backwards compatibility support for pre central-metadata """ rose_meta_path: str = ( - f"{self.root_path / 'rose-meta'}:{self.core_source / 'rose-meta'}" + f"{self.root_path / 'rose-meta'}:" + f"{self.core_source / 'rose-meta'}:" + f"{self.jules_source / 'rose-meta'}" ) os.environ["ROSE_META_PATH"] = rose_meta_path @@ -320,7 +324,7 @@ def parse_application_section(self, meta_dir: Path) -> Path: # Get Working Copy Functions ############################################################################ - def get_dependency_paths(self, source: str | None) -> Path: + def get_dependency_paths(self, source: str | None, repo: str) -> Path: """ Parse the core command line arguments to get the path to a git clone. If the source isn't defined, first populate the source by reading the @@ -333,11 +337,9 @@ def get_dependency_paths(self, source: str | None) -> Path: - The path to the source working copy to use """ - repo = "lfric_core" - # If source is None then read the dependencies.yaml file for the source if source is None: - source, ref = self.read_dependencies() + source, ref = self.read_dependencies(repo) if ":" in str(source): source_path = Path(source.split(":")[1]).expanduser() else: @@ -360,7 +362,7 @@ def get_dependency_paths(self, source: str | None) -> Path: source = self.git_clone_temp(source, ref, repo) return source - def read_dependencies(self, repo: str = "lfric_core") -> tuple[str, str]: + def read_dependencies(self, repo: str) -> tuple[str, str]: """ Read through the dependencies.yaml file for the source of the repo defined by repo. Uses self.root_path to locate the dependencies.yaml file. @@ -1220,7 +1222,15 @@ def parse_args() -> argparse.Namespace: "--core", default=None, help="The LFRic Core source being used." - "Either a path to a working copy or a git source." + "Either a path to a local clone or a github source." + "If not set, will be read from the dependencies.yaml", + ) + parser.add_argument( + "-j", + "--jules", + default=None, + help="The Jules source being used." + "Either a path to a local clone or a github source." "If not set, will be read from the dependencies.yaml", ) return parser.parse_args() @@ -1232,6 +1242,7 @@ def apply_macros_main( version: str | None = None, apps: Path = Path(".").absolute(), core: str | None = None, + jules: str | None = None, ) -> None: """ Main function for this program @@ -1239,7 +1250,7 @@ def apply_macros_main( check_environment() - macro_object: ApplyMacros = ApplyMacros(tag, cname, version, apps, core) + macro_object: ApplyMacros = ApplyMacros(tag, cname, version, apps, core, jules) # Pre-process macros banner_print("Pre-Processing Macros") @@ -1268,4 +1279,4 @@ def apply_macros_main( if __name__ == "__main__": args = parse_args() - apply_macros_main(args.tag, args.cname, args.version, args.apps, args.core) + apply_macros_main(args.tag, args.cname, args.version, args.apps, args.core, args.jules) From eea4a2216f8910d9109a6fcf434227591f08992f Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 5 May 2026 08:11:38 +0100 Subject: [PATCH 2/6] lfric-jules meta changes --- lfric_macros/apply_macros.py | 3 ++- lfric_macros/release_lfric.py | 38 +++++++++++++++++------------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lfric_macros/apply_macros.py b/lfric_macros/apply_macros.py index c891e155..b202e359 100755 --- a/lfric_macros/apply_macros.py +++ b/lfric_macros/apply_macros.py @@ -251,7 +251,7 @@ def __init__( version: str, apps: Path, core: Path, - jules: Path, + jules: Path | None = None, testing: bool = False, ) -> None: self.tag: str = tag @@ -1098,6 +1098,7 @@ def run_app_upgrade(self, app_path: Path) -> None: result = run_command(command) if result.returncode: print(f"[FAIL] The rose-stem app {app} failed to upgrade") + print(os.environ["ROSE_META_PATH"]) raise RuntimeError( f"\nThe command run:\n{command}" f"\nThe error message produced:\n{result.stderr}" diff --git a/lfric_macros/release_lfric.py b/lfric_macros/release_lfric.py index 567dd96a..c9edff75 100755 --- a/lfric_macros/release_lfric.py +++ b/lfric_macros/release_lfric.py @@ -241,7 +241,7 @@ def copy_head_meta(meta_dirs: list[Path], apps: Path, core: Path, version: str) _ = run_command(command) -def update_meta_import_path(meta_dirs: list[Path], version: str) -> None: +def update_meta_import_path(meta_dirs: list[Path], version: str, jules: str) -> None: """ Change HEAD to vnX.Y in meta import statements in the newly created vnX.Y/rose-meta.conf files @@ -261,7 +261,10 @@ def update_meta_import_path(meta_dirs: list[Path], version: str) -> None: elif in_imports and not line.strip().startswith("="): break if in_imports: - line = line.replace("HEAD", version) + if "jules-lfric" in line: + line = line.replace("HEAD", jules) + else: + line = line.replace("HEAD", version) lines[i] = line with open(meta_file, "w") as f: @@ -384,6 +387,13 @@ def parse_args() -> argparse.Namespace: type=version_number, help="The new version number we are updating to (format X.Y)", ) + parser.add_argument( + "-j", + "--jules", + required=True, + help="The newly released version of Jules for jules-lfric metadata imports " + "(format X.Y)" + ) parser.add_argument( "-t", "--ticket", @@ -413,6 +423,7 @@ def parse_args() -> argparse.Namespace: args.core = args.core.expanduser().absolute() args.version = f"vn{args.version}" args.old_version = f"vn{args.old_version}" + args.jules = f"vn{args.jules}" return args @@ -430,29 +441,16 @@ def main() -> None: set_dependency_path(args.apps, args.core) - # Find all metadata directories, excluing jules shared and lfric inputs as these - # have metadata but no macros. + # Find all metadata directories, excluing lfric-inputs as this has metadata but no + # macros. exclude_dirs = ( - ".svn", + ".git", "rose-stem", "integration-test", - "lfric-jules-shared", "lfricinputs", ) meta_dirs = find_meta_dirs([args.apps, args.core], exclude_dirs) - # Find JULES shared metadata directories and combine with all other metadirs for - # where they are handled differently - jules_meta_path = ( - args.apps - / "interfaces" - / "jules_interface" - / "rose-meta" - / "lfric-jules-shared" - ) - jules_shared_meta_dirs = find_meta_dirs([jules_meta_path]) - meta_dirs_plus_jules = meta_dirs.union(jules_shared_meta_dirs) - update_version_number(args.apps, args.version) update_variables_files(args.apps) @@ -471,9 +469,9 @@ def main() -> None: ) print("\n[INFO] Successfully upgraded apps") - copy_head_meta(meta_dirs_plus_jules, args.apps, args.core, args.version) + copy_head_meta(meta_dirs, args.apps, args.core, args.version) - update_meta_import_path(meta_dirs, args.version) + update_meta_import_path(meta_dirs, args.version, args.jules) upgrade_file_name = copy_versions_files( meta_dirs, args.old_version, args.version, args.apps, args.core From 853e3e1e47db3bc39372b0e77485f42e48bf71bb Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 5 May 2026 08:21:24 +0100 Subject: [PATCH 3/6] ruff --- lfric_macros/apply_macros.py | 4 +++- lfric_macros/release_lfric.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lfric_macros/apply_macros.py b/lfric_macros/apply_macros.py index b202e359..28a9538b 100755 --- a/lfric_macros/apply_macros.py +++ b/lfric_macros/apply_macros.py @@ -1280,4 +1280,6 @@ 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) + apply_macros_main( + args.tag, args.cname, args.version, args.apps, args.core, args.jules + ) diff --git a/lfric_macros/release_lfric.py b/lfric_macros/release_lfric.py index c9edff75..4d42df3a 100755 --- a/lfric_macros/release_lfric.py +++ b/lfric_macros/release_lfric.py @@ -392,7 +392,7 @@ def parse_args() -> argparse.Namespace: "--jules", required=True, help="The newly released version of Jules for jules-lfric metadata imports " - "(format X.Y)" + "(format X.Y)", ) parser.add_argument( "-t", From fb3b52001b62e7c3beeac9b579e3b0e0c0447353 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 5 May 2026 08:37:28 +0100 Subject: [PATCH 4/6] remove print --- lfric_macros/apply_macros.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lfric_macros/apply_macros.py b/lfric_macros/apply_macros.py index 28a9538b..7ec13a8d 100755 --- a/lfric_macros/apply_macros.py +++ b/lfric_macros/apply_macros.py @@ -1098,7 +1098,6 @@ def run_app_upgrade(self, app_path: Path) -> None: result = run_command(command) if result.returncode: print(f"[FAIL] The rose-stem app {app} failed to upgrade") - print(os.environ["ROSE_META_PATH"]) raise RuntimeError( f"\nThe command run:\n{command}" f"\nThe error message produced:\n{result.stderr}" From 337c289b2f2ae344fe8fe130420119beaa528c23 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 5 May 2026 08:38:56 +0100 Subject: [PATCH 5/6] add jules to pytest --- lfric_macros/tests/test_apply_macros.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lfric_macros/tests/test_apply_macros.py b/lfric_macros/tests/test_apply_macros.py index c4e3f78c..24b1af5e 100644 --- a/lfric_macros/tests/test_apply_macros.py +++ b/lfric_macros/tests/test_apply_macros.py @@ -70,7 +70,9 @@ def __repr__(self): # Create an instance of the apply_macros class # Use /tmp for Core and Jules as these are not required for testing -applymacros = ApplyMacros("vn0.0_t001", None, None, TEST_APPS_DIR, Path("/tmp"), True) +applymacros = ApplyMacros( + "vn0.0_t001", None, None, TEST_APPS_DIR, Path("/tmp"), Path("/tmp"), True +) def test_read_versions_file(): From 1d6cfd8bfafc6cc4f32bd2854027e43139f13597 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Wed, 6 May 2026 10:19:17 +0100 Subject: [PATCH 6/6] scitech suggestions --- lfric_macros/apply_macros.py | 2 +- lfric_macros/release_lfric.py | 12 +++++++----- lfric_macros/tests/test_apply_macros.py | 8 +++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lfric_macros/apply_macros.py b/lfric_macros/apply_macros.py index 5c59264c..bdec22e7 100755 --- a/lfric_macros/apply_macros.py +++ b/lfric_macros/apply_macros.py @@ -248,7 +248,7 @@ def __init__( self, tag: str, cname: str | None, - version: str, + version: str | None, apps: Path, core: Path, jules: Path | None = None, diff --git a/lfric_macros/release_lfric.py b/lfric_macros/release_lfric.py index 4d42df3a..33547c38 100755 --- a/lfric_macros/release_lfric.py +++ b/lfric_macros/release_lfric.py @@ -241,7 +241,9 @@ def copy_head_meta(meta_dirs: list[Path], apps: Path, core: Path, version: str) _ = run_command(command) -def update_meta_import_path(meta_dirs: list[Path], version: str, jules: str) -> None: +def update_meta_import_path( + meta_dirs: list[Path], version: str, jules_version: str +) -> None: """ Change HEAD to vnX.Y in meta import statements in the newly created vnX.Y/rose-meta.conf files @@ -262,7 +264,7 @@ def update_meta_import_path(meta_dirs: list[Path], version: str, jules: str) -> break if in_imports: if "jules-lfric" in line: - line = line.replace("HEAD", jules) + line = line.replace("HEAD", jules_version) else: line = line.replace("HEAD", version) lines[i] = line @@ -389,7 +391,7 @@ def parse_args() -> argparse.Namespace: ) parser.add_argument( "-j", - "--jules", + "--jules_version", required=True, help="The newly released version of Jules for jules-lfric metadata imports " "(format X.Y)", @@ -423,7 +425,7 @@ def parse_args() -> argparse.Namespace: args.core = args.core.expanduser().absolute() args.version = f"vn{args.version}" args.old_version = f"vn{args.old_version}" - args.jules = f"vn{args.jules}" + args.jules_version = f"vn{args.jules_version}" return args @@ -471,7 +473,7 @@ def main() -> None: copy_head_meta(meta_dirs, args.apps, args.core, args.version) - update_meta_import_path(meta_dirs, args.version, args.jules) + update_meta_import_path(meta_dirs, args.version, args.jules_version) upgrade_file_name = copy_versions_files( meta_dirs, args.old_version, args.version, args.apps, args.core diff --git a/lfric_macros/tests/test_apply_macros.py b/lfric_macros/tests/test_apply_macros.py index 24b1af5e..138fd2c2 100644 --- a/lfric_macros/tests/test_apply_macros.py +++ b/lfric_macros/tests/test_apply_macros.py @@ -71,7 +71,13 @@ def __repr__(self): # Create an instance of the apply_macros class # Use /tmp for Core and Jules as these are not required for testing applymacros = ApplyMacros( - "vn0.0_t001", None, None, TEST_APPS_DIR, Path("/tmp"), Path("/tmp"), True + tag="vn0.0_t001", + cname=None, + version=None, + apps=TEST_APPS_DIR, + core=Path("/tmp"), + jules=Path("/tmp"), + testing=True, )