Skip to content

Commit a46cc2a

Browse files
committed
update run archive/unarchive
1 parent 5a527dd commit a46cc2a

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

  • python/lib/sift_client

python/lib/sift_client/_internal/low_level_wrappers/runs.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from sift.runs.v2.runs_pb2 import (
77
CreateAutomaticRunAssociationForAssetsRequest,
88
CreateRunResponse,
9-
DeleteRunRequest,
109
GetRunRequest,
1110
GetRunResponse,
1211
ListRunsRequest,
@@ -54,9 +53,6 @@ async def get_run(self, run_id: str) -> Run:
5453
Raises:
5554
ValueError: If run_id is not provided.
5655
"""
57-
if not run_id:
58-
raise ValueError("run_id must be provided")
59-
6056
request = GetRunRequest(run_id=run_id)
6157
response = await self._grpc_client.get_stub(RunServiceStub).GetRun(request)
6258
grpc_run = cast("GetRunResponse", response).run
@@ -135,21 +131,6 @@ async def update_run(self, update: RunUpdate) -> Run:
135131
updated_grpc_run = cast("UpdateRunResponse", response).run
136132
return Run._from_proto(updated_grpc_run)
137133

138-
async def archive_run(self, run_id: str) -> None:
139-
"""Archive a run.
140-
141-
Args:
142-
run_id: The ID of the run to archive.
143-
144-
Raises:
145-
ValueError: If run_id is not provided.
146-
"""
147-
if not run_id:
148-
raise ValueError("run_id must be provided")
149-
150-
request = DeleteRunRequest(run_id=run_id)
151-
await self._grpc_client.get_stub(RunServiceStub).DeleteRun(request)
152-
153134
async def stop_run(self, run_id: str) -> None:
154135
"""Stop a run by setting its stop time to the current time.
155136

python/lib/sift_client/resources/runs.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ async def list_(
147147
filter_parts.append(cel.in_("client_key", client_keys))
148148
if assets:
149149
if all(isinstance(s, str) for s in assets):
150-
ids = cast("list[str]", assets)
150+
ids = cast("list[str]", assets) # linting
151151
filter_parts.append(cel.in_("asset_ids", ids))
152152
else:
153-
asset = cast("list[Asset]", assets)
153+
asset = cast("list[Asset]", assets) # linting
154154
filter_parts.append(cel.in_("asset_ids", [a._id_or_error for a in asset]))
155155
if duration_less_than:
156156
filter_parts.append(cel.less_than("duration_string", duration_less_than))
@@ -230,16 +230,25 @@ async def update(self, run: str | Run, update: RunUpdate | dict) -> Run:
230230
async def archive(
231231
self,
232232
run: str | Run,
233-
) -> None:
233+
) -> Run:
234234
"""Archive a run.
235235
236236
Args:
237237
run: The Run or run ID to archive.
238238
"""
239-
run_id = run._id_or_error if isinstance(run, Run) else run
240-
await self._low_level_client.archive_run(run_id=run_id)
239+
return await self.update(run, RunUpdate(is_archived=True))
240+
241+
async def unarchive(
242+
self,
243+
run: str | Run,
244+
) -> Run:
245+
"""Unarchive a run.
246+
247+
Args:
248+
run: The Run or run ID to unarchive.
249+
"""
250+
return await self.update(run, RunUpdate(is_archived=False))
241251

242-
# TODO: unarchive
243252

244253
async def stop(
245254
self,

0 commit comments

Comments
 (0)