Skip to content

Commit 45519d9

Browse files
authored
Fix type hint in _make_fileserver_request (#156)
* Fix type hint in _make_fileserver_request * Fix type hint in _make_fileserver_request * Add get_variables flag to get_agent_run * Add get_variables flag to get_agent_run
1 parent 4d42db7 commit 45519d9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cradl"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
description = "Python SDK for Cradl"
55
authors = [{ name = "Cradl", email = "[email protected]" }]
66
readme = "README.md"

src/cradl/client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _make_fileserver_request(
8686
file_url: str,
8787
content: Optional[bytes] = None,
8888
query_params: Optional[dict] = None,
89-
) -> Dict:
89+
) -> bytes:
9090
if not content and requests_fn == requests.put:
9191
raise EmptyRequestError
9292

@@ -2833,7 +2833,7 @@ def list_agent_runs(
28332833
})
28342834
return self._make_request(requests.get, f'/agents/{agent_id}/runs', params=params)
28352835

2836-
def get_agent_run(self, agent_id: str, run_id: str) -> Dict:
2836+
def get_agent_run(self, agent_id: str, run_id: str, *, get_variables: bool = False) -> Dict:
28372837
"""Get agent, calls the GET /agents/{agentId}/runs/{runId} endpoint.
28382838
28392839
:param agent_id: Id of the agent
@@ -2846,7 +2846,14 @@ def get_agent_run(self, agent_id: str, run_id: str) -> Dict:
28462846
:raises: :py:class:`~cradl.InvalidCredentialsException`, :py:class:`~cradl.TooManyRequestsException`,\
28472847
:py:class:`~cradl.LimitExceededException`, :py:class:`requests.exception.RequestException`
28482848
"""
2849-
return self._make_request(requests.get, f'/agents/{agent_id}/runs/{run_id}')
2849+
agent_run = self._make_request(requests.get, f'/agents/{agent_id}/runs/{run_id}')
2850+
if get_variables and agent_run.get('variablesFileUrl'):
2851+
agent_run['variables'] = json.loads(self._make_fileserver_request(
2852+
requests_fn=requests.get,
2853+
file_url=agent_run['variablesFileUrl'],
2854+
query_params={},
2855+
).decode())
2856+
return agent_run
28502857

28512858
def list_hooks(self, *, max_results: Optional[int] = None, next_token: Optional[str] = None) -> Dict:
28522859
"""List hooks available, calls the GET /hooks endpoint.

0 commit comments

Comments
 (0)