Skip to content

Commit ab675c5

Browse files
committed
Add comments
1 parent 12bd298 commit ab675c5

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

databricks/sdk/mixins/jobs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ def get_run(self,
3232
include_resolved_values=include_resolved_values,
3333
page_token=page_token)
3434

35-
isPaginatingIterations = run.iterations is not None and len(run.iterations) > 0
35+
# When querying a Job run, a page token is returned when there are more than 100 tasks. No iterations are defined for a Job run. Therefore, the next page in the response only includes the next page of tasks.
36+
# When querying a ForEach task run, a page token is returned when there are more than 100 iterations. Only a single task is returned, corresponding to the ForEach task itself. Therefore, the client only reads the iterations from the next page and not the tasks.
37+
is_paginating_iterations = run.iterations is not None and len(run.iterations) > 0
3638

3739
while run.next_page_token is not None:
3840
next_run = super().get_run(run_id,
3941
include_history=include_history,
4042
include_resolved_values=include_resolved_values,
4143
page_token=run.next_page_token)
42-
if isPaginatingIterations:
44+
if is_paginating_iterations:
4345
run.iterations.extend(next_run.iterations)
4446
else:
4547
run.tasks.extend(next_run.tasks)

tests/test_jobs_mixin.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,13 @@ def make_path_pattern(run_id: int, page_token: str) -> Pattern[str]:
1212

1313

1414
def test_get_run_with_no_pagination(config, requests_mock):
15-
run1 = {
16-
"tasks": [{
17-
"run_id": 0
18-
}, {
19-
"run_id": 1
20-
}],
21-
}
15+
run1 = {"tasks": [{"run_id": 0}, {"run_id": 1}], }
2216
requests_mock.get(make_path_pattern(1337, "initialToken"), text=json.dumps(run1))
2317
w = WorkspaceClient(config=config)
2418

2519
run = w.jobs.get_run(1337, page_token="initialToken")
2620

27-
assert run.as_dict() == {
28-
"tasks": [{
29-
'run_id': 0
30-
}, {
31-
'run_id': 1
32-
}],
33-
}
21+
assert run.as_dict() == {"tasks": [{'run_id': 0}, {'run_id': 1}], }
3422

3523

3624
def test_get_run_pagination_with_tasks(config, requests_mock):

0 commit comments

Comments
 (0)