Skip to content

Commit

Permalink
Mark end of process in sessions and exit benignly
Browse files Browse the repository at this point in the history
  • Loading branch information
sharif1093 committed Aug 13, 2019
1 parent 6ae3ef9 commit 44254ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions digideep/pipeline/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def train(self):
logger.fatal('Operation stopped by the user ...')
finally:
logger.fatal('End of operation ...')
self.finalize()

def test(self):
# Make the states of the two explorers train/test exactly the same, for the states of the environments.
Expand Down Expand Up @@ -311,6 +312,15 @@ def enjoy(self): #i.e. eval
finally:
logger.fatal('End of operation ...')

def finalize(self):
# Mark session as done if we have went through all epochs.
if self.state["i_epoch"] == self.params["runner"]["n_epochs"]:
self.session.mark_as_done()

# Close all explorers benignly:
for key in self.explorer:
self.explorer[key].close()

#####################
## Logging Summary ##
#####################
Expand Down
4 changes: 4 additions & 0 deletions digideep/pipeline/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ def set_device(self):
# self.device = torch.device("cpu")
def get_device(self):
return self.device

def mark_as_done(self):
with open(os.path.join(self.state['path_session'], 'done.lock'), 'w') as f:
print("", file=f)

#################################
# Apparatus for model save/load #
Expand Down

0 comments on commit 44254ce

Please sign in to comment.