Skip to content

Commit 9dd0548

Browse files
authored
Merge pull request #608 from atlanhq/APP-5600
APP-5600: Added pagination params `from_` and `size` to `find_runs_by_status_and_time_range`
2 parents 732b23b + 439380f commit 9dd0548

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

pyatlan/client/workflow.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,22 @@ def find_runs_by_status_and_time_range(
165165
status: List[AtlanWorkflowPhase],
166166
started_at: Optional[str] = None,
167167
finished_at: Optional[str] = None,
168+
from_: int = 0,
169+
size: int = 100,
168170
) -> List[WorkflowSearchResult]:
169171
"""
170-
Find workflows by status and optional time filters on startedAt and/or finishedAt.
172+
Find workflows based on their status and interval
171173
172174
:param status: list of the workflow statuses to filter
173175
:param started_at: (optional) lower bound on 'status.startedAt' (e.g 'now-2h')
174176
:param finished_at: (optional) lower bound on 'status.finishedAt' (e.g 'now-1h')
177+
:param from_:(optional) starting index of the search results (default: `0`).
178+
:param size: (optional) maximum number of search results to return (default: `100`).
175179
:returns: list of workflows matching the filters
176180
:raises ValidationError: if inputs are invalid
177181
:raises AtlanError: on any API communication issue
178182
"""
179183
time_filters = []
180-
181184
if started_at:
182185
time_filters.append(Range(field="status.startedAt", gte=started_at))
183186
if finished_at:
@@ -199,9 +202,9 @@ def find_runs_by_status_and_time_range(
199202
),
200203
],
201204
)
202-
203-
run_lookup_results = self._find_runs(run_lookup_query)
204-
205+
run_lookup_results = self._find_runs(
206+
query=run_lookup_query, from_=from_, size=size
207+
)
205208
return run_lookup_results.hits and run_lookup_results.hits.hits or []
206209

207210
@validate_arguments

pyatlan/model/search.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,8 +2017,11 @@ class IndexSearchRequest(SearchRequest):
20172017
)
20182018

20192019
class Metadata(AtlanObject):
2020+
# Set this to `False` to prevent the frequent
2021+
# Out of memory (OOM) issue in Metastore pods.
20202022
save_search_log: bool = Field(
2021-
default=True, description="Whether to log this search (True) or not (False)"
2023+
default=False,
2024+
description="Whether to log this search (True) or not (False)",
20222025
)
20232026
utm_tags: List[str] = Field(
20242027
default_factory=list,

tests/unit/test_workflow_client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,14 @@ def test_find_runs_by_status_and_time_range(client: WorkflowClient, mock_api_cal
281281
finished_at = "now-1h"
282282

283283
assert (
284-
client.find_runs_by_status_and_time_range(status, started_at, finished_at) == []
284+
client.find_runs_by_status_and_time_range(
285+
status=status,
286+
started_at=started_at,
287+
finished_at=finished_at,
288+
from_=10,
289+
size=5,
290+
)
291+
== []
285292
)
286293
mock_api_caller._call_api.assert_called_once()
287294
assert isinstance(

0 commit comments

Comments
 (0)