Skip to content
Snippets Groups Projects
Commit fda220b4 authored by Patrick Godwin's avatar Patrick Godwin
Browse files

utils.py: make job_id, subset_id optional, reflected in online hdf5 sink

parent 4f661772
No related branches found
No related tags found
No related merge requests found
......@@ -141,11 +141,9 @@ class HDF5StreamSink(object):
Also takes care of creating new directories as needed and removing any leftover temporary files.
"""
# set/update file names and directories with new gps time and duration
job_id = '0001'
subset_id = '0001'
self.feature_name = os.path.splitext(utils.to_trigger_filename(self.basename, start_time, duration, 'h5'))[0]
self.feature_path = utils.to_trigger_path(os.path.abspath(self.rootdir), self.basename, start_time, job_id, subset_id)
self.tmp_path = utils.to_trigger_path(self.tmp_dir, self.basename, start_time, job_id, subset_id)
self.feature_path = utils.to_trigger_path(os.path.abspath(self.rootdir), self.basename, start_time)
self.tmp_path = utils.to_trigger_path(self.tmp_dir, self.basename, start_time)
# create temp and output directories if they don't exist
aggregator.makedir(self.feature_path)
......
......@@ -330,8 +330,8 @@ class MultiChannelHandler(simplehandler.Handler):
# set/update file names and directories with new gps time and duration
duration = min(duration, self.feature_end_time - start_time)
self.fname = os.path.splitext(utils.to_trigger_filename(self.basename, start_time, duration, 'h5'))[0]
self.fpath = utils.to_trigger_path(os.path.abspath(self.out_path), self.basename, start_time, self.job_id, self.subset_id)
self.tmp_path = utils.to_trigger_path(self.tmp_dir, self.basename, start_time, self.job_id, self.subset_id)
self.fpath = utils.to_trigger_path(os.path.abspath(self.out_path), self.basename, start_time, job_id=self.job_id, subset_id=self.subset_id)
self.tmp_path = utils.to_trigger_path(self.tmp_dir, self.basename, start_time, job_id=self.job_id, subset_id=self.subset_id)
# create temp and output directories if they don't exist
aggregator.makedir(self.fpath)
......
......@@ -139,15 +139,23 @@ def gps2latency(gps_time):
#----------------------------------
### pathname utilities
def to_trigger_path(rootdir, basename, start_time, job_id, subset_id):
def to_trigger_path(rootdir, basename, start_time, job_id=None, subset_id=None):
"""
Given a basepath, instrument, description, start_time, job_id, will return a
Given a basepath, instrument, description, start_time, will return a
path pointing to a directory structure in the form::
${rootdir}/${basename}/${basename}-${start_time_mod1e5}/
and if the optional job_id, subset_id kwargs are given, the path will be of the form::
${rootdir}/${basename}/${basename}-${start_time_mod1e5}/${basename}-${job_id}-${subset_id}/
"""
start_time_mod1e5 = str(start_time).zfill(10)[:5]
return os.path.join(rootdir, basename, '-'.join([basename, start_time_mod1e5]), '-'.join([basename, job_id, subset_id]))
if job_id and subset_id:
trigger_path = os.path.join(rootdir, basename, '-'.join([basename, start_time_mod1e5]), '-'.join([basename, job_id, subset_id]))
else:
trigger_path = os.path.join(rootdir, basename, '-'.join([basename, start_time_mod1e5]))
return trigger_path
def to_trigger_filename(basename, start_time, duration, suffix, tmp=False):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment