Skip to content

Commit

Permalink
Add method to reset start & end boundaries on a run
Browse files Browse the repository at this point in the history
  • Loading branch information
drake-nominal committed Oct 29, 2024
1 parent adcab95 commit 9bde0f6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nominal/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ def update(
update_dataclass(self, run, fields=self.__dataclass_fields__)
return self

def reset_bounds(self) -> Self:
"""Update the start and end timestamps on the run by inspecting the bounds on
the datasets that compose this run.
This is primarily useful when the set of datasets composing the run change, or
the individual datasets get modified to have more or less data.
"""
datasets = self.list_datasets()

dataset_starts = [dataset.bounds.start for _, dataset in datasets if dataset.bounds]
dataset_ends = [dataset.bounds.end for _, dataset in datasets if dataset.bounds]

# If there are not yet any datasets with bounds in the run, there is nothing to reset
if not dataset_starts or not dataset_ends:
return self

return self.update(start=min(dataset_starts), end=max(dataset_ends))

@classmethod
def _from_conjure(cls, clients: _Clients, run: scout_run_api.Run) -> Self:
return cls(
Expand Down

0 comments on commit 9bde0f6

Please sign in to comment.