Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
46 changes: 46 additions & 0 deletions .codegen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"mode": "py_v0",
"api_changelog": false,
"version": {
"databricks/sdk/version.py": "__version__ = \"$VERSION\""
},
"sync": {
"skip_from_genkit": [
".github/workflows/next-changelog.yml",
"tagging.py",
"tagging.py.lock"
],
"skip_from_source": [
"BUILD.bazel",
"CLAUDE.md",
"OWNERS",
"README.md",
"changelog.json",
"releases.jsonl",
".cursor",
".cursorrules",
".nextchanges",
"changelog_validate",
"next-changelog.yml",
"tagging.py"
],
"rename_on_sync": {
"README.public.md": "README.md"
}
},
"toolchain": {
"required": ["python3.12", "uv"],
"pre_setup": [
"python3.12 -m venv .databricks"
],
"prepend_path": ".databricks/bin",
"setup": [
"pip install '.[dev]'"
],
"post_generate": [
"make fmt",
"pip install .",
"python3.12 docs/gen-client-docs.py"
]
}
}
2 changes: 1 addition & 1 deletion .codegen/_openapi_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ce12048f2c4a4fefb93fc3f55cba9c9798f9cb6
bb6433a6fab9f514ae007ef4cb93fb839a83108d
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
databricks/sdk/__init__.py linguist-generated=true
databricks/sdk/errors/overrides.py linguist-generated=true
databricks/sdk/errors/platform.py linguist-generated=true
databricks/sdk/service/__init__.py linguist-generated=true
databricks/sdk/service/_internal.py linguist-generated=true
databricks/sdk/service/agentbricks.py linguist-generated=true
databricks/sdk/service/aisearch.py linguist-generated=true
databricks/sdk/service/apps.py linguist-generated=true
databricks/sdk/service/billing.py linguist-generated=true
databricks/sdk/service/bundle.py linguist-generated=true
databricks/sdk/service/bundledeployments.py linguist-generated=true
databricks/sdk/service/catalog.py linguist-generated=true
databricks/sdk/service/cleanrooms.py linguist-generated=true
Expand Down
34 changes: 6 additions & 28 deletions .github/workflows/tagging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ jobs:
github.repository == 'databricks/databricks-sdk-go' ||
github.repository == 'databricks/databricks-sdk-py' ||
github.repository == 'databricks/databricks-sdk-java'
env:
# Ref the release is cut from. Releasing from a branch is currently
# supported in the terraform repository only: for
# terraform-provider-databricks this follows the dispatched branch
# (``github.ref_name``), so a release can be cut from a branch other
# than main; every other synced repo (SDK go/py/java, …) stays pinned
# to main, preserving the pre-existing hardcoded-main behaviour and
# blocking branch releases even via a manual non-main dispatch.
RELEASE_REF: ${{ github.repository == 'databricks/terraform-provider-databricks' && github.ref_name || 'main' }}
environment: "release-is"
runs-on:
group: databricks-protected-runner-group
Expand All @@ -59,19 +50,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Check out the release ref. ``RELEASE_REF`` is the dispatched
# branch for terraform-provider-databricks and ``main`` for every
# other repo (see the job-level ``env``). For scheduled runs and
# manual dispatches left at defaults this is the default branch
# (main); dispatching terraform with ``--ref <branch>`` cuts the
# release from that branch instead.
#
# Naming the ref explicitly (rather than omitting ``ref:``)
# forces re-resolution of the branch head at step time. Without
# it, checkout pins to ``github.sha`` — the SHA frozen at
# workflow_dispatch time — so re-running a stale dispatch would
# check out an older commit even when newer ones exist.
ref: ${{ env.RELEASE_REF }}
# Force re-resolution of ``main`` at step time. Without
# ``ref:``, checkout pins to ``github.sha`` — the SHA frozen
# at workflow_dispatch time — which means re-running a stale
# dispatch checks out an older main even when newer commits
# exist.
ref: main
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}

Expand All @@ -89,12 +73,6 @@ jobs:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
PACKAGES: ${{ inputs.packages }}
# Branch the release is cut from. tagging.py commits the
# changelog bump and creates the tag on this branch, and its
# concurrent-advance guard checks this branch. Matches the ref
# checked out above (``RELEASE_REF``): the dispatched branch for
# terraform, main everywhere else.
DECO_TAGGING_REF: ${{ env.RELEASE_REF }}
run: |
if [ -n "$PACKAGES" ]; then
uv run --locked tagging.py --package "$PACKAGES"
Expand Down
14 changes: 14 additions & 0 deletions databricks/sdk/__init__.py
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 30 additions & 3 deletions databricks/sdk/_base_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import io
import json
import logging
import urllib.parse
from abc import ABC, abstractmethod
from datetime import timedelta
from datetime import date, datetime, timedelta
from enum import Enum
from types import TracebackType
from typing import Any, BinaryIO, Callable, Dict, Iterable, Iterator, List, Optional, Type, Union

Expand All @@ -19,6 +21,27 @@
logger = logging.getLogger("databricks.sdk")


def _json_default(o: Any) -> Any:
"""``json.dumps`` ``default`` hook coercing SDK values into their wire form.

Lets an open ``Any`` body field accept an SDK response passed straight into
the next call (function chaining), which is otherwise not JSON serializable.
"""
as_dict = getattr(o, "as_dict", None)
if callable(as_dict):
return as_dict()
to_json_string = getattr(o, "ToJsonString", None) # protobuf Timestamp/Duration, FieldMask
if callable(to_json_string):
return to_json_string()
if isinstance(o, (datetime, date)):
return o.isoformat()
if isinstance(o, timedelta):
return f"{o.total_seconds()}s"
if isinstance(o, Enum):
return o.value
raise TypeError(f"Object of type {type(o).__name__} is not JSON serializable")


def _fix_host_if_needed(host: Optional[str]) -> Optional[str]:
if not host:
return host
Expand Down Expand Up @@ -281,14 +304,18 @@ def _perform(
data=None,
auth: Callable[[requests.PreparedRequest], requests.PreparedRequest] = None,
):
json_data = None
if body is not None and data is None and files is None:
json_data = json.dumps(body, allow_nan=False, default=_json_default)
headers = {"Content-Type": "application/json", **(headers or {})}
response = self._session.request(
method,
url,
params=self._fix_query_string(query),
json=body,
json=None if json_data is not None else body,
headers=headers,
files=files,
data=data,
data=json_data if json_data is not None else data,
auth=auth,
stream=raw,
timeout=self._http_timeout_seconds,
Expand Down
Empty file modified databricks/sdk/errors/overrides.py
100644 → 100755
Empty file.
Empty file modified databricks/sdk/errors/platform.py
100644 → 100755
Empty file.
Empty file modified databricks/sdk/service/__init__.py
100644 → 100755
Empty file.
Empty file modified databricks/sdk/service/_internal.py
100644 → 100755
Empty file.
Empty file modified databricks/sdk/service/agentbricks.py
100644 → 100755
Empty file.
Loading
Loading