Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e97f7ba
import the custom classes in controller build step
abrarsheikh Oct 3, 2025
12bb32c
fix
abrarsheikh Oct 3, 2025
7983f6b
fix api
abrarsheikh Oct 3, 2025
f00f616
check for type
abrarsheikh Oct 3, 2025
61aa96d
Merge branch 'master' into SERVE-1134-abrar-request_router
abrarsheikh Oct 15, 2025
069cfbc
refactor
abrarsheikh Oct 15, 2025
391b214
Merge branch 'master' into SERVE-1134-abrar-request_router
abrarsheikh Oct 16, 2025
20e4162
fix tests
abrarsheikh Oct 16, 2025
a704d62
nits
abrarsheikh Oct 16, 2025
66c42b1
force cloud pickle to serialize by value
abrarsheikh Oct 17, 2025
3746185
add back None check
abrarsheikh Oct 17, 2025
c0819e9
remove policy check
abrarsheikh Oct 17, 2025
4a0a295
Merge branch 'master' of github.com:ray-project/ray into SERVE-1134-a…
abrarsheikh Oct 17, 2025
d608e7d
fix test
abrarsheikh Oct 17, 2025
af0972f
use name
abrarsheikh Oct 17, 2025
e24d8a0
Merge branch 'master' of github.com:ray-project/ray into SERVE-1134-a…
abrarsheikh Oct 17, 2025
8e036ad
Merge branch 'master' of github.com:ray-project/ray into SERVE-1134-a…
abrarsheikh Oct 17, 2025
267cf96
serialize
abrarsheikh Oct 17, 2025
48ba0e5
add newline
abrarsheikh Oct 18, 2025
27b6577
remove args
abrarsheikh Oct 18, 2025
4ca7534
type check
abrarsheikh Oct 19, 2025
cce78a1
Merge branch 'master' of github.com:ray-project/ray into SERVE-1134-a…
abrarsheikh Oct 21, 2025
e8680c4
remove docstrings
abrarsheikh Oct 21, 2025
618178f
fix import
abrarsheikh Oct 21, 2025
c14c981
xMerge branch 'master' into SERVE-1134-abrar-request_router
abrarsheikh Oct 21, 2025
06846ff
denormalize
abrarsheikh Oct 21, 2025
c46e347
add back docs
abrarsheikh Oct 22, 2025
b792a11
Merge branch 'master' of github.com:ray-project/ray into SERVE-1134-a…
abrarsheikh Oct 22, 2025
13ae9b1
fix
abrarsheikh Oct 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions python/ray/_common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,26 @@
import sys
import tempfile
from inspect import signature
from typing import Any, Coroutine, Dict, Optional
from types import ModuleType
from typing import Any, Coroutine, Dict, Optional, Tuple

import psutil


def import_attr(full_path: str, *, reload_module: bool = False):
"""Given a full import path to a module attr, return the imported attr.
def import_module_and_attr(
full_path: str, *, reload_module: bool = False
) -> Tuple[ModuleType, Any]:
"""Given a full import path to a module attr, return the imported module and attr.

If `reload_module` is set, the module will be reloaded using `importlib.reload`.

For example, the following are equivalent:
MyClass = import_attr("module.submodule:MyClass")
MyClass = import_attr("module.submodule.MyClass")
from module.submodule import MyClass
Args:
full_path: The full import path to the module and attr.
reload_module: Whether to reload the module.

Returns:
Imported attr
A tuple of the imported module and attr.
"""
if full_path is None:
raise TypeError("import path cannot be None")

if ":" in full_path:
if full_path.count(":") > 1:
raise ValueError(
Expand All @@ -41,11 +40,26 @@ def import_attr(full_path: str, *, reload_module: bool = False):
last_period_idx = full_path.rfind(".")
module_name = full_path[:last_period_idx]
attr_name = full_path[last_period_idx + 1 :]

module = importlib.import_module(module_name)
if reload_module:
importlib.reload(module)
return getattr(module, attr_name)
return module, getattr(module, attr_name)


def import_attr(full_path: str, *, reload_module: bool = False) -> Any:
"""Given a full import path to a module attr, return the imported attr.

If `reload_module` is set, the module will be reloaded using `importlib.reload`.

For example, the following are equivalent:
MyClass = import_attr("module.submodule:MyClass")
MyClass = import_attr("module.submodule.MyClass")
from module.submodule import MyClass

Returns:
Imported attr
"""
return import_module_and_attr(full_path, reload_module=reload_module)[1]


def get_or_create_event_loop() -> asyncio.AbstractEventLoop:
Expand Down
Loading