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

🎨 Update type annotations to include options in ray.remote() #25999

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

tiangolo
Copy link
Member

@tiangolo tiangolo commented Jun 22, 2022

Closes #25657.

🎨 Update type annotations to include options in ray.remote()

Why are these changes needed?

The current type annotations expect and support using:

@ray.remote
def do_things(x: int, y: float):
    return x * y

...without options.

This PR adds type annotations for passing options, as in:

@ray.remote(num_cpus=3)
def do_more_things(name: str, value: float):
    return f"{name}: {value}"

Before:

Screenshot 2022-06-22 at 04 49 11

After (autocompletion):

Screenshot 2022-06-22 at 04 50 34

...and no errors:

Screenshot 2022-06-22 at 04 51 15

Related issue number

Related to: #25657

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 :(

@ericl ericl merged commit 8bde3f5 into ray-project:master Jun 24, 2022
@ericl
Copy link
Contributor

ericl commented Jun 24, 2022

Merged, thanks!

@tiangolo tiangolo deleted the ray-remote-options branch June 28, 2022 10:27
ericl pushed a commit that referenced this pull request Jun 29, 2022
Since #25999 we need typing_extensions. It is a very light requirement (no transitive dependencies and small package) so that should be ok.

Considered alternative: Make it optional -- but that would make the typing code more brittle, and prevent us from using more typing in the future.
sihanwang41 pushed a commit that referenced this pull request Jun 29, 2022
Since #25999 we need typing_extensions. It is a very light requirement (no transitive dependencies and small package) so that should be ok.

Considered alternative: Make it optional -- but that would make the typing code more brittle, and prevent us from using more typing in the future.
truelegion47 pushed a commit to truelegion47/ray that referenced this pull request Jun 30, 2022
* master: (35 commits)
  [tune/structure] Refactor `suggest` into `search` package (ray-project#26074)
  Add back ray.state in deprecation wrapper; print stack trace on warning (ray-project#26086)
  Enable isort for base directory (ray-project#26085)
  [AIR] Add __init__.py to ray.air.callbacks (ray-project#26088)
  [Serve] [Docs] Create end-to-end documentation example for Serve REST API and CLI (ray-project#25936)
  [AIR] Remove unnecessary pandas from examples (ray-project#26009)
  [Datasets] [Hotfix] Update `ds.to_pandas()` limit error to reflect current limit API (ray-project#26081)
  [Serve] [Docs] Add Serve REST API Schema to Serve API Docs (ray-project#25786)
  [Core][Doc] remove cython section from advanced doc. ray-project#26062
  [Core] Fix check failure from incorrect death cause (ray-project#26007)
  [hotfix] Fix linkcheck (ray-project#26070)
  [RLlib] Add timeout to filter synchronization. (ray-project#25959)
  [tune/structure] Introduce logger package (ray-project#26049)
  [RLlib] introduce serialization for our custom gym space types. (ray-project#25923)
  Fix unit test test_check_env.py and est_check_multi_agent.py. (ray-project#25993)
  [RLlib] Make QMix use the ReplayBufferAPI (ray-project#25560)
  [CI] deflake test_multi_node_3 by increasing its timeout
  [CI] Use BUILDKITE_JOB_ID for better navigation for flaky tracker (ray-project#26021)
  [AIR/Docs] Improve user guide gallery (ray-project#26016)
  🎨 Update type annotations to include options in `ray.remote()` (ray-project#25999)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core] Static type checking fails for ray.remote when called with options
3 participants