-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add parse and dispatch strategy #198
Add parse and dispatch strategy #198
Conversation
Remove tests as they are not compatible with new API changes to the Benchcab class. Tests relating to executing PBS commands will be a part of the PBS wrapper implementation.
Codecov Report
@@ Coverage Diff @@
## main #198 +/- ##
==========================================
- Coverage 86.74% 85.19% -1.55%
==========================================
Files 27 27
Lines 1396 1385 -11
==========================================
- Hits 1211 1180 -31
- Misses 185 205 +20
|
16f9766
to
6e201d6
Compare
6e201d6
to
2cbdf2a
Compare
benchcab/benchcab.py
Outdated
"""A helper method that initialises and returns the `tasks` attribute.""" | ||
repos = [ |
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.
This should call the _get_repos
method.
benchcab/benchcab.py
Outdated
@@ -102,21 +93,41 @@ def _validate_environment(self, project: str, modules: list): | |||
) | |||
sys.exit(1) | |||
|
|||
def _initialise_tasks(self) -> list[Task]: | |||
@functools.cache |
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.
After looking at this again, functools.cache
might be a bit overkill. It also looks like functions that take in a dictionary cannot be memoized with functools.cache
. We can achieve caching here by setting an initial value for self.config
to None
and only read the config if self.config == None
, else return the value of self.config
.
The current method of executing subcommands can be improved using a "parse and dispatch" strategy. Whereby you don't need to run a conditional to work out which subcommand to use. This change refactors the Benchcab class so that its "public" methods can be dispatched easily when inspecting the argparse.Namespace object returned by the command line parser. Fixes #196
2cbdf2a
to
474d183
Compare
Integration tests seem to be working. Merging now. |
The current method of executing subcommands can be improved using a "parse and dispatch" strategy. Whereby you don't need to run a conditional to work out which subcommand to use.
This change refactors the Benchcab class so that its "public" methods can be dispatched easily when inspecting the argparse.Namespace object returned by the command line parser.
Fixes #196