Skip to content

Commit 15c302b

Browse files
committed
add run for demo
1 parent c674c82 commit 15c302b

1 file changed

Lines changed: 15 additions & 79 deletions

File tree

  • python/lib/sift_client/_internal/low_level_wrappers

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

Lines changed: 15 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ def __init__(self, grpc_client: GrpcClient):
4242
super().__init__(grpc_client)
4343

4444
async def get_run(
45-
self,
45+
self,
4646
run_id: str,
4747
*,
48-
use_cache: bool = True,
4948
force_refresh: bool = False,
50-
ttl: int | None = None,
5149
) -> Run:
5250
"""Get a run by run_id.
5351
@@ -63,12 +61,11 @@ async def get_run(
6361
"""
6462
request = GetRunRequest(run_id=run_id)
6563
stub = self._grpc_client.get_stub(RunServiceStub)
66-
response = await self._call_with_cache(
64+
response = await self.call_with_cache(
6765
stub.GetRun,
6866
request,
69-
use_cache=use_cache,
67+
use_cache=self._grpc_client.has_cache,
7068
force_refresh=force_refresh,
71-
ttl=ttl,
7269
)
7370
grpc_run = cast("GetRunResponse", response).run
7471
return Run._from_proto(grpc_run)
@@ -80,9 +77,7 @@ async def list_runs(
8077
page_token: str | None = None,
8178
query_filter: str | None = None,
8279
order_by: str | None = None,
83-
use_cache: bool = True,
8480
force_refresh: bool = False,
85-
ttl: int | None = None,
8681
) -> tuple[list[Run], str]:
8782
"""List runs with optional filtering and pagination.
8883
@@ -107,12 +102,11 @@ async def list_runs(
107102

108103
request = ListRunsRequest(**request_kwargs)
109104
stub = self._grpc_client.get_stub(RunServiceStub)
110-
response = await self._call_with_cache(
105+
response = await self.call_with_cache(
111106
stub.ListRuns,
112107
request,
113-
use_cache=use_cache,
108+
use_cache=self._grpc_client.has_cache,
114109
force_refresh=force_refresh,
115-
ttl=ttl,
116110
)
117111
response = cast("ListRunsResponse", response)
118112

@@ -125,9 +119,7 @@ async def list_all_runs(
125119
query_filter: str | None = None,
126120
order_by: str | None = None,
127121
max_results: int | None = None,
128-
use_cache: bool = True,
129122
force_refresh: bool = False,
130-
ttl: int | None = None,
131123
) -> list[Run]:
132124
"""List all runs with optional filtering.
133125
@@ -144,64 +136,27 @@ async def list_all_runs(
144136
**k,
145137
query_filter=query_filter,
146138
order_by=order_by,
147-
use_cache=use_cache,
148139
force_refresh=force_refresh,
149-
ttl=ttl,
150140
),
151141
kwargs={},
152142
order_by=order_by,
153143
max_results=max_results,
154144
)
155145

156-
async def create_run(
157-
self,
158-
*,
159-
create: RunCreate,
160-
use_cache: bool = False, # Default to False for write operations
161-
force_refresh: bool = False,
162-
ttl: int | None = None,
163-
) -> Run:
146+
async def create_run(self, *, create: RunCreate) -> Run:
164147
request_proto = create.to_proto()
165-
stub = self._grpc_client.get_stub(RunServiceStub)
166-
response = await self._call_with_cache(
167-
stub.CreateRun,
168-
request_proto,
169-
use_cache=use_cache,
170-
force_refresh=force_refresh,
171-
ttl=ttl,
172-
)
148+
response = await self._grpc_client.get_stub(RunServiceStub).CreateRun(request_proto)
173149
grpc_run = cast("CreateRunResponse", response).run
174150
return Run._from_proto(grpc_run)
175151

176-
async def update_run(
177-
self,
178-
update: RunUpdate,
179-
*,
180-
use_cache: bool = False, # Default to False for write operations
181-
force_refresh: bool = False,
182-
ttl: int | None = None,
183-
) -> Run:
152+
async def update_run(self, update: RunUpdate) -> Run:
184153
grpc_run, update_mask = update.to_proto_with_mask()
185154
request = UpdateRunRequest(run=grpc_run, update_mask=update_mask)
186-
stub = self._grpc_client.get_stub(RunServiceStub)
187-
response = await self._call_with_cache(
188-
stub.UpdateRun,
189-
request,
190-
use_cache=use_cache,
191-
force_refresh=force_refresh,
192-
ttl=ttl,
193-
)
155+
response = await self._grpc_client.get_stub(RunServiceStub).UpdateRun(request)
194156
updated_grpc_run = cast("UpdateRunResponse", response).run
195157
return Run._from_proto(updated_grpc_run)
196158

197-
async def stop_run(
198-
self,
199-
run_id: str,
200-
*,
201-
use_cache: bool = False, # Default to False for write operations
202-
force_refresh: bool = False,
203-
ttl: int | None = None,
204-
) -> None:
159+
async def stop_run(self, run_id: str) -> None:
205160
"""Stop a run by setting its stop time to the current time.
206161
207162
Args:
@@ -214,23 +169,10 @@ async def stop_run(
214169
raise ValueError("run_id must be provided")
215170

216171
request = StopRunRequest(run_id=run_id)
217-
stub = self._grpc_client.get_stub(RunServiceStub)
218-
await self._call_with_cache(
219-
stub.StopRun,
220-
request,
221-
use_cache=use_cache,
222-
force_refresh=force_refresh,
223-
ttl=ttl,
224-
)
172+
await self._grpc_client.get_stub(RunServiceStub).StopRun(request)
225173

226174
async def create_automatic_run_association_for_assets(
227-
self,
228-
run_id: str,
229-
asset_names: list[str],
230-
*,
231-
use_cache: bool = False, # Default to False for write operations
232-
force_refresh: bool = False,
233-
ttl: int | None = None,
175+
self, run_id: str, asset_names: list[str]
234176
) -> None:
235177
"""Associate assets with a run for automatic data ingestion.
236178
@@ -247,14 +189,8 @@ async def create_automatic_run_association_for_assets(
247189
raise ValueError("asset_names must be provided")
248190

249191
request = CreateAutomaticRunAssociationForAssetsRequest(
250-
run_id=run_id,
251-
asset_names=asset_names
192+
run_id=run_id, asset_names=asset_names
252193
)
253-
stub = self._grpc_client.get_stub(RunServiceStub)
254-
await self._call_with_cache(
255-
stub.CreateAutomaticRunAssociationForAssets,
256-
request,
257-
use_cache=use_cache,
258-
force_refresh=force_refresh,
259-
ttl=ttl,
194+
await self._grpc_client.get_stub(RunServiceStub).CreateAutomaticRunAssociationForAssets(
195+
request
260196
)

0 commit comments

Comments
 (0)