Repository: gwastro/pycbc

Issue:
Workflow generators should produce an XML file with a process and process_params table
The workflow generators store their state in the parsed ini files, but for bookkeeping purposes, it will be useful to know exactly how they were invoked. They should create a LIGO_LW XML file with a process and process_params table containing the appropriate metadata. This should also be displayed in the configuration section of the summary pages.

We should definitely do this for the coinc_search and psd_estimation workflows for 1.2.0, but it should be added to the GRB workflow eventually as well.



Discussion:
There is a module that already does this:

https://github.com/ligo-cbc/pycbc/blob/master/bin/pycbc_make_coinc_pipedown_workflow#L178

Not sure this was ever put into the HDF5 workflow.

@spxiwh thanks, I'll use this when I get to work on Sunday, unless @ahnitz or you get to it first.

@spxiwh I didn't get to this today. Any chance you can take a look Monday morning?


Resolving patch:
diff --git a/pycbc/workflow/analysislogging.py b/pycbc/workflow/analysislogging.py
--- a/pycbc/workflow/analysislogging.py
+++ b/pycbc/workflow/analysislogging.py
@@ -102,9 +102,12 @@ def setup_analysislogging(workflow, segs_list, insps, args, output_dir,
             segmentdb_utils.add_to_segment_summary(outdoc, proc_id, sci_def_id,
                                                          summ_segs, comment='')
         elif sci_seg_file:
-            err_msg = "Got %d files matching %s and %s. Expected 1 or 0." \
-                      %(len(sci_seg_file), ifo, 'SCIENCE')
-            raise ValueError(err_msg)
+            # FIXME: While the segment module is still fractured (#127) this
+            #        may not work. Please update when #127 is resolved
+            pass
+            #err_msg = "Got %d files matching %s and %s. Expected 1 or 0." \
+            #          %(len(sci_seg_file), ifo, 'SCIENCE')
+            #raise ValueError(err_msg)
 
         # SCIENCE_OK
         sci_ok_seg_file = seg_ifo_files.find_output_with_tag('SCIENCE_OK')
@@ -118,9 +121,12 @@ def setup_analysislogging(workflow, segs_list, insps, args, output_dir,
             segmentdb_utils.add_to_segment_summary(outdoc, proc_id,
                                           sci_ok_def_id, summ_segs, comment='')
         elif sci_ok_seg_file:
-            err_msg = "Got %d files matching %s and %s. Expected 1 or 0." \
-                      %(len(sci_ok_seg_file), ifo, 'SCIENCE_OK')
-            raise ValueError(err_msg)
+            # FIXME: While the segment module is still fractured (#127) this
+            #        may not work. Please update when #127 is resolved
+            pass
+            #err_msg = "Got %d files matching %s and %s. Expected 1 or 0." \
+            #          %(len(sci_ok_seg_file), ifo, 'SCIENCE_OK')
+            #raise ValueError(err_msg)
 
 
         # SCIENCE_AVAILABLE
@@ -136,9 +142,12 @@ def setup_analysislogging(workflow, segs_list, insps, args, output_dir,
             segmentdb_utils.add_to_segment_summary(outdoc, proc_id,
                                    sci_available_def_id, summ_segs, comment='')
         elif sci_available_seg_file:
-            err_msg = "Got %d files matching %s and %s. Expected 1 or 0." \
-                      %(len(sci_available_seg_file), ifo, 'SCIENCE_AVAILABLE')
-            raise ValueError(err_msg)
+            # FIXME: While the segment module is still fractured (#127) this
+            #        may not work. Please update when #127 is resolved
+            pass
+            #err_msg = "Got %d files matching %s and %s. Expected 1 or 0." \
+            #          %(len(sci_available_seg_file), ifo, 'SCIENCE_AVAILABLE')
+            #raise ValueError(err_msg)
 
         # ANALYSABLE - This one needs to come from inspiral outs
         ifo_insps = insps.find_output_with_ifo(ifo)
diff --git a/pycbc/workflow/segment.py b/pycbc/workflow/segment.py
--- a/pycbc/workflow/segment.py
+++ b/pycbc/workflow/segment.py
@@ -1122,9 +1122,15 @@ def get_analyzable_segments(workflow, out_dir, tags=[]):
             sci_segs[ifo] -= cat_segs
             
         sci_segs[ifo].coalesce()
-        seg_ok_path = os.path.abspath(os.path.join(out_dir, '%s-SCIENCE-OK.xml' % ifo))
-        seg_files += [segments_to_file(sci_segs[ifo], seg_ok_path, 
-                                          "SCIENCE_OK", ifo=ifo)]  
+        seg_ok_path = os.path.abspath(os.path.join(out_dir,
+                                                   '%s-SCIENCE-OK.xml' % ifo))
+        curr_url = urlparse.urlunparse(['file', 'localhost', seg_ok_path,
+                          None, None, None])
+        curr_file = OutSegFile(ifo, 'SCIENCE_OK', workflow.analysis_time,
+                               curr_url, segment_list=sci_segs[ifo],
+                               tags=tags)
+        curr_file.toSegmentXml()
+        seg_files += [curr_file]
 
     if segments_method == 'ALL_SINGLE_IFO_TIME':
         pass


Test patch: