Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/pchakrab/i…
Browse files Browse the repository at this point in the history
…nit-deprecation-warning
  • Loading branch information
pchakraborty committed Jan 8, 2025
2 parents 031ec83 + a6da6de commit 1f45929
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 19 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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="[email protected]"}]
dependencies = [
Expand Down
4 changes: 2 additions & 2 deletions src/mepo/cmdline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/mepo/command/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions src/mepo/command/restore-state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
10 changes: 5 additions & 5 deletions src/mepo/command/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
52 changes: 52 additions & 0 deletions tests/input/external-components.yaml
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions tests/output/output_branch_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
64 changes: 63 additions & 1 deletion tests/test_mepo_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

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():
args = SimpleNamespace(
ignore_permissions=False,
nocolor=True,
hashes=False,
serial=True,
parallel=False,
)
with contextlib.redirect_stdout(io.StringIO()) as output:
mepo_status.run(args)
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions tests/test_mepo_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f45929

Please sign in to comment.