Skip to content

Commit

Permalink
Allow passing metadata path to data-prep-cubes
Browse files Browse the repository at this point in the history
  • Loading branch information
aristizabal95 committed Oct 3, 2023
1 parent d904304 commit 28a10ca
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cli/medperf/commands/dataset/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def set_staging_parameters(self):
self.report_path = os.path.join(out_path, config.report_file)
self.out_datapath = os.path.join(out_path, "data")
self.out_labelspath = os.path.join(out_path, "labels")
self.metadata_path = os.path.join(out_path, "metadata")

# Check if labels_path is specified
self.labels_specified = (
Expand All @@ -167,6 +168,10 @@ def set_staging_parameters(self):
self.report_specified = (
self.cube.get_default_output("prepare", "report_file") is not None
)
# Backwards compatibility. Run a cube as before if no metadata is specified
self.metadata_specified = (
self.cube.get_default_output("prepare", "metadata_path") is not None
)
logging.debug(f"tmp data preparation output: {out_path}")
logging.debug(f"tmp data statistics output: {self.out_statistics_path}")

Expand Down Expand Up @@ -211,6 +216,9 @@ def sigint_handler(sig, frame):

observer = Observer()

if self.metadata_specified:
prepare_params["metadata_path"] = self.metadata_path

if self.report_specified:
prepare_params["report_file"] = out_report
metadata = {"execution_status": "started"}
Expand Down Expand Up @@ -293,6 +301,12 @@ def run_sanity_check(self):
# Add the labels parameter
sanity_params["labels_path"] = out_labelspath

if self.metadata_specified:
sanity_params["metadata_path"] = self.metadata_path
sanity_params[
"Ptasks.sanity_check.parameters.input.metadata_paths.opts"
] = "ro"

if self.report_specified:
sanity_params["report_file"] = out_report
sanity_str_params[
Expand Down Expand Up @@ -330,6 +344,12 @@ def run_statistics(self):
"Ptasks.statistics.parameters.input.data_path.opts": "ro"
}

if self.metadata_specified:
statistics_params["metadata_path"] = self.metadata_path
statistics_params[
"Ptasks.statistics.parameters.input.metadata_path.opts"
] = "ro"

self.ui.text = "Generating statistics..."

self.cube.run(
Expand Down

0 comments on commit 28a10ca

Please sign in to comment.