-
Notifications
You must be signed in to change notification settings - Fork 18
Lfric macros jules meta #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
c0f8dab
eea4a22
853e3e1
fb3b520
337c289
5af66b9
1d6cfd8
798b4a7
d411ba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be easy to get a bit confused with apps and core being references to paths. So adding version here may help users of the script know what is expected in the argument.
Suggested change
|
||||||
| 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 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon it would be good to differentiate between the parameters here as it makes it clearer what data is being operated on when the function is called.
Suggested change
|
||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def test_read_versions_file(): | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
repoargument would benefit from being added to the docstringThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done