Skip to content

Commit

Permalink
Merge pull request #3 from maxkatzmann/none-selected-warning
Browse files Browse the repository at this point in the history
Added reminder message and updated documentation.
  • Loading branch information
thobl authored Jan 11, 2024
2 parents 3136b03 + 1e13bbd commit 0cf17ff
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# 1.0.7
* **user experience:** If no run is selected via the command line, a warning
is presented to the user as a reminder.
* **documentation:** The README now briefly explains how to execute from the
command line

# 1.0.6
* **new feature:** it is now possible to use wildcards to specify
the names of experiments to be run
* bug-fix: under some circumstances the multi-processing pool
* **bug-fix:** under some circumstances the multi-processing pool
was getting an exception when python is shutting down
* **documentation:** Description of the new feature.

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ run.add(
run.run()
```

The experiment is then run using `python example.py experiment1`.

If you want to reformat the output before writing it to a file using a
function `reformat()`, which takes a string and returns a string, you
can do so by simply adding `stdout_mod=reformat` to the above example.
Expand Down
12 changes: 11 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def _add_run(run):
_state.runs_by_name[run.name].append(run)


def _wildcard_match(pattern: str, candidates: 'list[str]'):
def _wildcard_match(pattern: str, candidates: "list[str]"):
"""Decides whether some element a pattern with Unix shell-style wildcards
matches any candidate string.
Expand Down Expand Up @@ -376,9 +376,19 @@ def run():
except KeyboardInterrupt:
_print_warning("aborted during experiment " + name)
pool.close()

# If no runs were selected, we print a brief reminder message that names of
# runs should be passed via the command line to execute them.
any_selected = any(map(_is_selected, _state.runs_by_name.keys()))

_state.run_completed = True
_state = _State()

if not any_selected:
_print_warning(
f"Did not try to run experiments as none were passed via the command line."
)


def use_cores(nr_cores):
"""Set the number of cores used to run the experiments.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="run",
version="1.0.6",
version="1.0.7",
description="python module for running experiments",
url="https://github.com/thobl/run",
author="Thomas Bläsius",
Expand Down

0 comments on commit 0cf17ff

Please sign in to comment.