From fda220b447a4caca5bc14252641497d096fcb737 Mon Sep 17 00:00:00 2001
From: Patrick Godwin <patrick.godwin@ligo.org>
Date: Thu, 29 Nov 2018 16:14:36 -0800
Subject: [PATCH] utils.py: make job_id, subset_id optional, reflected in
 online hdf5 sink

---
 gstlal-burst/bin/gstlal_feature_hdf5_sink        |  6 ++----
 gstlal-burst/python/fxtools/feature_extractor.py |  4 ++--
 gstlal-burst/python/fxtools/utils.py             | 14 +++++++++++---
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gstlal-burst/bin/gstlal_feature_hdf5_sink b/gstlal-burst/bin/gstlal_feature_hdf5_sink
index 6cfb130c61..4fc4a8bcae 100755
--- a/gstlal-burst/bin/gstlal_feature_hdf5_sink
+++ b/gstlal-burst/bin/gstlal_feature_hdf5_sink
@@ -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)
diff --git a/gstlal-burst/python/fxtools/feature_extractor.py b/gstlal-burst/python/fxtools/feature_extractor.py
index 54e4d8f165..dd7718a48d 100644
--- a/gstlal-burst/python/fxtools/feature_extractor.py
+++ b/gstlal-burst/python/fxtools/feature_extractor.py
@@ -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)
diff --git a/gstlal-burst/python/fxtools/utils.py b/gstlal-burst/python/fxtools/utils.py
index d0db9f6809..82802a8e8b 100644
--- a/gstlal-burst/python/fxtools/utils.py
+++ b/gstlal-burst/python/fxtools/utils.py
@@ -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):
 	"""
-- 
GitLab