Skip to content

[Data] Start the Azure test emulator as a container, so CI can run it - #66276

Merged
sampan-s-nayak merged 2 commits into
uc/dv-errorfrom
uc/emulator-container
Oct 8, 2026
Merged

sampan-s-nayak merged 2 commits into
uc/dv-errorfrom
uc/emulator-container

Conversation

@NightWing1998

@NightWing1998 NightWing1998 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Why

Unity Catalog credential vending is covered for AWS, but the Azure path was only
tested as far as resolve(): the Databricks SDK is mocked, the assertions check
that AZURE_STORAGE_SAS_TOKEN lands in os.environ, and no byte is ever read.
Once tests actually read data through a vended Azure SAS, two real bugs showed
up — and a third, unrelated to Azure, turned up on the way.

Verified against a real Azure Databricks workspace with a Unity Catalog managed
Delta table (12,000 rows, 4 log versions, 24 Parquet files) throughout.

What does this PR achieve

Add azurite to CI so that we can actively test UC code path against mock azure.

Links

PR is a part of stacked PRs. Chain: #66272 > #66273 > #66274 > #66275 > #66276

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Azure catalog tests to run the Azurite emulator inside a container using testcontainers, falling back to a local binary if Docker is unavailable. A review comment points out that if retrieving the container host or port fails, the exception will propagate and bypass the fallback to the binary path, potentially leaking the container. It suggests wrapping the entire container setup and port retrieval in a try-except block and ensuring the container is stopped on failure.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@ray-gardener ray-gardener Bot added data Ray Data-related issues devprod labels Sep 18, 2026
@NightWing1998 NightWing1998 added the go add ONLY when ready to merge, run all tests label Sep 30, 2026
@NightWing1998
NightWing1998 force-pushed the uc/emulator-container branch from c28fba4 to d2b0b26 Compare October 2, 2026 11:37
@NightWing1998
NightWing1998 requested a review from a team as a code owner October 5, 2026 12:08
@NightWing1998
NightWing1998 force-pushed the uc/emulator-container branch from d2b0b26 to e7378ca Compare October 5, 2026 12:08

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e7378ca. Configure here.

NightWing1998 and others added 2 commits October 8, 2026 12:31
Azurite was started by shelling out to an `azurite` binary, so the tests skipped
anywhere without `npm install -g azurite` -- including CI, where the bazel
target could catch import regressions and nothing else.

Start it as a container through `testcontainers`, already declared for
`test_kafka.py`, which starts its broker the same way -- so the CI images need
no npm and no Dockerfile change. Uses `testcontainers.community.azurite`, since
`testcontainers.azurite` warns that it is deprecated. `azurite` is a real extra
of testcontainers 4.15.0, so it joins `kafka` in the requirement.

The binary path stays as a fallback, because Docker is not always usable where
it is installed: a remote-only Docker context starts the container but publishes
its port somewhere the test process cannot reach. Any Docker problem means "try
the other path", never a suite failure; with neither available the tests skip,
naming both options.

Testing: all three branches exercised -- the container attempted and declining
cleanly, the binary fallback carrying the suite, and the skip when neither is
present.

    pytest python/ray/data/tests/datasource/test_catalog_azure.py \
           python/ray/data/tests/test_catalog.py
    51 passed, 1 skipped

Not verified: the container actually serving the tests. This machine has no
local Docker daemon, so every run took the fallback.

AI assistance was used for this change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Dhruvil Shah <[email protected]>
@NightWing1998
NightWing1998 force-pushed the uc/emulator-container branch from e7378ca to df1ccf6 Compare October 8, 2026 07:01
@sampan-s-nayak
sampan-s-nayak merged commit 0d2fc26 into master Oct 8, 2026
7 checks passed
@sampan-s-nayak
sampan-s-nayak deleted the uc/emulator-container branch October 8, 2026 15:15
sampan-s-nayak pushed a commit that referenced this pull request Oct 8, 2026
…6272)

## Why

Unity Catalog credential vending is covered for AWS, but the Azure path
was only
tested as far as resolve(): the Databricks SDK is mocked, the assertions
check
that AZURE_STORAGE_SAS_TOKEN lands in os.environ, and no byte is ever
read.
Once tests actually read data through a vended Azure SAS, two real bugs
showed
up — and a third, unrelated to Azure, turned up on the way.

Verified against a real Azure Databricks workspace with a Unity Catalog
managed
Delta table (12,000 rows, 4 log versions, 24 Parquet files) throughout.

## What does this PR achieve?

This PR is solely focused in improving the test coverage around azure
unity catalog.
Some tests added in the PR actually fail in CI but are fixed in later PR
part of the stack.

## Links

PR is a part of `stacked PRs`. Chain: #66272 > #66273 > #66274 > #66275
> #66276

---------

Signed-off-by: Dhruvil Shah <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
sampan-s-nayak pushed a commit that referenced this pull request Oct 8, 2026
…t them (#66273)

## Why

Unity Catalog credential vending is covered for AWS, but the Azure path
was only
tested as far as resolve(): the Databricks SDK is mocked, the assertions
check
that AZURE_STORAGE_SAS_TOKEN lands in os.environ, and no byte is ever
read.
Once tests actually read data through a vended Azure SAS, two real bugs
showed
up — and a third, unrelated to Azure, turned up on the way.

Verified against a real Azure Databricks workspace with a Unity Catalog
managed
Delta table (12,000 rows, 4 log versions, 24 Parquet files) throughout.

## What does this PR achieve

Fix the Azure credential vending to allow non-driver node task/actor
operators
to read delta tables from Unity Catalog.

## Links

PR is a part of stacked PRs. Chain: #66272 > #66273 > #66274 > #66275 >
#66276

Signed-off-by: Dhruvil Shah <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
sampan-s-nayak pushed a commit that referenced this pull request Oct 8, 2026
…row (#66274)

## Why

Unity Catalog credential vending is covered for AWS, but the Azure path
was only
tested as far as resolve(): the Databricks SDK is mocked, the assertions
check
that AZURE_STORAGE_SAS_TOKEN lands in os.environ, and no byte is ever
read.
Once tests actually read data through a vended Azure SAS, two real bugs
showed
up — and a third, unrelated to Azure, turned up on the way.

Verified against a real Azure Databricks workspace with a Unity Catalog
managed
Delta table (12,000 rows, 4 log versions, 24 Parquet files) throughout.

## What does this PR achieve?

PyArrow v20.0.0 or above is required to support UC Parquet file based
tables.
Bump the minimum pyarrow version required so that users with older
pyarrow
version don't see exception during pipeline execution.

## Links

PR is a part of stacked PRs. Chain: #66272 > #66273 > #66274 > #66275 >
#66276

Signed-off-by: Dhruvil Shah <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
sampan-s-nayak pushed a commit that referenced this pull request Oct 8, 2026
## Why

Unity Catalog credential vending is covered for AWS, but the Azure path
was only
tested as far as resolve(): the Databricks SDK is mocked, the assertions
check
that AZURE_STORAGE_SAS_TOKEN lands in os.environ, and no byte is ever
read.
Once tests actually read data through a vended Azure SAS, two real bugs
showed
up — and a third, unrelated to Azure, turned up on the way.

Verified against a real Azure Databricks workspace with a Unity Catalog
managed
Delta table (12,000 rows, 4 log versions, 24 Parquet files) throughout.

## What does this PR achieve

Deltalake python SDK does not support reading tables with deletion
vectors. Current
error message requests to update the `deltalake` library version but no
version so
released so far has this support. Correct the exception message raised
to show that.

## Links

PR is a part of stacked PRs. Chain: #66272 > #66273 > #66274 > #66275 >
#66276

Signed-off-by: Dhruvil Shah <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
sai-miduthuri pushed a commit that referenced this pull request Nov 18, 2026
…dentials to the environment (#67899) (#68232)

## Description

Backport of #67899 (master commit
596241a) onto `releases/2.60.1`, **AWS
part only**. It's based directly on `releases/2.60.1` and is independent
of #68213 / #68214 and the #67898 pick; all of them merge with it
without conflicts.

On this branch, `DatabricksUnityCatalog.resolve()` writes vended AWS
credentials into the driver's `os.environ` and, if Ray isn't running
yet, starts Ray with them in `runtime_env`. AWS env vars take precedence
over the instance role, so after one Unity Catalog read the driver and
every worker use a short-lived credential scoped to that one table.
Writes to the job's own buckets (checkpoints, logs) then fail with
`ACCESS_DENIED`.

With this PR, AWS credentials travel only in the objects that use them,
which pickle into the read and write tasks:

- An explicit `S3FileSystem` for every reader and mode. Before, AWS
Parquet reads used the environment.
- For Delta, the AWS keys and region in `storage_options`, for
deltalake's log read and the `write_delta` commit. `read_delta`,
`write_delta` and the datasink's credential refresh already merge
`resolved.storage_options` on this branch.

GCS was already environment-free and is unchanged. A response with no
known credential type still raises `ValueError`.

Behavior changes worth a release note (the same as on master):

- AWS Parquet reads through Unity Catalog now need `region`, which the
`DatabricksUnityCatalog` docstring already lists as required for AWS.
- Code that relied on the vended AWS keys being in the environment
afterwards no longer gets them.

## Related issues

Related to #67899.

## Additional information

### How this differs from #67899

`releases/2.60.1` doesn't have the Azure Unity Catalog work #67899 edits
(#66272–#66276: Azure SAS in `storage_options`, `AzureFileSystem` for
Parquet, Azurite tests). So `git cherry-pick` conflicts in `catalog.py`
and `test_catalog.py` and tries to bring in that Azure code and the
Gravitino catalog. I ported the AWS change by hand instead:

- **Azure is unchanged.** It still gets the SAS through `_apply_env`
(the environment plus `runtime_env`), because nothing else delivers it
on this branch. Removing that would break Azure reads. `_creds_to_env`
is gone: Azure calls `_parse_azure_creds` directly, and the unknown-type
`ValueError` moved into `_resolve_storage`, as on master.
- **Not taken:** master's `delta_datasink.py` and `test_write_delta.py`
changes. They're comment-only and say Unity Catalog never touches the
environment, which is still false for Azure here.
`test_catalog_azure.py` doesn't exist on this branch.
- **Tests:** master's strict `isolated_env` fixture (environment must
come back unchanged, `ray.init` fails if called) covers every AWS and
GCS `resolve()` test. The two Azure tests keep the old lenient fixture,
renamed `azure_env`. Master deleted
`test_resolve_initializes_ray_with_runtime_env`; here it becomes
`test_resolve_azure_initializes_ray_with_runtime_env`, since Azure still
does that. As on master, `test_resolve_aws_requires_region` covers both
readers, and `test_resolve_rejects_unknown_credential_type` and the
`storage_options` asserts in the `write_delta` test are added.

Not a duplicate: no open or merged PR against `releases/2.60.1` picks
#67899.

### Testing

`test_catalog.py` skips the whole module without `databricks-sdk`, and
this branch's Data CI locks don't include it, so **CI doesn't run these
tests here**. I ran them locally:

| Command | Result |
|---|---|
| pre-commit (commit hooks) on the 2 changed files | Passed |
| `pytest test_catalog.py` (databricks-sdk 0.143.0) | 36 passed. On
`releases/2.60.1`: 34 |
| The same with `releases/2.60.1`'s `catalog.py` | 8 failed and 7
fixture errors: every AWS `resolve()` test, the Parquet region check,
and the `write_delta` `storage_options` asserts |
| `pytest datasource/test_write_delta.py` | 101 passed |
| `pytest datasource/test_delta.py` | 15 passed |
| `pytest unit/datasource/` | 83 passed |

Each file ran in its own pytest process. Environment: Python 3.12.10
with the Ray 2.60.0 release wheel, this branch's `python/ray/data` and
`python/ray/tests` linked over it, and the CI lock pins: pyarrow 23.0.1,
pandas 2.3.3, numpy 2.2.6, deltalake 1.5.0, pytest 7.4.4.

Not checked on a real Databricks workspace, as with #67899 on master.

AI assistance was used to prepare this backport; every line has been
reviewed by the submitter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Abhishek Verma <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues devprod go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants