-
Notifications
You must be signed in to change notification settings - Fork 7k
add metadata put in workflow #19195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
add metadata put in workflow #19195
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
63ebaf9
add metadata put in workflow
lchu6 263a5cd
change type hint for step user metadata
lchu6 d06ab0e
put prerun and postrun meta into workflow_storage
lchu6 d618fb4
add workflow level metadata put
lchu6 f685598
fix type hint
lchu6 94b4734
re-order code additions
lchu6 7ad2b4c
change the location of where workflow metadata recorded
lchu6 882df49
move application logic out of workflow storage api
lchu6 5aa1b18
change checkpoint files naming
lchu6 bdc54bd
fix attribute naming change
lchu6 148bcff
fix type
lchu6 a0cb8be
change metadata file names
lchu6 bbeeb5e
add tests for workflow metadata
lchu6 6ae3aa5
change metadata name
lchu6 c496afa
add json serialization check for user metadata
lchu6 4dfc0ed
lint
lchu6 7c0fe88
‘empty’
lchu6 db34a29
try to fix
fishbone bfb67ee
up
fishbone e4f8f48
Merge remote-tracking branch 'upstream/master' into metadata
fishbone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import asyncio | ||
|
|
||
| from ray import workflow | ||
| from ray.tests.conftest import * # noqa | ||
| from ray.workflow import workflow_storage | ||
| from ray.workflow.storage import get_global_storage | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def get_metadata(paths, is_json=True): | ||
lchu6 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| store = get_global_storage() | ||
| key = store.make_key(*paths) | ||
| return asyncio.get_event_loop().run_until_complete(store.get(key, is_json)) | ||
|
|
||
|
|
||
| def test_step_user_metadata(workflow_start_regular): | ||
|
|
||
| metadata = {"k1": "v1"} | ||
| step_name = "simple_step" | ||
| workflow_id = "simple" | ||
|
|
||
| @workflow.step(name=step_name, metadata=metadata) | ||
| def simple(): | ||
| return 0 | ||
|
|
||
| simple.step().run(workflow_id) | ||
|
|
||
| checkpointed_metadata = get_metadata( | ||
| [workflow_id, "steps", step_name, workflow_storage.STEP_USER_METADATA]) | ||
| assert metadata == checkpointed_metadata | ||
|
|
||
|
|
||
| def test_step_runtime_metadata(workflow_start_regular): | ||
|
|
||
| step_name = "simple_step" | ||
| workflow_id = "simple" | ||
|
|
||
| @workflow.step(name=step_name) | ||
| def simple(): | ||
| return 0 | ||
|
|
||
| simple.step().run(workflow_id) | ||
|
|
||
| prerun_meta = get_metadata([ | ||
| workflow_id, "steps", step_name, workflow_storage.STEP_PRERUN_METADATA | ||
| ]) | ||
| postrun_meta = get_metadata([ | ||
| workflow_id, "steps", step_name, workflow_storage.STEP_POSTRUN_METADATA | ||
| ]) | ||
| assert "start_time" in prerun_meta | ||
| assert "end_time" in postrun_meta | ||
|
|
||
|
|
||
| def test_workflow_user_metadata(workflow_start_regular): | ||
|
|
||
| metadata = {"k1": "v1"} | ||
| workflow_id = "simple" | ||
|
|
||
| @workflow.step | ||
| def simple(): | ||
| return 0 | ||
|
|
||
| simple.step().run(workflow_id, metadata=metadata) | ||
|
|
||
| checkpointed_metadata = get_metadata( | ||
| [workflow_id, workflow_storage.WORKFLOW_USER_METADATA]) | ||
| assert metadata == checkpointed_metadata | ||
|
|
||
|
|
||
| def test_workflow_runtime_metadata(workflow_start_regular): | ||
|
|
||
| workflow_id = "simple" | ||
|
|
||
| @workflow.step | ||
| def simple(): | ||
| return 0 | ||
|
|
||
| simple.step().run(workflow_id) | ||
|
|
||
| prerun_meta = get_metadata( | ||
| [workflow_id, workflow_storage.WORKFLOW_PRERUN_METADATA]) | ||
| postrun_meta = get_metadata( | ||
| [workflow_id, workflow_storage.WORKFLOW_POSTRUN_METADATA]) | ||
| assert "start_time" in prerun_meta | ||
| assert "end_time" in postrun_meta | ||
|
|
||
|
|
||
| def test_all_metadata(workflow_start_regular): | ||
|
|
||
| user_step_metadata = {"k1": "v1"} | ||
| user_run_metadata = {"k2": "v2"} | ||
| step_name = "simple_step" | ||
| workflow_id = "simple" | ||
|
|
||
| @workflow.step | ||
| def simple(): | ||
| return 0 | ||
|
|
||
| simple.options( | ||
| name=step_name, metadata=user_step_metadata).step().run( | ||
| workflow_id, metadata=user_run_metadata) | ||
|
|
||
| checkpointed_user_step_metadata = get_metadata( | ||
| [workflow_id, "steps", step_name, workflow_storage.STEP_USER_METADATA]) | ||
| checkpointed_user_run_metadata = get_metadata( | ||
| [workflow_id, workflow_storage.WORKFLOW_USER_METADATA]) | ||
| checkpointed_pre_step_meta = get_metadata([ | ||
| workflow_id, "steps", step_name, workflow_storage.STEP_PRERUN_METADATA | ||
| ]) | ||
| checkpointed_post_step_meta = get_metadata([ | ||
| workflow_id, "steps", step_name, workflow_storage.STEP_POSTRUN_METADATA | ||
| ]) | ||
| checkpointed_pre_run_meta = get_metadata( | ||
| [workflow_id, workflow_storage.WORKFLOW_PRERUN_METADATA]) | ||
| checkpointed_post_run_meta = get_metadata( | ||
| [workflow_id, workflow_storage.WORKFLOW_POSTRUN_METADATA]) | ||
| assert user_step_metadata == checkpointed_user_step_metadata | ||
| assert user_run_metadata == checkpointed_user_run_metadata | ||
| assert "start_time" in checkpointed_pre_step_meta | ||
| assert "start_time" in checkpointed_pre_run_meta | ||
| assert "end_time" in checkpointed_post_step_meta | ||
| assert "end_time" in checkpointed_post_run_meta | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| import sys | ||
| sys.exit(pytest.main(["-v", __file__])) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.