Skip to content
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

[2/X][Pipeline] Add python generation for ClassNode #22617

Merged
merged 6 commits into from
Feb 24, 2022

Conversation

jiaodong
Copy link
Member

@jiaodong jiaodong commented Feb 24, 2022

Biggest TBD is how to handle deeply nested Deployment used in init_args, where simple traversal of init_args and init_kwargs are not sufficient. This is covered in the unit test in PR and need to be fixed. Will address in next stacked diff so this one doesn't look too large.

Why are these changes needed?

  • Added backbone of ray dag -> serve dag transformation and deployment extraction.
  • Added util functions for deployment unique name generation .. ray_actor_options, replacement of DeploymentNode with deployment handle, etc.

Checks

  • 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 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
    • Unit tests
    • Release tests
    • This PR is not tested :(

Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

The parts that are filled in look good; the detailed comments and thoughtful abstractions are really appreciated!

Are you planning to address the TODOs/missing pieces here or in a follow-up? Let's make sure we can grep -r "TODO" and find nothing before the branch cut

python/ray/serve/pipeline/deployment_method_node.py Outdated Show resolved Hide resolved
python/ray/serve/pipeline/generate.py Outdated Show resolved Hide resolved
python/ray/serve/pipeline/generate.py Outdated Show resolved Hide resolved
Comment on lines +52 to +57
def _remove_non_default_ray_actor_options(ray_actor_options: Dict[str, Any]):
"""
In Ray DAG building we pass full ray_actor_options regardless if a field
was explicitly set. Since some values are invalid, we need to remove them
from ray_actor_options.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

interestingly, there's a small edge case we likely won't handle: if the user passed in one of these default explicitly, we won't error but will instead just purge it. not important IMO but if there's a simple way to handle it, might be worthwhile

Copy link
Member Author

Choose a reason for hiding this comment

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

i see, let me leave a TODO about this, we will revisit this part soon when we get to the build() implementations.

Comment on lines 80 to 91
# TODO: (jiaodong) Need to handle deeply nested deployment in args
for arg in args:
if isinstance(arg, DeploymentNode):
init_args.append(arg._deployment_handle)
else:
init_args.append(arg)
for key, value in kwargs.items():
if isinstance(value, DeploymentNode):
init_kwargs[key] = value._deployment_handle
else:
init_kwargs[key] = value
return init_args, init_kwargs
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we be able to hook into the ray DAG node arg replacement that already handles nested args?

Copy link
Contributor

Choose a reason for hiding this comment

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

this would be a very big limitation, not acceptable for public release IMO

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly -- that's the most feasible way I can think of as well, pickling / json serialization with hook on DAGNode type is the simplest way we handle nested args.

There're some details to be figured out that I didn't have a passing test yet, since we both 1) want to replace ClassNode with DeploymentNode 2) But for the deployment instance we construct and pass into DeploymentNode, we need to recursively replace all DeploymentNode with handle. I'm thinking maybe a two-pass solution is cleaner.

Let me work on this on branch #3 today and update this to be mergeable.

python/ray/serve/pipeline/generate.py Outdated Show resolved Hide resolved
python/ray/serve/pipeline/generate.py Outdated Show resolved Hide resolved
python/ray/serve/pipeline/generate.py Outdated Show resolved Hide resolved
python/ray/serve/pipeline/generate.py Outdated Show resolved Hide resolved
python/ray/serve/pipeline/tests/test_generate.py Outdated Show resolved Hide resolved
@edoakes
Copy link
Contributor

edoakes commented Feb 24, 2022

@jiaodong I think for the sake of reviewing it might be easier to address my nits and merge this branch w/o the full functionality, then make smaller follow-ups for things like nested args.

@edoakes
Copy link
Contributor

edoakes commented Feb 24, 2022

Btw, for nested deployment args, shouldn't the rag DAG API give us an interface to handle this? This would be a common pattern to basically all DAG implementations I'd assume. cc @ericl if you have thought about this

@edoakes edoakes added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Feb 24, 2022
@jiaodong jiaodong added tests-ok The tagger certifies test failures are unrelated and assumes personal liability. and removed @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. labels Feb 24, 2022
@edoakes edoakes merged commit 3c707f7 into ray-project:master Feb 24, 2022
simonsays1980 pushed a commit to simonsays1980/ray that referenced this pull request Feb 27, 2022
- Added backbone of ray dag -> serve dag transformation and deployment extraction.
- Added util functions for deployment unique name generation .. ray_actor_options, replacement of DeploymentNode with deployment handle, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants