What's Changed
* refactor!: apply flake8 builtin rules by tdstein in https://github.com/posit-dev/posit-sdk-py/pull/248
* feat: replace restart environment variable hash with Unix epoch by tdstein in https://github.com/posit-dev/posit-sdk-py/pull/251
* feat!: improve compatibility with Databricks SQL client by dbkegley in https://github.com/posit-dev/posit-sdk-py/pull/252
Breaking Changes
* refactor: rename `bundles.create` method argument from `input` to `archive` by tdstein in 248
* refactor: rename `bundles.get` method argument from `id` to `uid` by tdstein in 248
* refactor: rename `permissions.get` method argument from `id` to `uid` by tdstein in 248
* refactor: rename `tasks.get` method argument from `id` to `uid` by tdstein in 248
* refactor: rewrite `external.databricks` helpers for better interop between `databricks-sdk-python` and `databricks-sql-python` by dbkegley 252
Migration Guide
This release includes changes to remove shadowing of builtins. As a result, the argument names for various methods have changed. This change only impacts method invocations using keyword-arguments. Methods invoked without keyword-arguments do not require adjustments.
refactor: rename `bundles.create` method argument from `input` to `archive` by tdstein in 248
Rename the keyword-argument `input` to `archive`.
Previous
python
from posit import connect
client = connect.Client()
content = client.content.find_one()
bundle = content.bundles.create(input="archive.tar.gz")
Current
python
from posit import connect
client = connect.Client()
content = client.content.find_one()
bundle = content.bundles.create(archive="archive.tar.gz")
refactor: rename `bundles.get` method argument from `id` to `uid` by tdstein in 248
Rename the keyword-argument `id` to `uid`.
Previous
python
from posit import connect
client = connect.Client()
content = client.content.find_one()
bundle = content.bundles.get(id="3bb97e21-8216-445c-95b7-288578ca4311")
Current
python
from posit import connect
client = connect.Client()
content = client.content.find_one()
bundle = content.bundles.get(uid="3bb97e21-8216-445c-95b7-288578ca4311")
refactor: rename `permissions.get` method argument from `id` to `uid` by tdstein in 248
Rename the keyword-argument `id` to `uid`.
Previous
python
from posit import connect
client = connect.Client()
content = client.content.find_one()
permission = content.permissions.get(id="3bb97e21-8216-445c-95b7-288578ca4311")
Current
python
from posit import connect
client = connect.Client()
content = client.content.find_one()
permission = content.permissions.get(uid="3bb97e21-8216-445c-95b7-288578ca4311")
refactor: rename `tasks.get` method argument from `id` to `uid` by tdstein in 248
Rename the keyword-argument `id` to `uid`.
Previous
python
from posit import connect
client = connect.Client()
task = client.tasks.get(id="CmsfmnfDDyRUrsAc")
Current
python
from posit import connect
client = connect.Client()
task = client.tasks.get(uid="CmsfmnfDDyRUrsAc")
refactor: rewrite `external.databricks` helpers for better interop between `databricks-sdk-python` and `databricks-sql-python` by dbkegley 252
Previous
python
from databricks import sql
from databricks.sdk.core import ApiClient, Config
from databricks.sdk.service.iam import CurrentUserAPI
from posit.connect.external.databricks import viewer_credentials_provider
session_token = "<read-from-http-header>"
credentials_provider = viewer_credentials_provider(
user_session_token=session_token
)
databricks-sdk usage
cfg = Config(
host=DATABRICKS_HOST_URL,
credentials_provider=credentials_provider
)
databricks_user = CurrentUserAPI(ApiClient(cfg)).me()
print(databricks_user)
databricks-sql usage
with sql.connect(
server_hostname=DATABRICKS_HOST,
http_path=SQL_HTTP_PATH,
auth_type="databricks-oauth", old local credential_provider fallback behavior
credentials_provider=credentials_provider,
) as connection:
with connection.cursor() as cursor:
cursor.execute("SELECT * FROM samples.nyctaxi.trips LIMIT 10;")
result = cursor.fetchall()
print(result)
Current
> [!WARNING]
> Requires `databricks-sdk>=0.29.0`
python
from databricks import sql
from databricks.sdk.core import ApiClient, Config, databricks_cli
from databricks.sdk.service.iam import CurrentUserAPI
from posit.connect.external.databricks import PositCredentialsStrategy
session_token = "<read-from-http-header>"
posit_strategy = PositCredentialsStrategy(
local_strategy=databricks_cli, new local credential_provider fallback behavior
user_session_token=session_token)
cfg = Config(
host=DATABRICKS_HOST_URL,
uses Posit's custom credential_strategy if running on Connect,
otherwise falls back to the strategy defined by local_strategy
credentials_strategy=posit_strategy)
databricks_user = CurrentUserAPI(ApiClient(cfg)).me()
print(databricks_user)
with sql.connect(
server_hostname=DATABRICKS_HOST,
http_path=SQL_HTTP_PATH,
https://github.com/databricks/databricks-sql-python/issues/148#issuecomment-2271561365
credentials_provider=posit_strategy.sql_credentials_provider(cfg)
) as connection:
with connection.cursor() as cursor:
cursor.execute("SELECT * FROM samples.nyctaxi.trips LIMIT 10;")
result = cursor.fetchall()
print(result)
**Full Changelog**: https://github.com/posit-dev/posit-sdk-py/compare/v0.3.1...v0.4.0