Skip to content

Commit

Permalink
implement path expansion during pipestat configuration check
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Nov 16, 2023
1 parent 2675eef commit e41927c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions looper/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,23 +508,24 @@ def _get_pipestat_configuration(self, sample_name=None, project_level=False):
# We cannot use pipestat without it being defined in the looper config file.
raise ValueError

# Expand paths in the event ENV variables were used in config files
output_dir = expandpath(self.output_dir)

# Get looper user configured items first and update the pipestat_config_dict
try:
results_file_path = pipestat_config_dict["results_file_path"]
results_file_path = expandpath(pipestat_config_dict["results_file_path"])
if not os.path.exists(os.path.dirname(results_file_path)):
results_file_path = os.path.join(
os.path.dirname(self.output_dir), results_file_path
os.path.dirname(output_dir), results_file_path
)
pipestat_config_dict.update({"results_file_path": results_file_path})
except KeyError:
results_file_path = None

try:
flag_file_dir = pipestat_config_dict["flag_file_dir"]
flag_file_dir = expandpath(pipestat_config_dict["flag_file_dir"])
if not os.path.isabs(flag_file_dir):
flag_file_dir = os.path.join(
os.path.dirname(self.output_dir), flag_file_dir
)
flag_file_dir = os.path.join(os.path.dirname(output_dir), flag_file_dir)
pipestat_config_dict.update({"flag_file_dir": flag_file_dir})
except KeyError:
flag_file_dir = None
Expand All @@ -534,7 +535,7 @@ def _get_pipestat_configuration(self, sample_name=None, project_level=False):
{"project_name": pipestat_config_dict["project_name"]}
)

pipestat_config_dict.update({"output_dir": self.output_dir})
pipestat_config_dict.update({"output_dir": output_dir})

pifaces = (
self.project_pipeline_interfaces
Expand All @@ -545,7 +546,8 @@ def _get_pipestat_configuration(self, sample_name=None, project_level=False):
for piface in pifaces:
# We must also obtain additional pipestat items from the pipeline author's piface
if "schema_path" in piface.data:
pipestat_config_dict.update({"schema_path": piface.data["schema_path"]})
schema_path = expandpath(piface.data["schema_path"])
pipestat_config_dict.update({"schema_path": schema_path})
if "pipeline_name" in piface.data:
pipestat_config_dict.update(
{"pipeline_name": piface.data["pipeline_name"]}
Expand All @@ -557,7 +559,7 @@ def _get_pipestat_configuration(self, sample_name=None, project_level=False):

# Pipestat_dict_ is now updated from all sources and can be written to a yaml.
looper_pipestat_config_path = os.path.join(
os.path.dirname(self.output_dir), "looper_pipestat_config.yaml"
os.path.dirname(output_dir), "looper_pipestat_config.yaml"
)
if not os.path.exists(looper_pipestat_config_path):
write_pipestat_config(looper_pipestat_config_path, pipestat_config_dict)
Expand Down

0 comments on commit e41927c

Please sign in to comment.