Skip to content

Commit

Permalink
v2: Default status and restore-state to serial
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Jan 6, 2025
1 parent 29d87b6 commit cd99260
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ 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.0] - 2024-12-24

### Added

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 @@ -188,7 +188,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 @@ -198,7 +198,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
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
2 changes: 1 addition & 1 deletion tests/test_mepo_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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)
Expand Down
4 changes: 2 additions & 2 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

0 comments on commit cd99260

Please sign in to comment.