Skip to content
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

Fix autosave function for single core #770

Merged
merged 15 commits into from
Dec 7, 2021
Merged

Fix autosave function for single core #770

merged 15 commits into from
Dec 7, 2021

Conversation

yannikschaelte
Copy link
Member

@yannikschaelte yannikschaelte commented Dec 6, 2021

  • Assert {id} template in CSV histories.
  • Fix behavior of filename=None for single-core by rewriting pre- and post-processing (filename was ignored / overwritten by None, and thus the default output file always generated)

Actual fix of #743 not done yet.

@yannikschaelte yannikschaelte self-assigned this Dec 6, 2021
@yannikschaelte yannikschaelte marked this pull request as draft December 6, 2021 15:53
@yannikschaelte yannikschaelte changed the title Fix hdf5 file distribution Fix autosave function for single core Dec 6, 2021
@yannikschaelte yannikschaelte marked this pull request as ready for review December 6, 2021 17:27
@yannikschaelte
Copy link
Member Author

(applied black to history.py. should stop doing that 🐈‍⬛ )

pypesto/objective/history.py Show resolved Hide resolved
test/conftest.py Outdated Show resolved Hide resolved
test/base/test_store.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2021

Codecov Report

Merging #770 (0ec162e) into develop (a3fb58b) will increase coverage by 41.78%.
The diff coverage is 95.74%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop     #770       +/-   ##
============================================
+ Coverage    48.05%   89.84%   +41.78%     
============================================
  Files           98       98               
  Lines         6829     6847       +18     
============================================
+ Hits          3282     6152     +2870     
+ Misses        3547      695     -2852     
Impacted Files Coverage Δ
pypesto/optimize/task.py 100.00% <ø> (ø)
pypesto/sample/sample.py 96.55% <ø> (+58.62%) ⬆️
pypesto/optimize/util.py 95.12% <92.59%> (+38.87%) ⬆️
pypesto/objective/history.py 95.31% <96.42%> (+48.15%) ⬆️
pypesto/optimize/optimize.py 97.95% <100.00%> (+7.95%) ⬆️
pypesto/optimize/optimizer.py 90.56% <100.00%> (+4.94%) ⬆️
pypesto/objective/amici_util.py 75.43% <0.00%> (-8.78%) ⬇️
pypesto/objective/amici_calculator.py 91.66% <0.00%> (-1.67%) ⬇️
pypesto/store/hdf5.py 83.33% <0.00%> (+4.16%) ⬆️
... and 66 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3fb58b...0ec162e. Read the comment docs.

Copy link
Collaborator

@PaulJonasJost PaulJonasJost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure what you did in the testing files but looks like a more elegant way of creating temporary hdf5 files 👍

@yannikschaelte
Copy link
Member Author

yannikschaelte commented Dec 6, 2021

Not entirely sure what you did in the testing files but looks like a more elegant way of creating temporary hdf5 files +1

you mean that hdf5_file argument? That was just as a cleaner solution to those with ... statements, and to fight claustrophobia.

pypesto/optimize/optimize.py Outdated Show resolved Hide resolved
pypesto/optimize/optimize.py Outdated Show resolved Hide resolved
pypesto/objective/history.py Outdated Show resolved Hide resolved
return False

# extract storage type
path = Path(storage_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yannikschaelte yannikschaelte merged commit cd826fa into develop Dec 7, 2021
@yannikschaelte yannikschaelte deleted the fix_store branch December 7, 2021 12:54
@@ -79,13 +86,13 @@ def check_history(self):
if storage_type is not None:
read_results_from_file(
self.problem, self.history_options,
len(result.optimize_result.list) + 2
n_starts=n_starts,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As indicated by the docstring here, having n_starts+2 was very much intentional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah missed the docstring 🙈 problem is that now the csv files each carry an id, therefore files with id=1,2 do not exist. Would it be desirable to allow passing a list of ids (/filenames) to read_results_from_file instead of the single n_starts? then this scenario could be covered here by [0, 0, 0]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess silently reading the same file multiple times bc no id is present, is not desirable, unless explicitly requested, thus the {id} check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the {id} was there before. This is supposed to check whether read_results_from_file can handle missing files (optimization stopped before file was written, for whatever reason). If we do not wan't this behavior we should add a check whether read_results_from_file fails when the file is not present.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did the {id} come in before? It's not in the original file name in 6d3226d#diff-80b64c062a6e89e507e7518b03d2cf45dc9518a824f39bae232b565e8e5016afL52, does it come in in processing somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it just read in the same file filename.csv 3 times in the previous test implementation, therefore all files existed. when adding {id}, then there was a trace is Null error or something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I supposed the test didn't implement what I intended to then ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix this in a separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :) it confused me too then. so in conclusion I guess yes we want to be able to merge histories also when some ids are not present (maybe warn then).

@yannikschaelte yannikschaelte mentioned this pull request Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants