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 py_modules.py AttributeError: module has no attribute '__path__' #46302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jm-nab
Copy link

@jm-nab jm-nab commented Jun 27, 2024

top level site-packages do not get imported correctly?

Why are these changes needed?

2024-06-27 14:49:14,769	INFO packaging.py:358 -- Pushing file package 'gcs://_ray_pkg_3b213a8b75cb367b.zip' (101.40MiB) to Ray cluster...
2024-06-27 14:49:15,644	INFO packaging.py:371 -- Successfully pushed file package 'gcs://_ray_pkg_3b213a8b75cb367b.zip'.
> /home/jm/repos/enterprise/vertexai_loaders/venv_311/lib/python3.11/site-packages/ray/_private/runtime_env/py_modules.py(86)upload_py_modules_if_needed()
-> pass
(Pdb) l
 81  	                        "py_modules only supports modules whose __path__ has length 1."
 82  	                    )
 83  	                [module_path] = module.__path__
 84  	            else:
 85  	                breakpoint()
 86  ->	                pass
 87  	        else:
 88  	            raise TypeError(
 89  	                "py_modules must be a list of file paths, URIs, "
 90  	                f"or imported modules, got {type(module)}."
 91  	            )
(Pdb) module
<module 'jsonpatch' from '/home/jm/repos/enterprise/vertexai_loaders/venv_311/lib/python3.11/site-packages/jsonpatch.py'>
(Pdb) dir(module)
['AddOperation', 'CopyOperation', 'DiffBuilder', 'InvalidJsonPatch', 'JsonPatch', 'JsonPatchConflict', 'JsonPatchException', 'JsonPatchTestFailed', 'JsonPointer', 'JsonPointerException', 'MappingProxyType', 'MoveOperation', 'MutableMapping', 'MutableSequence', 'PatchOperation', 'RemoveOperation', 'ReplaceOperation', 'Sequence', 'TestOperation', '_ST_ADD', '_ST_REMOVE', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__license__', '__loader__', '__name__', '__package__', '__spec__', '__version__', '__website__', '_jsonloads', '_path_join', 'apply_patch', 'basestring', 'collections', 'copy', 'functools', 'json', 'make_patch', 'multidict', 'sys', 'unicode_literals']
(Pdb) module.__package__
''
(Pdb) module.__file__
'/home/jm/repos/enterprise/vertexai_loaders/venv_311/lib/python3.11/site-packages/jsonpatch.py'
(Pdb) import os
(Pdb) os.path.dirname(module.__file__)
'/home/jm/repos/enterprise/vertexai_loaders/venv_311/lib/python3.11/site-packages'

Related issue number

Checks

  • 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 :(
    • tested locally with pdb

Here's the test:

    import enum, io, jsonpatch
    ray.init(address=raycluster_uri, runtime_env={"py_modules": [
        enum
        io
        jsonpatch,
        ]})

top level site-packages do not get imported correctly

Signed-off-by: jm-nab <146757414+jm-nab@users.noreply.github.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.

1 participant