From 6b70ba95bfb89cb76c4f061127ae59ec5d86b6ae Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 17 Sep 2024 15:57:29 -0700 Subject: [PATCH 1/3] v0 --- nominal/core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nominal/core.py b/nominal/core.py index d36414e3..e11ec4e6 100644 --- a/nominal/core.py +++ b/nominal/core.py @@ -80,6 +80,23 @@ def add_dataset(self, ref_name: str, dataset: Dataset | str) -> None: } self._client._run_client.add_data_sources_to_run(self._client._auth_header, data_sources, self.rid) + def add_datasets(self, datasets: dict[str, Dataset | str]) -> None: + """Add multiple datasets to this run. + + Datasets map "ref names" (their name within the run) to a Dataset (or dataset rid). The same type of datasets + should use the same ref name across runs, since checklists and templates use ref names to reference datasets. + """ + # TODO(alkasm): support series tags & offset + data_sources = { + ref_name: scout_run_api.CreateRunDataSource( + data_source=scout_run_api.DataSource(dataset=_rid_from_instance_or_string(dataset)), + series_tags={}, + offset=None, + ) + for ref_name, dataset in datasets.items() + } + self._client._run_client.add_data_sources_to_run(self._client._auth_header, data_sources, self.rid) + def _iter_list_datasets(self) -> Iterable[tuple[str, Dataset]]: run = self._client._run_client.get_run(self._client._auth_header, self.rid) dataset_rids_by_ref_name = {} From dc1552f486ad93d2c52aed1654ae6f4297338c67 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 17 Sep 2024 16:01:00 -0700 Subject: [PATCH 2/3] one call other --- nominal/core.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/nominal/core.py b/nominal/core.py index e11ec4e6..ae68d01d 100644 --- a/nominal/core.py +++ b/nominal/core.py @@ -70,15 +70,7 @@ def add_dataset(self, ref_name: str, dataset: Dataset | str) -> None: Datasets map "ref names" (their name within the run) to a Dataset (or dataset rid). The same type of datasets should use the same ref name across runs, since checklists and templates use ref names to reference datasets. """ - # TODO(alkasm): support series tags & offset - data_sources = { - ref_name: scout_run_api.CreateRunDataSource( - data_source=scout_run_api.DataSource(dataset=_rid_from_instance_or_string(dataset)), - series_tags={}, - offset=None, - ) - } - self._client._run_client.add_data_sources_to_run(self._client._auth_header, data_sources, self.rid) + self.add_datasets({ref_name: dataset}) def add_datasets(self, datasets: dict[str, Dataset | str]) -> None: """Add multiple datasets to this run. From 1c6f8ba663e5de54b0351589a06f0768917e903f Mon Sep 17 00:00:00 2001 From: ross-barrett Date: Tue, 17 Sep 2024 16:04:40 -0700 Subject: [PATCH 3/3] Update nominal/core.py mapping Co-authored-by: Alexander Reynolds --- nominal/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nominal/core.py b/nominal/core.py index ae68d01d..956db998 100644 --- a/nominal/core.py +++ b/nominal/core.py @@ -72,7 +72,7 @@ def add_dataset(self, ref_name: str, dataset: Dataset | str) -> None: """ self.add_datasets({ref_name: dataset}) - def add_datasets(self, datasets: dict[str, Dataset | str]) -> None: + def add_datasets(self, datasets: Mapping[str, Dataset | str]) -> None: """Add multiple datasets to this run. Datasets map "ref names" (their name within the run) to a Dataset (or dataset rid). The same type of datasets