diff --git a/CHANGELOG.md b/CHANGELOG.md index b03f3f0f..6831467d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -## [2.2.0] - 2024-12-24 +- Moved `mepo status` and `mepo restore-state` to default to their serial variants rather than parallel by default. At the same time, we remove the `--serial` option from these commands and add a `--parallel` option if users want to run them in parallel. + +## [2.2.1] - 2025-01-03 + +### Fixed + +- Fixed bugs in the lesser used options of `mepo clone`, `allrepos` and `registry` +### Added + +- Added tests for `mepo clone --allrepos` and `mepo clone --registry` + +## [2.2.0] - 2024-12-24 ### Added diff --git a/pyproject.toml b/pyproject.toml index 82d3d5ed..f4847a1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mepo" -version = "2.2.0" +version = "2.2.1" description = "A tool for managing (m)ultiple r(epo)s" authors = [{name="GMAO SI Team", email="siteam@gmao.gsfc.nasa.gov"}] dependencies = [ diff --git a/src/mepo/cmdline/parser.py b/src/mepo/cmdline/parser.py index 12b5c4dd..8a551de0 100644 --- a/src/mepo/cmdline/parser.py +++ b/src/mepo/cmdline/parser.py @@ -185,7 +185,7 @@ def __status(self): "--hashes", action="store_true", help="Print the exact hash of the HEAD." ) status.add_argument( - "--serial", action="store_true", help="Run the serial version." + "--parallel", action="store_true", help="Run the parallel version." ) def __restore_state(self): @@ -195,7 +195,7 @@ def __restore_state(self): aliases=mepoconfig.get_command_alias("restore-state"), ) restore_state.add_argument( - "--serial", action="store_true", help="Run the serial version." + "--parallel", action="store_true", help="Run the parallel version." ) def __diff(self): diff --git a/src/mepo/command/clone.py b/src/mepo/command/clone.py index 720614c9..3e64b5ac 100644 --- a/src/mepo/command/clone.py +++ b/src/mepo/command/clone.py @@ -136,7 +136,7 @@ def checkout_all_repos(allcomps, branch): if branch is None: raise RuntimeError("`allrepos` option must be used with a branch/tag.") for comp in allcomps: - branch_y = colors.YELLOW + args.branch + colors.RESET + branch_y = colors.YELLOW + branch + colors.RESET print(f"Checking out {branch_y} in {comp.name}") git = GitRepository(comp.remote, comp.local) - git.checkout(args.branch) + git.checkout(branch) diff --git a/src/mepo/command/restore-state.py b/src/mepo/command/restore-state.py index bb33ee40..3d9fe86c 100644 --- a/src/mepo/command/restore-state.py +++ b/src/mepo/command/restore-state.py @@ -9,13 +9,13 @@ def run(args): print("Checking status...", flush=True) allcomps = MepoState.read_state() - if args.serial: + if args.parallel: + with mp.Pool() as pool: + result = pool.map(check_component_status, allcomps) + else: result = [] for comp in allcomps: result.append(check_component_status(comp)) - else: - with mp.Pool() as pool: - result = pool.map(check_component_status, allcomps) restore_state(allcomps, result) diff --git a/src/mepo/command/status.py b/src/mepo/command/status.py index ad51bb12..6b309116 100644 --- a/src/mepo/command/status.py +++ b/src/mepo/command/status.py @@ -20,17 +20,17 @@ def run(args): allcomps = MepoState.read_state() # max_width = len(max([comp.name for comp in allcomps], key=len)) max_width = max([len(comp.name) for comp in allcomps]) - if args.serial: - for comp in allcomps: - result = check_component_status(comp, args.ignore_permissions) - print_component_status(comp, result, max_width, args.nocolor, args.hashes) - else: + if args.parallel: with mp.Pool() as pool: result = pool.starmap( check_component_status, [(comp, args.ignore_permissions) for comp in allcomps], ) print_status(allcomps, result, max_width, args.nocolor, args.hashes) + else: + for comp in allcomps: + result = check_component_status(comp, args.ignore_permissions) + print_component_status(comp, result, max_width, args.nocolor, args.hashes) def check_component_status(comp, ignore_permissions): diff --git a/tests/input/external-components.yaml b/tests/input/external-components.yaml new file mode 100644 index 00000000..e296d30d --- /dev/null +++ b/tests/input/external-components.yaml @@ -0,0 +1,52 @@ +GEOSfvdycore: + fixture: true + develop: main + +env: + local: ./@env + remote: https://github.com/GEOS-ESM/ESMA_env.git + tag: v4.29.1 + develop: main + +cmake: + local: ./@cmake + remote: https://github.com/GEOS-ESM/ESMA_cmake.git + tag: v3.55.0 + develop: develop + +ecbuild: + local: ./@cmake/@ecbuild + remote: https://github.com/GEOS-ESM/ecbuild.git + tag: geos/v1.4.0 + +GMAO_Shared: + local: ./src/Shared/@GMAO_Shared + remote: https://github.com/GEOS-ESM/GMAO_Shared.git + branch: mepo-testing-do-not-delete + sparse: ./config/GMAO_Shared.sparse + develop: main + +GEOS_Util: + local: ./src/Shared/@GMAO_Shared/@GEOS_Util + remote: https://github.com/GEOS-ESM/GEOS_Util.git + tag: v2.1.3 + develop: main + +FMS: + local: ./src/Shared/@FMS + remote: https://github.com/GEOS-ESM/FMS.git + tag: geos/2019.01.02+noaff.10 + develop: geos/release/2019.01 + +FVdycoreCubed_GridComp: + local: ./src/Components/@FVdycoreCubed_GridComp + remote: https://github.com/GEOS-ESM/FVdycoreCubed_GridComp.git + branch: develop + develop: develop + +fvdycore: + local: ./src/Components/@FVdycoreCubed_GridComp/@fvdycore + remote: https://github.com/GEOS-ESM/GFDL_atmos_cubed_sphere.git + branch: geos/develop + develop: geos/develop + diff --git a/tests/output/output_branch_list.txt b/tests/output/output_branch_list.txt index 13438e52..0fb80988 100644 --- a/tests/output/output_branch_list.txt +++ b/tests/output/output_branch_list.txt @@ -8,4 +8,5 @@ ecbuild | * (HEAD detached at geos/v1.3.0) | remotes/origin/feature/netcdf4-cmake | remotes/origin/geos/main | remotes/origin/master + | remotes/origin/mepo-testing-do-not-delete | remotes/origin/release/stable diff --git a/tests/test_mepo_clone.py b/tests/test_mepo_clone.py index 65bcd0fd..9d1963b8 100644 --- a/tests/test_mepo_clone.py +++ b/tests/test_mepo_clone.py @@ -15,6 +15,7 @@ FIXTURE_NAME = "GEOSfvdycore-mepo-testing" FIXTURE_URL = f"https://github.com/pchakraborty/{FIXTURE_NAME}.git" +TEST_DIR = os.path.dirname(os.path.realpath(__file__)) def get_mepo_status(): @@ -22,7 +23,7 @@ def get_mepo_status(): ignore_permissions=False, nocolor=True, hashes=False, - serial=True, + parallel=False, ) with contextlib.redirect_stdout(io.StringIO()) as output: mepo_status.run(args) @@ -89,3 +90,64 @@ def test_mepo_clone_url_branch_directory(): status_output = get_mepo_status() assert status_output == saved_output shutil.rmtree(DIRECTORY) + + +def test_mepo_clone_url_branch_allrepos(): + if os.path.isdir(FIXTURE_NAME): + shutil.rmtree(FIXTURE_NAME) + args = SimpleNamespace( + style="prefix", + registry=None, + url=FIXTURE_URL, + branch="mepo-testing-do-not-delete", + directory=None, + partial="blobless", + allrepos=True, + ) + mepo_clone.run(args) + saved_output = """Checking status... +GEOSfvdycore | (b) mepo-testing-do-not-delete +env | (b) mepo-testing-do-not-delete +cmake | (b) mepo-testing-do-not-delete +ecbuild | (b) mepo-testing-do-not-delete +GMAO_Shared | (b) mepo-testing-do-not-delete +GEOS_Util | (b) mepo-testing-do-not-delete +FMS | (b) mepo-testing-do-not-delete +FVdycoreCubed_GridComp | (b) mepo-testing-do-not-delete +fvdycore | (b) mepo-testing-do-not-delete +""" + with contextlib_chdir(FIXTURE_NAME): + status_output = get_mepo_status() + assert status_output == saved_output + shutil.rmtree(FIXTURE_NAME) + + +def test_mepo_clone_url_external_registry(): + if os.path.isdir(FIXTURE_NAME): + shutil.rmtree(FIXTURE_NAME) + args = SimpleNamespace( + style="prefix", + registry=os.path.join(TEST_DIR, "input/external-components.yaml"), + url=FIXTURE_URL, + branch="mepo-testing-do-not-delete", + directory=None, + partial="blobless", + allrepos=False, + ) + mepo_clone.run(args) + saved_output = """Checking status... +GEOSfvdycore | (b) mepo-testing-do-not-delete + | external-components.yaml: \x1b[31muntracked file\x1b[0m +env | (t) v4.29.1 (DH) +cmake | (t) v3.55.0 (DH) +ecbuild | (t) geos/v1.4.0 (DH) +GMAO_Shared | (b) mepo-testing-do-not-delete +GEOS_Util | (t) v2.1.3 (DH) +FMS | (t) geos/2019.01.02+noaff.10 (DH) +FVdycoreCubed_GridComp | (b) develop +fvdycore | (b) geos/develop +""" + with contextlib_chdir(FIXTURE_NAME): + status_output = get_mepo_status() + assert status_output == saved_output + shutil.rmtree(FIXTURE_NAME) diff --git a/tests/test_mepo_commands.py b/tests/test_mepo_commands.py index 5627b279..fba243fa 100644 --- a/tests/test_mepo_commands.py +++ b/tests/test_mepo_commands.py @@ -100,7 +100,7 @@ def __mepo_status(self, saved_output): ignore_permissions=False, nocolor=True, hashes=False, - serial=False, + parallel=True, ) with contextlib.redirect_stdout(io.StringIO()) as output: mepo_status.run(args) @@ -112,7 +112,7 @@ def __mepo_status(self, saved_output): def __mepo_restore_state(self): os.chdir(self.__class__.fixture_dir) - args = SimpleNamespace(serial=False) + args = SimpleNamespace(parallel=True) with contextlib.redirect_stdout(io.StringIO()) as _: mepo_restore_state.run(args) self.__mepo_status(self.__class__.output_clone_status) @@ -337,7 +337,7 @@ def test_reset(self): self.__class__.__mepo_clone() def test_mepo_version(self): - self.assertEqual(get_mepo_version(), "2.2.0") + self.assertEqual(get_mepo_version(), "2.2.1") def tearDown(self): pass