-
Notifications
You must be signed in to change notification settings - Fork 51
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
Refactor benchmark CLI #273
Conversation
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.
On the whole this looks like a good factoring and decreases a lot of repetitive code.
|
||
from amazon.ionbenchmark.benchmark_spec import BenchmarkSpec | ||
|
||
_pypy = platform.python_implementation() == 'PyPy' |
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.
I will say again: it's not clear to me that anyone is actually using this with PyPy. For the benchmarking I would comfortable saying "we don't benchmark or profile on pypy"
@rmarrowstone What are your thoughts on testing the benchmark CLI? Can you recommend a good overall testing strategy, or shall I just try to write unit tests for the individual components and rely on the regression workflow to catch larger problems? |
Latter sounds reasonable. For CLIs I tend to just run them and not worry too much about automated testing of the actual executable: the ROI of such isn't great imo. |
Alright, I've got all tests passing now, including on PyPy. The performance workflow will fail, but I'd like to address that in a followup PR to prevent the scope of this one from growing too large. |
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.
Some minor-ish comments. I can't say I've read every line thoroughly. I can say that this is such an improvement over what's there that I'm inclined to merge and iterate/fix-up as needed.
Great work!!!
if 'name' not in self: | ||
self['name'] = f'({self.get_format()},{self.get_operation_name()},{path.basename(self.get_input_file())})' | ||
|
||
def __missing__(self, key): |
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.
fwiw i think you could inherit from defaultdict
to do this. not sure it's any better.
""" | ||
return self["name"] | ||
|
||
def get_format(self): |
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.
consider using @property
annotation on methods without get_
e.g:
@property
def format(self):
...
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.
So... I just tried this out, and found that I was getting inconsistent behavior between PyPy and CPython, so I'd like to leave it as is.
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.
sorry to hear that. agree not to sweat it for now.
self._loader_dumper = self._get_loader_dumper() | ||
return self._loader_dumper | ||
|
||
def _get_loader_dumper(self): |
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.
Nice way to abstract the specific format. 👍
Co-authored-by: Rob Marrowstone <[email protected]>
Issue #, if available:
Description of changes:
This is still a WIP, but the CLI is usable with BenchmarkSpecs.
Still to-do are some more documentation, updating the benchmark cli tests, and some general double-checking of things, but you can start taking a look at it or even try it out yourself right now!
Example:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.