-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue/17 #36
Issue/17 #36
Conversation
Click here to view all benchmarks. |
@@ -1622,16 +1622,17 @@ def save_metrics(self, loop: int, output_metrics_file: str, epoch: int, batch=1) | |||
|
|||
# write to file) | |||
queried_sample = np.array(self.queried_sample) | |||
flag = queried_sample[:,0].astype(int) == epoch | |||
if len(queried_sample) > 0: |
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 is part of a small bug fix that I'm not totally sure about and would like a second opinion from one of the science team. When I was setting up the tests for the learn_loop
function, I ran into an issue with the test data where queried_sample
was empty, which caused the above line to fail. I added a check here and another place in database.py
to check for an empty list before continuing, which seems ok in tandem with the sum(flag) > 0
check before writing, but I wanted to make sure I wasn't causing unexpected behavior.
if is_save_photoids_to_file or is_save_snana_types: | ||
file_name = file_name_prefix + '_' + str(iteration_step) + file_name_suffix | ||
if config.photo_ids_to_file or config.SNANA_types: | ||
file_name = config.photo_ids_froot + '_' + str(iteration_step) + file_name_suffix |
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.
Cute - I didn't notice froot
when I first looked at the LoopConfig dataclass.
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.
Overall, this looks like a nice clean up. Thanks for tidying up the function definitions as well - I like the one-parameter-per-line look too :)
Change Description
creates the
LoopConfiguration
class, which collates all the various configuration options for thelearn_loop
function and adds both some pre-run validation for these options as well as the ability to write all the configuration options to a JSON file, which can be read and rebuilt at runtime.I tried to make this change in a minimally invasive way to the preexisting API. For instance, if before
learn_loop
was called like:the new API could be
of course, you can also just instantiate it separately.
or write and read it from a json file.
resolves #17
Solution Description
Created the
LoopConfiguration
class and placed all of the config parameters in there. Added some validation steps.For the
learn_loop.py
module, I also passed theLoopConfiguration
class through some of the ancillary functions, my arbitrary marker was that if it originally took in more than three of the config parameters I would just replace those with the full config instance and call the field directly in the function .While I was going through the refactor, I also took some time to write a few more tests for
learn_loop
and changed the styling so that multi-line function/object calls have one parameter per line.Code Quality
New Feature Checklist
Documentation Change Checklist