Skip to content

[Data] Update the export API to refresh the dataset and operator states - #55355

Merged
alanwguo merged 1 commit into
ray-project:masterfrom
coqian:coqian/data-export
Aug 14, 2025
Merged

alanwguo merged 1 commit into
ray-project:masterfrom
coqian:coqian/data-export

Conversation

@coqian

@coqian coqian commented Aug 7, 2025 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

This PR is a revert of #55333 and resolves conflict by #55163

Original description:
Some frequently used metadata fields are missing in the export API schema:

  • For both dataset and operator: state, execution start and end time

These fields are important for us to observe the lifecycle of the datasets and operators, and can be used to improve the accuracy of reported metrics, such as throughput, which relies on the duration.

Summary of change:

  • Add state, execution start and end time at the export API schema
  • Add a new state enum PENDING for dataset and operator, to represent the state when they are not running yet.
  • Refresh the metadata when ever the state of dataset/operator gets updated. And the event will always contains the latest snapshot of all the metadata.

Related issue number

Checks

@coqian
coqian requested review from a team as code owners August 7, 2025 07:03

@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.

Summary of Changes

Hello @coqian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the observability of Ray Data workflows by enriching the export API with detailed lifecycle information for datasets and their operators. It introduces new state tracking, including execution start and end times, and ensures that this metadata is continuously updated and exported as the execution progresses. These changes will enable more precise monitoring and analysis of data processing performance.

Highlights

  • Enhanced Export API Schema: I've extended the export API schema for both datasets and operators to include crucial lifecycle metadata: state, execution_start_time, and execution_end_time. These fields are vital for observing the lifecycle of data processing workflows and improving the accuracy of reported metrics.
  • New PENDING State: A new PENDING state has been introduced for both datasets and operators. This state accurately represents their status when they have been registered but are not yet actively running, providing a more granular view of their lifecycle.
  • Real-time Metadata Refresh: The system now actively refreshes and exports dataset and operator metadata whenever their state is updated. This ensures that the exported events always contain the latest snapshot of all relevant metadata, including their current state and execution timings.
  • Centralized State Management: The DatasetState enum definition has been centralized into its own dedicated file (dataset_state.py), improving code organization and reusability across the Ray Data module.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@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 enhances the data export API by adding state, execution_start_time, and execution_end_time to dataset and operator metadata. This is a great improvement for observability. The implementation is solid, with a new PENDING state for better lifecycle tracking and logic to refresh metadata on state changes. The accompanying tests cover the new functionality well. I've offered one suggestion to improve code conciseness.

Comment thread python/ray/data/_internal/stats.py Outdated
Comment on lines 592 to 607

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.

medium

This loop to find the operator metadata can be expressed more concisely and idiomatically using a generator expression with next().

        operator_metadata = next(
            (op for op in dataset_metadata.topology.operators if op.uuid == operator_uuid),
            None
        )

@coqian
coqian force-pushed the coqian/data-export branch from 71b4740 to 7e1bfd9 Compare August 7, 2025 07:11
# Set the appropriate description that summarizes
# the result of dataset execution.
if exception is None:
StatsManager.update_dataset_metadata_state(

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.

@coqian why don't we move this into _update_stats_metrics method?

Same question for all the hooks added here

@coqian coqian Aug 7, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@alexeykudinkin Personally, I prefer separating metadata update from metrics because of two differences between them:

  1. Metadata contains descriptive fields that rarely get updated, such as state, timestamp; while metrics report numeric time series values as job runs.
  2. The frequency to update them: we only export metadata when there is a state change; while for metrics, the _update_stats_metrics will be called frequently to report the value update.

@can-anyscale can-anyscale 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.

data team should review i think, stamp for the protobuf change

@coqian
coqian force-pushed the coqian/data-export branch 3 times, most recently from c2e9988 to 991b41f Compare August 11, 2025 23:47
Comment on lines 13 to 22

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.

Can you help me understand why wouldn't we just inherit from str instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created this file from existing code by @omatthew98. I think the reason is that the state enum value type is defined as int for downstream usage, such as Prometheus, so there will be base type conflicts if inheriting from str at the same time.

Comment thread python/ray/data/_internal/stats.py Outdated
Comment on lines 570 to 588

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.

Let's avoid modifying objects in place and instead create a new object

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a deepcopy of dataset_metadata before updating any values, and then modified the copy instead

Comment thread python/ray/data/_internal/stats.py Outdated
Comment on lines 592 to 617

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.

Same comment as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a deepcopy of dataset_metadata before updating any values, and then modified the copy instead

@coqian
coqian force-pushed the coqian/data-export branch from 991b41f to 84da1fe Compare August 12, 2025 07:25
@coqian
coqian requested a review from alexeykudinkin August 12, 2025 16:23
Comment thread python/ray/data/_internal/stats.py Outdated
Comment on lines 592 to 599

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.

This will be making N copies, where N is the number of operators in the dataset.

Instead let's make just 1 copy and update all states at once

@coqian coqian Aug 12, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Modified the code to be able to update multiple operators in a single call, and only create one copy of the dataset metadata.

@coqian
coqian force-pushed the coqian/data-export branch 2 times, most recently from a9500c6 to 471e5af Compare August 12, 2025 23:12
@coqian
coqian requested a review from alexeykudinkin August 12, 2025 23:18
@alexeykudinkin alexeykudinkin added the go add ONLY when ready to merge, run all tests label Aug 13, 2025
@alexeykudinkin
alexeykudinkin enabled auto-merge (squash) August 13, 2025 20:34
auto-merge was automatically disabled August 13, 2025 23:16

Head branch was pushed to by a user without write access

@coqian
coqian force-pushed the coqian/data-export branch from 837369e to 4e1807b Compare August 13, 2025 23:16
@alanwguo
alanwguo merged commit 6d7234b into ray-project:master Aug 14, 2025
dioptre pushed a commit to sourcetable/ray that referenced this pull request Aug 20, 2025
…es (ray-project#55355)

<!-- Thank you for your contribution! Please review
https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before
opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?
This PR is a revert of
[ray-project#55333](ray-project#55333) and resolves
conflict by [ray-project#55163](ray-project#55163)

Original description:
Some frequently used metadata fields are missing in the export API
schema:
- For both dataset and operator: state, execution start and end time

These fields are important for us to observe the lifecycle of the
datasets and operators, and can be used to improve the accuracy of
reported metrics, such as throughput, which relies on the duration.

<!-- Please give a short summary of the change and the problem this
solves. -->
Summary of change:
- Add state, execution start and end time at the export API schema
- Add a new state enum `PENDING` for dataset and operator, to represent
the state when they are not running yet.
- Refresh the metadata when ever the state of dataset/operator gets
updated. And the event will always contains the latest snapshot of all
the metadata.

## Related issue number

<!-- For example: "Closes ray-project#1234" -->

## Checks

- [X] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [X] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [X] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Signed-off-by: cong.qian <[email protected]>
Signed-off-by: Andrew Grosser <[email protected]>
jugalshah291 pushed a commit to jugalshah291/ray_fork that referenced this pull request Sep 11, 2025
…es (ray-project#55355)

<!-- Thank you for your contribution! Please review
https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before
opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?
This PR is a revert of
[ray-project#55333](ray-project#55333) and resolves
conflict by [ray-project#55163](ray-project#55163)

Original description:
Some frequently used metadata fields are missing in the export API
schema:
- For both dataset and operator: state, execution start and end time

These fields are important for us to observe the lifecycle of the
datasets and operators, and can be used to improve the accuracy of
reported metrics, such as throughput, which relies on the duration.

<!-- Please give a short summary of the change and the problem this
solves. -->
Summary of change:
- Add state, execution start and end time at the export API schema
- Add a new state enum `PENDING` for dataset and operator, to represent
the state when they are not running yet.
- Refresh the metadata when ever the state of dataset/operator gets
updated. And the event will always contains the latest snapshot of all
the metadata.

## Related issue number

<!-- For example: "Closes ray-project#1234" -->

## Checks

- [X] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [X] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [X] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Signed-off-by: cong.qian <[email protected]>
Signed-off-by: jugalshah291 <[email protected]>
dstrodtman pushed a commit that referenced this pull request Oct 6, 2025
…es (#55355)

<!-- Thank you for your contribution! Please review
https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before
opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?
This PR is a revert of
[#55333](#55333) and resolves
conflict by [#55163](#55163)

Original description:
Some frequently used metadata fields are missing in the export API
schema:
- For both dataset and operator: state, execution start and end time

These fields are important for us to observe the lifecycle of the
datasets and operators, and can be used to improve the accuracy of
reported metrics, such as throughput, which relies on the duration.

<!-- Please give a short summary of the change and the problem this
solves. -->
Summary of change:
- Add state, execution start and end time at the export API schema
- Add a new state enum `PENDING` for dataset and operator, to represent
the state when they are not running yet.
- Refresh the metadata when ever the state of dataset/operator gets
updated. And the event will always contains the latest snapshot of all
the metadata.

## Related issue number

<!-- For example: "Closes #1234" -->

## Checks

- [X] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [X] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [X] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Signed-off-by: cong.qian <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
bveeramani pushed a commit that referenced this pull request Nov 20, 2025
… op args when refreshing metadata (#58755)

## Description
We export dataset and operator metadata whenever there is a state
change. However, the size of the export file can be very large because
the metadata also includes the DataContext config and operator args,
which does not change over time, and they will be written multiple times
to the file. To reduce the file size and remove redundant info, we can
only export DataContext and operator args when the dataset is
[registered](https://github.com/ray-project/ray/blob/d1cce8c9dc8411fad7cfbd619350bec6f19839a3/python/ray/data/_internal/stats.py#L621),
and avoid them in the later state updates.

## Related issues
Related previous PRs:
[55355](#55355),
[53554](#53554)

Signed-off-by: cong.qian <[email protected]>
SheldonTsen pushed a commit to SheldonTsen/ray that referenced this pull request Dec 1, 2025
… op args when refreshing metadata (ray-project#58755)

## Description
We export dataset and operator metadata whenever there is a state
change. However, the size of the export file can be very large because
the metadata also includes the DataContext config and operator args,
which does not change over time, and they will be written multiple times
to the file. To reduce the file size and remove redundant info, we can
only export DataContext and operator args when the dataset is
[registered](https://github.com/ray-project/ray/blob/d1cce8c9dc8411fad7cfbd619350bec6f19839a3/python/ray/data/_internal/stats.py#L621),
and avoid them in the later state updates.

## Related issues
Related previous PRs:
[55355](ray-project#55355),
[53554](ray-project#53554)

Signed-off-by: cong.qian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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