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

[air] fix pyarrow lazy import #37670

Merged
merged 1 commit into from
Jul 25, 2023
Merged

Conversation

matthewdeng
Copy link
Contributor

Why are these changes needed?

#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported. This leads to the following error:

>>> from ray import tune
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/matt/miniconda3/envs/test-tune/lib/python3.9/site-packages/ray/tune/__init__.py", line 2, in <module>
    from ray.tune.tune import run_experiments, run
  File "/Users/matt/miniconda3/envs/test-tune/lib/python3.9/site-packages/ray/tune/tune.py", line 27, in <module>
    from ray.air import CheckpointConfig
  File "/Users/matt/miniconda3/envs/test-tune/lib/python3.9/site-packages/ray/air/__init__.py", line 1, in <module>
    from ray.air.checkpoint import Checkpoint
  File "/Users/matt/miniconda3/envs/test-tune/lib/python3.9/site-packages/ray/air/checkpoint.py", line 22, in <module>
    from ray.air._internal.remote_storage import (
  File "/Users/matt/miniconda3/envs/test-tune/lib/python3.9/site-packages/ray/air/_internal/remote_storage.py", line 142, in <module>
    _cached_fs: Dict[tuple, Tuple[float, pyarrow.fs.FileSystem]] = {}
AttributeError: 'NoneType' object has no attribute 'fs'

Note that functionality that does rely on pyarrow will call the following utility function and raise a descriptive error if it is not installed:

def _assert_pyarrow_installed():
if pyarrow is None:
raise RuntimeError(
"Uploading, downloading, and deleting from cloud storage "
"requires pyarrow to be installed. Install with: "
"`pip install pyarrow`. Subsequent calls to cloud operations "
"will be ignored."
)

Related issue number

Closes #37656

Checks

Verified locally that running from ray import tune succeeds.

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • 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
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Matthew Deng <matt@anyscale.com>
@krfricke krfricke merged commit 39d11bc into ray-project:master Jul 25, 2023
77 of 82 checks passed
@rickyyx
Copy link
Contributor

rickyyx commented Jul 27, 2023

are we cherry picking this?

matthewdeng added a commit to matthewdeng/ray that referenced this pull request Jul 28, 2023
ray-project#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported. 

Signed-off-by: Matthew Deng <matt@anyscale.com>
rickyyx pushed a commit that referenced this pull request Jul 28, 2023
#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported.

Signed-off-by: Matthew Deng <matt@anyscale.com>
NripeshN pushed a commit to NripeshN/ray that referenced this pull request Aug 15, 2023
ray-project#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported.

Signed-off-by: Matthew Deng <matt@anyscale.com>
Signed-off-by: NripeshN <nn2012@hw.ac.uk>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
ray-project#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported.

Signed-off-by: Matthew Deng <matt@anyscale.com>
Signed-off-by: harborn <gangsheng.wu@intel.com>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
ray-project#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported. 

Signed-off-by: Matthew Deng <matt@anyscale.com>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
ray-project#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported.

Signed-off-by: Matthew Deng <matt@anyscale.com>
Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
vymao pushed a commit to vymao/ray that referenced this pull request Oct 11, 2023
ray-project#35938 introduced a pyarrow typehint, though pyarrow is being lazily imported.

Signed-off-by: Matthew Deng <matt@anyscale.com>
Signed-off-by: Victor <vctr.y.m@example.com>
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.

[Air] Missing pyarrow module causes import issues
3 participants