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/#193 restore scenario #263
Conversation
Codecov Report
@@ Coverage Diff @@
## development #263 +/- ##
===============================================
+ Coverage 86.52% 89.11% +2.59%
===============================================
Files 45 45
Lines 2745 2812 +67
===============================================
+ Hits 2375 2506 +131
+ Misses 370 306 -64
Continue to review full report at Codecov.
|
Is this PR ready to be reviewed by anyone? |
Almost. I just now discovered compatibility-issues with #264, will fix that and assign people then. |
This is ready for review, although there is one line in the unit-test I will change so that tests will pass after merging #264 . |
smac/smac_cli.py
Outdated
stats = None | ||
incumbent = None | ||
if args_.restore_state: | ||
# Check for folder and files |
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.
Could you add some output to debug if restoring fails, e.g. "Trying to restore state from
", "Successfully restored %d runs", "Successfully restored incumbent with value %f"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.
Done.
Can we please merge the documentation before merging any other pull request? The documentation PR is already quite big and would have to be updated accordingly if we merge new features/change output files etc. |
Not sure whats up with the travis-ci build, when I follow the Details it tells me all has passed... |
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 for the late review. I hope most of the requested changes should be quite easy to implement.
smac/optimizer/smbo.py
Outdated
except FirstRunCrashedException as err: | ||
if self.scenario.abort_on_first_run_crash: | ||
raise | ||
# Initialization, depends on input |
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.
can we please move Lines 104-122 in function?
(otherwise we would need to copy the code for new optimizers besides SMBO.
@@ -83,12 +85,43 @@ def main_cli(self): | |||
fn=traj_fn, cs=scen.cs) | |||
initial_configs.append(trajectory[-1]["incumbent"]) | |||
|
|||
# Restore state |
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.
please also move this code to its own function
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.
it should be also easier to write a unit test if we move this code to its own function
smac/smac_cli.py
Outdated
# Copy traj if output_dir is different | ||
if scen.output_dir != Scenario(scen_path).output_dir: | ||
new_traj_path = os.path.join(scen.output_dir, "traj_aclib2.json") | ||
shutil.copy(traj_path, new_traj_path) |
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.
should we make a copy of the old "state" to prevent overwriting it?
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.
See command above... I figured that if the user specifies a new output_dir, then the restoring gets done in another folder. That way, the old version will be completely preserved.
smac/smac_cli.py
Outdated
incumbent = trajectory[-1]["incumbent"] | ||
root_logger.debug("Restored incumbent %s from %s", incumbent, traj_path) | ||
# Copy traj if output_dir is different | ||
if scen.output_dir != Scenario(scen_path).output_dir: |
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.
Scenario(scen_path)
looks weird to me.
Is args_.restore_state
not already the output_dir of the previous scenario?
Furthermore, I wonder whether we have side effects by creating the Scenario
object again --- overwriting of old existing files?
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.
By leaving it open to the user to specify the scenario, the user can choose to use a different scenario-file (with extended limits or another output-path) to continue a restored scenario. When continuing in a new output-folder, everything gets written anew except for the trajectory (which is written continously), so its copied. I changed the Scenario(scen_path).output_dir
to InputReader().read_scenario_file(scen_path)['output_dir']
to avoid possible side-effects.
Do you think the procedure is correct in general?
smac/stats/stats.py
Outdated
""" | ||
Save all relevant attributes to json-dictionary. | ||
""" | ||
data = {'ta_runs': self.ta_runs, |
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.
Can't we save the Scenario attributes in a similar generic way as in load()
?
Such a hand-written dictionary is also hard to maintain.
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 can do it the other way around: manually filtering everything thats NOT to be saved. Implemented now, do you think it's better?
@mlindauer I'm not sure whats up with the build... its something to with pexpect: |
@shukon we're working on the |
Since my concerns were addressed, can we merge this PR? @shukon maybe an update of the docu mentioning this new feature would be nice. |
@mlindauer Added mention to the docs. As far as I'm concerned, we can merge. |
hmmm... we have a major issue with this PR because it includes unintended commits to the development branch. Unfortunately, another student commited without permissions stuff to the development branch. This is also the reason for the weird We reverted the commits in the development branch. |
I will clean this branch up at some point today. |
a6fc961
to
8846f39
Compare
@mlindauer This branch should be clean now. |
Before I merge this, I wanted to try it myself using
@shukon Please try to run the example yourself and check whether you can produce this error (and fix if necessary). Furthermore, reading the docu, I was not sure whether I would need to change the scenario file provided in the cmd ( |
Done. I tried quite a few things now, but I'm quite confident that the build-fail has nothing to do with this PR. It's the |
…sue/#193_restore_scenario
Sorry, I found another bug. Furthermore, this branch has now a merge conflict with the dev. @shukon could you please fix this merge conflict. |
@mlindauer Don't be sorry for finding bugs, let me be sorry for not finding them. Should be fixed now ( |
Very nice now! I haven't found further bugs ;-) Nevertheless, I have a further request. Could you please add a message (on INFO level) that the state was restored and that SMAC continues with the following state (incumbent + stats). Right now, I as a user would wonder whether SMAC really restored the state or not since it does not say anything in this direction. |
@mlindauer Now logging:
|
Implementing state-restoration for smac-cmdline as mentioned in issue #193.
simply use the
--restore_state <FOLDER>
-option. Currently simply assuming for scenario to be the same, differing options can lead to unexpected behavior (except for the limits, e.g.runcount_limit
,wallclock_limit
,tuner-timeout
).