Skip to content

Commit

Permalink
fall back to default pipestat schema if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
stolarczyk committed May 11, 2021
1 parent 76cc53e commit 3bb0da2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pypiper/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
make_lock_name,
parse_cmd,
pipeline_filepath,
default_pipestat_schema,
)

__all__ = ["PipelineManager"]
Expand Down Expand Up @@ -322,6 +323,7 @@ def __init__(

# pipesatat setup
potential_namespace = getattr(self, "sample_name", self.name)
potential_pipestat_schema = default_pipestat_schema(sys.argv[0])

# don't force default pipestat_results_file value unless
# pipestat config not provided
Expand All @@ -332,7 +334,7 @@ def __init__(
self._pipestat_manager = PipestatManager(
namespace=pipestat_namespace or potential_namespace,
record_identifier=pipestat_record_id or potential_namespace,
schema_path=pipestat_schema,
schema_path=pipestat_schema or potential_pipestat_schema,
results_file_path=pipestat_results_file,
config=pipestat_config,
)
Expand Down
14 changes: 14 additions & 0 deletions pypiper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,20 @@ def default_pipeline_config(pipeline_filepath):
return os.path.splitext(os.path.basename(pipeline_filepath))[0] + ".yaml"


def default_pipestat_schema(pipeline_filepath):
"""
Determine the default filepath for a pipeline's pipestat output schema.
:param str pipeline_filepath: path to a pipeline
:return str: default filepath for a pipeline's pipestat output schema.
"""
pipestat_results_schema = os.path.join(
os.path.dirname(pipeline_filepath), "pipestat_results_schema.yaml"
)
print(f"Using default schema: {pipestat_results_schema}")
return pipestat_results_schema if os.path.exists(pipestat_results_schema) else None


def _add_args(parser, args, required):
"""
Add new arguments to an ArgumentParser.
Expand Down

0 comments on commit 3bb0da2

Please sign in to comment.