Commit e4a672bc authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Job config is now automatically saved as JSON file.

parent 36abe651
......@@ -699,8 +699,17 @@ class JobConfig(object):
return outdict
def to_jsonable_dict(self):
# type: (JobConfig) -> dict
return python_to_json(self.to_dict())
def save(self, path_outfile):
"""Save the JobConfig instance to a JSON file in the same structure like the one in options_default.json.
:param path_outfile: path of the output JSON file
"""
with open(path_outfile, 'w') as outF:
json.dump(self.to_jsonable_dict(), outF, skipkeys=False, indent=4)
def __repr__(self):
return pformat(self.to_dict())
......
......@@ -82,6 +82,11 @@ class process_controller(object):
# called_from_iPyNb = 1 if 'ipykernel/__main__.py' in sys.argv[0] else 0
# save config
self._path_job_optionsfile = os.path.join(self.config.path_job_logs, '%s_options.json' % self.config.ID)
self.config.save(self._path_job_optionsfile)
# create job log
self._path_job_logfile = os.path.join(self.config.path_job_logs, '%s.log' % self.config.ID)
if os.path.exists(self._path_job_logfile):
HLP_F.silentremove(self._path_job_logfile)
......@@ -90,6 +95,7 @@ class process_controller(object):
self.logger.info('Process Controller initialized for job ID %s (comment: %s).'
% (self.config.ID, self.DB_job_record.comment))
self.logger.info('Job logfile: %s' % self._path_job_logfile)
self.logger.info('Job options file: %s' % self._path_job_optionsfile)
if self.config.delete_old_output:
self.logger.info('Deleting previously processed data...')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment