databricks-sdk-py icon indicating copy to clipboard operation
databricks-sdk-py copied to clipboard

Added `w.clusters.commands(cluster_id).run('return [1,2,3]')` utility

Open nfx opened this issue 2 years ago • 1 comments

Changes

This PR refactors the wrapper around Command Execution API, which was used by dbutils.fs.mounts() and other cluster-proxied dbutils into a dedicated mixin.

Usage:

cluster_id = env_or_skip("TEST_DEFAULT_CLUSTER_ID")
ce = w.clusters.commands(cluster_id=cluster_id)
rows = ce.run('return spark.sql("SHOW DATABASES").collect()')
assert len(rows) > 0

and results:

image

Tests

  • [x] make test run locally
  • [x] make fmt applied
  • [x] relevant integration tests applied

nfx avatar Aug 31 '23 17:08 nfx

Codecov Report

Patch coverage is 75.41% of modified lines.

Files Changed Coverage
databricks/sdk/mixins/compute.py 72.50%
databricks/sdk/dbutils.py 100.00%

:loudspeaker: Thoughts on this report? Let us know!.

codecov-commenter avatar Aug 31 '23 17:08 codecov-commenter