Skip to content

Commit

Permalink
Fixes 0.3 defaults (#30)
Browse files Browse the repository at this point in the history
* Fix default values
* Set exp_driver init

(cherry picked from commit ee19120)
  • Loading branch information
moritzmeister committed Nov 8, 2019
1 parent f8e5a90 commit 72b8a3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions maggy/core/experimentdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, experiment_type, **kwargs):
if self.experiment_type == 'optimization':
# set up an optimization experiment

self.num_trials = kwargs.get('num_trials')
self.num_trials = kwargs.get('num_trials', 1)

searchspace = kwargs.get('searchspace')
if isinstance(searchspace, Searchspace):
Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(self, experiment_type, **kwargs):
self.optimizer.searchspace = self.searchspace
self.optimizer.final_store = self._final_store

direction = kwargs.get('direction')
direction = kwargs.get('direction', 'max')
if isinstance(direction, str) and direction.lower() in ['min', 'max']:
self.direction = direction.lower()
else:
Expand Down
6 changes: 4 additions & 2 deletions maggy/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
experiment_json = None


def lagom(map_fun, name,
def lagom(map_fun, name='no-name',
experiment_type='optimization', hb_interval=1,
num_trials=None, searchspace=None, optimizer=None, direction=None,
ablation_study=None, ablator=None,
Expand Down Expand Up @@ -88,6 +88,7 @@ def lagom(map_fun, name,
global elastic_id
global run_id
running = True
exp_driver = None

sc = hopsutil._find_spark().sparkContext
app_id = str(sc.applicationId)
Expand Down Expand Up @@ -174,7 +175,8 @@ def lagom(map_fun, name,
# sparkmagic hb poll intervall is 5 seconds, therefore wait 6 seconds
time.sleep(6)
# cleanup spark jobs
exp_driver.stop()
if running and exp_driver is not None:
exp_driver.stop()
elastic_id += 1
running = False
sc.setJobGroup("", "")
Expand Down

0 comments on commit 72b8a3a

Please sign in to comment.