Repository: gwastro/pycbc

Issue:
Error : time data with pycbc_geom_aligned_bank
I try to create a new template bank with pycbc_geom_aligned_bank which is raising an error :

```
/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py39-testing/bin/pycbc_geom_aligned_bank --pn-order threePointFivePN --f0 10 --f-low 10 --f-upper 80 --delta-f 0.01 --min-match 0.97 --min-mass1 1.0 --min-mass2 1.0 --max-mass1 2.0 --max-mass2 2.0 --min-total-mass 2.0 --max-total-mas 4.0 --max-eta 0.25 --min-eta 0.0 --max-ns-spin-mag 0.05 --psd-model aLIGOZeroDetHighPower --verbose --workflow-name VTBank --intermediate-data-file /home/christopher.allene/halfSNR/80Hz/Template/VTBank/IntermediateBNS40Hz.hdf --metadata-file /home/christopher.allene/halfSNR/80Hz/Template/VTBank/MetaBNS40Hz.xml --output-file /home/christopher.allene/halfSNR/80Hz/Template/VTBank/TemplateBankBNS40Hz.xml --submit-now
Traceback (most recent call last):
  File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py39-testing/bin/pycbc_geom_aligned_bank", line 237, in <module>
    ligolw_process.register_to_xmldoc(outdoc, __program__, vars(opts), comment="",
  File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py39-testing/lib/python3.9/site-packages/ligo/lw/utils/process.py", line 109, in register_to_xmldoc
    process = proctable.RowType.initialized(program = program, process_id = proctable.get_next_id(), **kwargs)
  File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py39-testing/lib/python3.9/site-packages/ligo/lw/lsctables.py", line 562, in initialized
    cvs_entry_time = lal.UTCToGPS(time.strptime(cvs_entry_time, "%Y-%m-%d %H:%M:%S +0000")) if cvs_entry_time is not None else None,
  File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py39-testing/lib/python3.9/_strptime.py", line 562, in _strptime_time
    tt = _strptime(data_string, format)[0]
  File "/cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs/igwn-py39-testing/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '' does not match format '%Y-%m-%d %H:%M:%S +0000'
```




Discussion:
@ChristopherAllene thanks for reporting this. I do not have a lot of time for this at the moment, but we may have to fix `pycbc_geom_aligned_bank` (and related scripts) to work around a recent change in the python-ligo-lw module. We probably want to use [this function](https://github.com/gwastro/pycbc/blob/master/pycbc/io/ligolw.py#L128) instead of calling `register_to_xmldoc()` directly.
I'm not sure it come from ligo-lw. I cloned the igwn-py39-testing environment with ligo-lw 1.7.0 and it failed (same error).
It might come from the pycbc version. On farmn pycbc is ver 1.8.0 against ver 2.0.1 on CIT server and the farmn is working.

Resolving patch:
diff --git a/pycbc/io/ligolw.py b/pycbc/io/ligolw.py
--- a/pycbc/io/ligolw.py
+++ b/pycbc/io/ligolw.py
@@ -126,18 +126,20 @@ def return_search_summary(start_time=0, end_time=0, nevents=0, ifos=None):
     return search_summary
 
 def create_process_table(document, program_name=None, detectors=None,
-                         comment=None):
+                         comment=None, options=None):
     """Create a LIGOLW process table with sane defaults, add it to a LIGOLW
     document, and return it.
     """
     if program_name is None:
         program_name = os.path.basename(sys.argv[0])
+    if options is None:
+        options = {}
 
     # ligo.lw does not like `cvs_entry_time` being an empty string
     cvs_entry_time = pycbc_version.date or None
 
     process = ligolw_process.register_to_xmldoc(
-            document, program_name, {}, version=pycbc_version.version,
+            document, program_name, options, version=pycbc_version.version,
             cvs_repository='pycbc/'+pycbc_version.git_branch,
             cvs_entry_time=cvs_entry_time, instruments=detectors,
             comment=comment)
diff --git a/pycbc/tmpltbank/bank_output_utils.py b/pycbc/tmpltbank/bank_output_utils.py
--- a/pycbc/tmpltbank/bank_output_utils.py
+++ b/pycbc/tmpltbank/bank_output_utils.py
@@ -1,10 +1,11 @@
 import numpy
 from lal import PI, MTSUN_SI, TWOPI, GAMMA
 from ligo.lw import ligolw, lsctables, utils as ligolw_utils
-from ligo.lw.utils import process as ligolw_process
 from pycbc import pnutils
 from pycbc.tmpltbank.lambda_mapping import ethinca_order_from_string
-from pycbc.io.ligolw import return_empty_sngl, return_search_summary
+from pycbc.io.ligolw import (
+    return_empty_sngl, return_search_summary, create_process_table
+)
 
 
 def convert_to_sngl_inspiral_table(params, proc_id):
@@ -199,10 +200,10 @@ def calculate_ethinca_metric_comps(metricParams, ethincaParams, mass1, mass2,
 
 def output_sngl_inspiral_table(outputFile, tempBank, metricParams,
                                ethincaParams, programName="", optDict = None,
-                               outdoc=None, **kwargs):
+                               outdoc=None):
     """
-    Function that converts the information produced by the various pyCBC bank
-    generation codes into a valid LIGOLW xml file containing a sngl_inspiral
+    Function that converts the information produced by the various PyCBC bank
+    generation codes into a valid LIGOLW XML file containing a sngl_inspiral
     table and outputs to file.
 
     Parameters
@@ -228,9 +229,6 @@ def output_sngl_inspiral_table(outputFile, tempBank, metricParams,
     outdoc (key-word argument) : ligolw xml document
         If given add template bank to this representation of a xml document and
         write to disk. If not given create a new document.
-    kwargs : key-word arguments
-        All other key word arguments will be passed directly to
-        ligolw_process.register_to_xmldoc
     """
     if optDict is None:
         optDict = {}
@@ -244,9 +242,13 @@ def output_sngl_inspiral_table(outputFile, tempBank, metricParams,
         if optDict['channel_name'] is not None:
             ifos = [optDict['channel_name'][0:2]]
 
-    proc_id = ligolw_process.register_to_xmldoc(
-            outdoc, programName, optDict,
-            instruments=ifos, **kwargs).process_id
+    proc = create_process_table(
+        outdoc,
+        program_name=programName,
+        detectors=ifos,
+        options=optDict
+    )
+    proc_id = proc.process_id
     sngl_inspiral_table = convert_to_sngl_inspiral_table(tempBank, proc_id)
     # Calculate Gamma components if needed
     if ethincaParams is not None:


Test patch:
diff --git a/tools/pycbc_test_suite.sh b/tools/pycbc_test_suite.sh
--- a/tools/pycbc_test_suite.sh
+++ b/tools/pycbc_test_suite.sh
@@ -60,6 +60,18 @@ if [ "$PYCBC_TEST_TYPE" = "search" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
     fi
     popd
 
+    # run a quick bank placement example
+    pushd examples/tmpltbank
+    bash -e testNonspin2.sh
+    if test $? -ne 0 ; then
+        RESULT=1
+        echo -e "    FAILED!"
+        echo -e "---------------------------------------------------------"
+    else
+        echo -e "    Pass."
+    fi
+    popd
+
     # run PyCBC Live test
     if ((${PYTHON_MINOR_VERSION} > 7)); then
       # ligo.skymap is only supporting python3.8+, and older releases are