Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not terminate listing for token-based pagination resources on empty response #530

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Feb 6, 2024

Changes

It is allowed for list APIs to return less than the number of resources in the page_size limit in a response. In case no items are returned but there are still items to list, we should continue to list resources until no next_page_token is included in the response. This matches the logic from the Go SDK: https://github.com/databricks/databricks-sdk-go/blob/main/.codegen/api.go.tmpl#L275-L294

Tests

  • Nightly tests pass.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

Attention: 149 lines in your changes are missing coverage. Please review.

Comparison is base (e290be9) 57.78% compared to head (3685fde) 57.83%.
Report is 1 commits behind head on main.

Files Patch % Lines
databricks/sdk/service/iam.py 0.00% 42 Missing ⚠️
databricks/sdk/service/ml.py 0.00% 27 Missing ⚠️
databricks/sdk/service/catalog.py 0.00% 24 Missing ⚠️
databricks/sdk/service/sql.py 0.00% 17 Missing ⚠️
databricks/sdk/service/compute.py 0.00% 6 Missing ⚠️
databricks/sdk/service/jobs.py 0.00% 6 Missing ⚠️
databricks/sdk/service/pipelines.py 0.00% 6 Missing ⚠️
databricks/sdk/service/settings.py 0.00% 6 Missing ⚠️
databricks/sdk/service/vectorsearch.py 0.00% 6 Missing ⚠️
databricks/sdk/service/oauth2.py 0.00% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #530      +/-   ##
==========================================
+ Coverage   57.78%   57.83%   +0.04%     
==========================================
  Files          43       43              
  Lines       27614    27591      -23     
==========================================
  Hits        15957    15957              
+ Misses      11657    11634      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

{{end -}}
yield {{.Pagination.Entity.PascalName}}.from_dict(v)
{{ if .Pagination.Token -}}
if '{{.Pagination.Token.Bind.Name}}' not in json or not json['{{.Pagination.Token.Bind.Name}}']:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly reordered but designed to match the Go SDK pagination logic exactly.

@mgyucht mgyucht requested a review from tanmay-db February 8, 2024 10:34
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mgyucht mgyucht added this pull request to the merge queue Feb 8, 2024
Merged via the queue into main with commit c20bbff Feb 8, 2024
9 checks passed
@mgyucht mgyucht deleted the deco-9805 branch February 8, 2024 11:11
tanmay-db added a commit that referenced this pull request Feb 8, 2024
* Make docs useful again ([#519](#519)).
* Show undocumented fields in dataclasses ([#520](#520)).
* Search for both databricks.exe and databricks binaries in windows ([#517](#517)).
* Rename `databricks.sdk.errors.mapping` to `databricks.sdk.errors.platform` ([#522](#522)).
* refactor: add Union to content (2nd) parameter in upload function ([#493](#493)).
* Regenerate from the tip of main ([#524](#524)).
* Fix WorkspaceConf.get_status and WorkspaceConf.set_status ([#525](#525)).
* Enable Databricks OAuth also for Azure and GCP ([#526](#526)).
* Construct workspace client from account client ([#527](#527)).
* Skip test_get_workspace_client in Azure and GCP ([#531](#531)).
* Do not terminate listing for token-based pagination resources on empty response ([#530](#530)).
* Use fake clock for faster unit tests ([#533](#533)).
* Generate SDK ([#536](#536)).

API Changes:

 * Added `cancel_refresh()` method for [w.lakehouse_monitors](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/lakehouse_monitors.html) workspace-level service.
 * Added `get_refresh()` method for [w.lakehouse_monitors](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/lakehouse_monitors.html) workspace-level service.
 * Added `list_refreshes()` method for [w.lakehouse_monitors](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/lakehouse_monitors.html) workspace-level service.
 * Added `run_refresh()` method for [w.lakehouse_monitors](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/lakehouse_monitors.html) workspace-level service.
 * Removed `name` field for `databricks.sdk.service.catalog.UpdateConnection`.
 * Removed `name` field for `databricks.sdk.service.catalog.UpdateMetastore`.
 * Removed `name` field for `databricks.sdk.service.catalog.UpdateRegisteredModelRequest`.
 * Removed `name` field for `databricks.sdk.service.catalog.UpdateSchema`.
 * Removed `name` field for `databricks.sdk.service.catalog.UpdateVolumeRequestContent`.
 * Added `databricks.sdk.service.catalog.CancelRefreshRequest` dataclass.
 * Added `databricks.sdk.service.catalog.GetRefreshRequest` dataclass.
 * Added `databricks.sdk.service.catalog.ListRefreshesRequest` dataclass.
 * Added `databricks.sdk.service.catalog.MonitorRefreshInfo` dataclass.
 * Added `databricks.sdk.service.catalog.MonitorRefreshInfoState` dataclass.
 * Added `databricks.sdk.service.catalog.RunRefreshRequest` dataclass.
 * Changed `max_workers` field for `databricks.sdk.service.compute.AutoScale` to no longer be required.
 * Changed `min_workers` field for `databricks.sdk.service.compute.AutoScale` to no longer be required.
 * Changed `destination` field for `databricks.sdk.service.compute.DbfsStorageInfo` to be required.
 * Added `use_preemptible_executors` field for `databricks.sdk.service.compute.GcpAttributes`.
 * Added `zone_id` field for `databricks.sdk.service.compute.GcpAttributes`.
 * Added `abfss` field for `databricks.sdk.service.compute.InitScriptInfo`.
 * Added `gcs` field for `databricks.sdk.service.compute.InitScriptInfo`.
 * Changed `destination` field for `databricks.sdk.service.compute.LocalFileInfo` to be required.
 * Changed `destination` field for `databricks.sdk.service.compute.S3StorageInfo` to be required.
 * Changed `destination` field for `databricks.sdk.service.compute.VolumesStorageInfo` to be required.
 * Changed `clients` field for `databricks.sdk.service.compute.WorkloadType` to be required.
 * Changed `destination` field for `databricks.sdk.service.compute.WorkspaceStorageInfo` to be required.
 * Added `databricks.sdk.service.compute.Adlsgen2Info` dataclass.
 * Added `databricks.sdk.service.compute.GcsStorageInfo` dataclass.
 * Removed `get_status()` method for [w.files](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/files.html) workspace-level service.
 * Added `create_directory()` method for [w.files](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/files.html) workspace-level service.
 * Added `delete_directory()` method for [w.files](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/files.html) workspace-level service.
 * Added `list_directory_contents()` method for [w.files](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/files.html) workspace-level service.
 * Added `databricks.sdk.service.files.CreateDirectoryRequest` dataclass.
 * Added `databricks.sdk.service.files.DeleteDirectoryRequest` dataclass.
 * Added `databricks.sdk.service.files.DirectoryEntry` dataclass.
 * Added `databricks.sdk.service.files.ListDirectoryContentsRequest` dataclass.
 * Added `databricks.sdk.service.files.ListDirectoryResponse` dataclass.
 * Added `databricks.sdk.service.files.PageToken` dataclass.
 * Added `source` field for `databricks.sdk.service.jobs.DbtTask`.
 * Added `for_each_task` field for `databricks.sdk.service.jobs.RunTask`.
 * Added `source` field for `databricks.sdk.service.jobs.SqlTaskFile`.
 * Added `for_each_task` field for `databricks.sdk.service.jobs.SubmitTask`.
 * Added `for_each_task` field for `databricks.sdk.service.jobs.Task`.
 * Added `databricks.sdk.service.jobs.ForEachStats` dataclass.
 * Added `databricks.sdk.service.jobs.ForEachTask` dataclass.
 * Added `databricks.sdk.service.jobs.ForEachTaskErrorMessageStats` dataclass.
 * Added `databricks.sdk.service.jobs.ForEachTaskTaskRunStats` dataclass.
 * Added `databricks.sdk.service.jobs.RunForEachTask` dataclass.
 * Removed `reset()` method for [w.pipelines](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/pipelines.html) workspace-level service.
 * Changed `autoscale` field for `databricks.sdk.service.pipelines.PipelineCluster` to `databricks.sdk.service.pipelines.PipelineClusterAutoscale` dataclass.
 * Removed `databricks.sdk.service.pipelines.ResetRequest` dataclass.
 * Added `databricks.sdk.service.pipelines.PipelineClusterAutoscale` dataclass.
 * Added `databricks.sdk.service.pipelines.PipelineClusterAutoscaleMode` dataclass.
 * Changed `delete_personal_compute_setting()` method for [a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html) account-level service with new required argument order.
 * Removed `read_personal_compute_setting()` method for [a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html) account-level service.
 * Changed `update_personal_compute_setting()` method for [a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html) account-level service with new required argument order.
 * Added `get_personal_compute_setting()` method for [a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html) account-level service.
 * Removed `delete_default_workspace_namespace()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Removed `read_default_workspace_namespace()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Removed `update_default_workspace_namespace()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Added `delete_default_namespace_setting()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Added `delete_restrict_workspace_admins_setting()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Added `get_default_namespace_setting()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Added `get_restrict_workspace_admins_setting()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Added `update_default_namespace_setting()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Added `update_restrict_workspace_admins_setting()` method for [w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html) workspace-level service.
 * Removed `databricks.sdk.service.settings.DeleteDefaultWorkspaceNamespaceRequest` dataclass.
 * Removed `databricks.sdk.service.settings.DeleteDefaultWorkspaceNamespaceResponse` dataclass.
 * Changed `etag` field for `databricks.sdk.service.settings.DeletePersonalComputeSettingRequest` to no longer be required.
 * Removed `databricks.sdk.service.settings.ReadDefaultWorkspaceNamespaceRequest` dataclass.
 * Removed `databricks.sdk.service.settings.ReadPersonalComputeSettingRequest` dataclass.
 * Removed `databricks.sdk.service.settings.UpdateDefaultWorkspaceNamespaceRequest` dataclass.
 * Changed `allow_missing` field for `databricks.sdk.service.settings.UpdatePersonalComputeSettingRequest` to be required.
 * Changed `setting` field for `databricks.sdk.service.settings.UpdatePersonalComputeSettingRequest` to be required.
 * Added `field_mask` field for `databricks.sdk.service.settings.UpdatePersonalComputeSettingRequest`.
 * Added `databricks.sdk.service.settings.DeleteDefaultNamespaceSettingRequest` dataclass.
 * Added `databricks.sdk.service.settings.DeleteDefaultNamespaceSettingResponse` dataclass.
 * Added `databricks.sdk.service.settings.DeleteRestrictWorkspaceAdminsSettingRequest` dataclass.
 * Added `databricks.sdk.service.settings.DeleteRestrictWorkspaceAdminsSettingResponse` dataclass.
 * Added `databricks.sdk.service.settings.GetDefaultNamespaceSettingRequest` dataclass.
 * Added `databricks.sdk.service.settings.GetPersonalComputeSettingRequest` dataclass.
 * Added `databricks.sdk.service.settings.GetRestrictWorkspaceAdminsSettingRequest` dataclass.
 * Added `databricks.sdk.service.settings.RestrictWorkspaceAdminsMessage` dataclass.
 * Added `databricks.sdk.service.settings.RestrictWorkspaceAdminsMessageStatus` dataclass.
 * Added `databricks.sdk.service.settings.RestrictWorkspaceAdminsSetting` dataclass.
 * Added `databricks.sdk.service.settings.UpdateDefaultNamespaceSettingRequest` dataclass.
 * Added `databricks.sdk.service.settings.UpdateRestrictWorkspaceAdminsSettingRequest` dataclass.
 * Removed `delta_sync_vector_index_spec` field for `databricks.sdk.service.vectorsearch.CreateVectorIndexRequest`.
 * Added `delta_sync_index_spec` field for `databricks.sdk.service.vectorsearch.CreateVectorIndexRequest`.
 * Added `file_type` field for `databricks.sdk.service.workspace.ExportResponse`.
 * Added `resource_id` field for `databricks.sdk.service.workspace.ObjectInfo`.

OpenAPI SHA: 6b897bc95b23abed8b9f5eff0e6b8ec034046180, Date: 2024-02-08
@tanmay-db tanmay-db mentioned this pull request Feb 8, 2024
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2024
## 0.19.0

### Improvements and Bug Fixes
* Construct workspace client from account client
([#527](#527)).
* Enabled Databricks OAuth also for Azure and GCP
([#526](#526)).
* Do not terminate listing for token-based pagination resources on empty
response
([#530](#530)).
* Renamed `databricks.sdk.errors.mapping` to
`databricks.sdk.errors.platform`
([#522](#522)).
* Added Union to content (2nd) parameter in upload function
([#493](#493)).
* Fixed WorkspaceConf.get_status and WorkspaceConf.set_status
([#525](#525)).

### Documentation
* Make docs useful again
([#519](#519)).
* Show undocumented fields in dataclasses
([#520](#520)).


### API Changes

Additions:
 * Added the following dataclasses:
    - `databricks.sdk.service.catalog.CancelRefreshRequest`
    - `databricks.sdk.service.catalog.GetRefreshRequest` 
    - `databricks.sdk.service.catalog.ListRefreshesRequest`
    - `databricks.sdk.service.catalog.MonitorRefreshInfo`
    - `databricks.sdk.service.catalog.MonitorRefreshInfoState`
    - `databricks.sdk.service.catalog.RunRefreshRequest`
    - `databricks.sdk.service.compute.Adlsgen2Info`
    - `databricks.sdk.service.compute.GcsStorageInfo`
    - `databricks.sdk.service.files.CreateDirectoryRequest`
    - `databricks.sdk.service.files.DeleteDirectoryRequest`
    - `databricks.sdk.service.files.DirectoryEntry`
    - `databricks.sdk.service.files.ListDirectoryContentsRequest`
    - `databricks.sdk.service.files.ListDirectoryResponse`
    -  `databricks.sdk.service.files.PageToken`
    - `databricks.sdk.service.jobs.ForEachStats`
    - `databricks.sdk.service.jobs.ForEachTask`
    - `databricks.sdk.service.jobs.ForEachTaskErrorMessageStats`
    - `databricks.sdk.service.jobs.ForEachTaskTaskRunStats`
    - `databricks.sdk.service.jobs.RunForEachTask`
    - `databricks.sdk.service.pipelines.PipelineClusterAutoscale`
    - `databricks.sdk.service.pipelines.PipelineClusterAutoscaleMode`
- `databricks.sdk.service.settings.DeleteDefaultNamespaceSettingRequest`
-
`databricks.sdk.service.settings.DeleteDefaultNamespaceSettingResponse`
-
`databricks.sdk.service.settings.DeleteRestrictWorkspaceAdminsSettingRequest`
-
`databricks.sdk.service.settings.DeleteRestrictWorkspaceAdminsSettingResponse`
- `databricks.sdk.service.settings.GetDefaultNamespaceSettingRequest`
    - `databricks.sdk.service.settings.GetPersonalComputeSettingRequest`
-
`databricks.sdk.service.settings.GetRestrictWorkspaceAdminsSettingRequest`
    - `databricks.sdk.service.settings.RestrictWorkspaceAdminsMessage`
- `databricks.sdk.service.settings.RestrictWorkspaceAdminsMessageStatus`
    - `databricks.sdk.service.settings.RestrictWorkspaceAdminsSetting`
- `databricks.sdk.service.settings.UpdateDefaultNamespaceSettingRequest`
-
`databricks.sdk.service.settings.UpdateRestrictWorkspaceAdminsSettingRequest`
* Added `cancel_refresh()`, `get_refresh()`, `list_refreshes()` and
`run_refresh()` method for
[w.lakehouse_monitors](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/lakehouse_monitors.html)
workspace-level service.
* Added `use_preemptible_executors` field for
`databricks.sdk.service.compute.GcpAttributes`.
* Added `zone_id` field for
`databricks.sdk.service.compute.GcpAttributes`.
* Added `abfss` and `gcs` field for
`databricks.sdk.service.compute.InitScriptInfo`.
* Added `create_directory()`, `delete_directory()` and
`list_directory_contents()` method for
[w.files](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/files.html)
workspace-level service.
* Added `source` field for `databricks.sdk.service.jobs.DbtTask` and
`databricks.sdk.service.jobs.SqlTaskFile`.
* Added `for_each_task` field for `databricks.sdk.service.jobs.RunTask`,
`databricks.sdk.service.jobs.SubmitTask` and
`databricks.sdk.service.jobs.Task`.
* Added `field_mask` field for
`databricks.sdk.service.settings.UpdatePersonalComputeSettingRequest`.
* Added `delta_sync_index_spec` field for
`databricks.sdk.service.vectorsearch.CreateVectorIndexRequest`.
* Added `file_type` field for
`databricks.sdk.service.workspace.ExportResponse`.
* Added `resource_id` field for
`databricks.sdk.service.workspace.ObjectInfo`.
* Added `delete_default_namespace_setting()`,
`delete_restrict_workspace_admins_setting()`,
`get_default_namespace_setting()`,
`get_restrict_workspace_admins_setting()`,
`update_default_namespace_setting()` and
`update_restrict_workspace_admins_setting()` method for
[w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html)
workspace-level service.
* Added `get_personal_compute_setting()` method for
[a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html)
account-level service.

Removals:
 * Removed the following dataclasses:
- `databricks.sdk.service.settings.ReadDefaultWorkspaceNamespaceRequest`
- `databricks.sdk.service.settings.ReadPersonalComputeSettingRequest`
-
`databricks.sdk.service.settings.UpdateDefaultWorkspaceNamespaceRequest`
-
`databricks.sdk.service.settings.DeleteDefaultWorkspaceNamespaceRequest`
-
`databricks.sdk.service.settings.DeleteDefaultWorkspaceNamespaceResponse`
    - `databricks.sdk.service.pipelines.ResetRequest`
 * Removed the following methods:
- `get_status()` for
[w.files](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/files.html)
workspace-level service.
- `reset()` for
[w.pipelines](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/pipelines.html)
workspace-level service.
- `delete_default_workspace_namespace()` for
[w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html)
workspace-level service.
- `read_default_workspace_namespace()` for
[w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html)
workspace-level service.
- `update_default_workspace_namespace()` for
[w.settings](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings.html)
workspace-level service.
- `read_personal_compute_setting()` for
[a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html)
account-level service.
* Removed `name` field for
`databricks.sdk.service.catalog.UpdateConnection`,
`databricks.sdk.service.catalog.UpdateMetastore`,
`databricks.sdk.service.catalog.UpdateRegisteredModelRequest`.
`databricks.sdk.service.catalog.UpdateSchema`and
`databricks.sdk.service.catalog.UpdateVolumeRequestContent`.
* Removed `delta_sync_vector_index_spec` field for
`databricks.sdk.service.vectorsearch.CreateVectorIndexRequest`.

Changes:
* Changed `max_workers` and `min_workers` field for
`databricks.sdk.service.compute.AutoScale` to no longer be required.
* Changed `destination` field for
`databricks.sdk.service.compute.DbfsStorageInfo`,
`databricks.sdk.service.compute.LocalFileInfo`,
`databricks.sdk.service.compute.S3StorageInfo`,
`databricks.sdk.service.compute.VolumesStorageInfo` and
`databricks.sdk.service.compute.WorkspaceStorageInfo` to be required.
* Changed `clients` field for
`databricks.sdk.service.compute.WorkloadType` to be required.
* Changed `allow_missing` and `setting` field for
`databricks.sdk.service.settings.UpdatePersonalComputeSettingRequest` to
be required.
* Changed `etag` field for
`databricks.sdk.service.settings.DeletePersonalComputeSettingRequest` to
no longer be required.
* Changed `autoscale` field for
`databricks.sdk.service.pipelines.PipelineCluster` to
`databricks.sdk.service.pipelines.PipelineClusterAutoscale` dataclass.
* Changed `delete_personal_compute_setting()` and
`update_personal_compute_setting()` method for
[a.account_settings](https://databricks-sdk-py.readthedocs.io/en/latest/account/account_settings.html)
account-level service with new required argument order.

### Internal Changes
* Generate SDK
([#536](#536)).
* Use fake clock for faster unit tests
([#533](#533)).
* Skip test_get_workspace_client in Azure and GCP
([#531](#531)).
* Regenerate from the tip of main
([#524](#524)).
* Search for both databricks.exe and databricks binaries in windows
([#517](#517)).

OpenAPI SHA: 6b897bc95b23abed8b9f5eff0e6b8ec034046180, Date: 2024-02-08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants