From b4365356f0fba4ff47b6e657d5c2479d92bf55c7 Mon Sep 17 00:00:00 2001
From: Patrick Godwin <patrick.godwin@ligo.org>
Date: Thu, 23 Sep 2021 12:22:25 -0700
Subject: [PATCH] handle config with multiple levels of nesting, add
 injection/segment specific config for inspiral workflows

---
 gstlal-inspiral/python/dags/layers/inspiral.py |  2 --
 gstlal/python/config/__init__.py               | 15 +++++++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gstlal-inspiral/python/dags/layers/inspiral.py b/gstlal-inspiral/python/dags/layers/inspiral.py
index 2a53ef22c3..612e460d4b 100644
--- a/gstlal-inspiral/python/dags/layers/inspiral.py
+++ b/gstlal-inspiral/python/dags/layers/inspiral.py
@@ -213,7 +213,6 @@ def filter_layer(config, dag, ref_psd_cache, svd_bank_cache):
 			Option("gps-start-time", int(start)),
 			Option("gps-end-time", int(end)),
 			Option("channel-name", dagutil.format_ifo_args(ifos, config.source.channel_name)),
-			Option("frame-type", dagutil.format_ifo_args(ifos, config.source.frame_type)),
 		]
 		if config.source.frame_cache:
 			filter_opts.append(Option("frame-cache", config.source.frame_cache, track=False))
@@ -317,7 +316,6 @@ def filter_injections_layer(config, dag, ref_psd_cache, svd_bank_cache):
 			Option("gps-start-time", int(start)),
 			Option("gps-end-time", int(end)),
 			Option("channel-name", dagutil.format_ifo_args(ifos, config.source.channel_name)),
-			Option("frame-type", dagutil.format_ifo_args(ifos, config.source.frame_type)),
 		]
 		if config.source.frame_cache:
 			filter_opts.append(Option("frame-cache", config.source.frame_cache, track=False))
diff --git a/gstlal/python/config/__init__.py b/gstlal/python/config/__init__.py
index 3eb2c60693..adf39f2b60 100644
--- a/gstlal/python/config/__init__.py
+++ b/gstlal/python/config/__init__.py
@@ -92,17 +92,20 @@ class Config:
 			self.data = dotdict(replace_keys(kwargs["data"]))
 		if "frames" in kwargs:
 			self.frames = dotdict(replace_keys(kwargs["frames"]))
+		if "segments" in kwargs:
+			self.segments = dotdict(replace_keys(kwargs["segments"]))
+		if "injections" in kwargs:
+			self.injections = dotdict(replace_keys(kwargs["injections"]))
 
 		# condor options
-		condor_config = replace_keys(kwargs["condor"])
-		self.condor = dotdict(condor_config)
+		self.condor = dotdict(replace_keys(kwargs["condor"]))
 
 		# file transfer installed by default
 		if self.condor.transfer_files is None:
 			self.condor.transfer_files = True
 
 		self.condor.submit = self.create_condor_submit_options(
-			condor_config,
+			self.condor,
 			x509_proxy=self.source.x509_proxy,
 		)
 
@@ -233,4 +236,8 @@ class dotdict(dict):
 
 
 def replace_keys(dict_):
-	return {k.replace("-", "_"): v for k, v in dict_.items()}
+	out = dict(dict_)
+	for k, v in out.items():
+		if isinstance(v, dict):
+			out[k] = replace_keys(v)
+	return {k.replace("-", "_"): v for k, v in out.items()}
-- 
GitLab