chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:17:40 +08:00
commit f1825c8ceb
10096 changed files with 2364182 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
Apache 2.0
+3
View File
@@ -0,0 +1,3 @@
include ray/autoscaler/ray-schema.json
include ray/py.typed
recursive-include ray *.pyi
+50
View File
@@ -0,0 +1,50 @@
# Building manylinux2014 wheels
**WARNING:** To cause everything to be rebuilt, this script will delete ALL changes to the
repository, including both changes to tracked files, and ANY untracked files.
It will also cause all files inside the repository to be owned by root, and
produce .whl files owned by root.
Inside the root directory (i.e., one level above this python directory), run
```
docker run -ti --rm \
-e HOST_UID=$(id -u) \
-e HOST_GID=$(id -g) \
-e BUILDKITE_COMMIT="$(git rev-parse HEAD)" \
-e BUILD_ONE_PYTHON_ONLY=py39 \
-w /ray -v "$(pwd)":/ray \
-e HOME=/tmp \
quay.io/pypa/manylinux2014_x86_64:2026.01.02-1 \
/ray/python/build-wheel-manylinux2014.sh
```
The Python 3.9 wheel files will be placed in the `.whl` directory.
One can change the value of `BUILDKITE_COMMIT` to generate wheels with
different built-in commit string (the code is not changed) and
`BUILD_ONE_PYTHON_ONLY` to build wheels of different Python versions.
For arm64 / aarch64 architecture, use the `quay.io/pypa/manylinux2014_aarch64`
image:
```
docker run -ti --rm \
-e BUILDKITE_COMMIT="$(git rev-parse HEAD)" \
-e BUILD_ONE_PYTHON_ONLY=py39 \
-w /ray -v "$(pwd)":/ray \
quay.io/pypa/manylinux2014_aarch64:2026.01.02-1 \
/ray/python/build-wheel-manylinux2014.sh
```
## Building MacOS wheels
To build wheels for MacOS, run the following inside the root directory (i.e.,
one level above this python directory).
```
./python/build-wheel-macos.sh
```
The script uses `sudo` multiple times, so you may need to type in a password.
+92
View File
@@ -0,0 +1,92 @@
#!/bin/bash
# Cause the script to exit if a single command fails.
set -e
# Show explicitly which commands are currently running.
set -x
DOWNLOAD_DIR=python_downloads
NODE_VERSION="14"
PY_MMS=("3.10" "3.11" "3.12" "3.13" "3.14")
if [[ -n "${SKIP_DEP_RES}" ]]; then
./ci/env/install-bazel.sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
if [ "$(uname -m)" = "arm64" ]; then
curl -o- https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh | bash
else
curl -sSL -o- https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh | bash
fi
conda init bash
source ~/.bash_profile
# Use the latest version of Node.js in order to build the dashboard.
source "$HOME"/.nvm/nvm.sh
nvm install $NODE_VERSION
nvm use $NODE_VERSION
fi
# Build the dashboard so its static assets can be included in the wheel.
pushd python/ray/dashboard/client
source "$HOME"/.nvm/nvm.sh
npm ci
npm run build
popd
mkdir -p .whl
for ((i=0; i<${#PY_MMS[@]}; ++i)); do
PY_MM=${PY_MMS[i]}
CONDA_ENV_NAME="p$PY_MM"
# The -f flag is passed twice to also run git clean in the arrow subdirectory.
# The -d flag removes directories. The -x flag ignores the .gitignore file,
# and the -e flag ensures that we don't remove the .whl directory.
git clean -f -f -x -d -e .whl -e $DOWNLOAD_DIR -e python/ray/dashboard/client -e dashboard/client
# Install python using conda. This should be easier to produce consistent results in buildkite and locally.
[ ! -f "$HOME/.bash_profile" ] && conda init bash
source ~/.bash_profile
conda create -y -n "$CONDA_ENV_NAME"
conda activate "$CONDA_ENV_NAME"
conda remove -y python || true
conda install -y python="$PY_MM" pip=25.2
# NOTE: We expect conda to set the PATH properly.
PIP_CMD=pip
if [ -z "${TRAVIS_COMMIT}" ]; then
TRAVIS_COMMIT=${BUILDKITE_COMMIT}
fi
pushd python
$PIP_CMD install -q setuptools==80.9.0 cython==3.0.12 wheel
# Set the commit SHA in _version.py.
if [ -n "$TRAVIS_COMMIT" ]; then
echo "TRAVIS_COMMIT variable detected. ray.__commit__ will be set to $TRAVIS_COMMIT"
else
echo "TRAVIS_COMMIT variable is not set, getting the current commit from git."
TRAVIS_COMMIT=$(git rev-parse HEAD)
fi
sed -i .bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/_version.py && rm ray/_version.py.bak
# Add the correct Python to the path and build the wheel. This is only
# needed so that the installation finds the cython executable.
# build ray wheel
$PIP_CMD wheel -v -w dist . --no-deps
# build ray-cpp wheel
RAY_INSTALL_CPP=1 $PIP_CMD wheel -q -w dist . --no-deps
mv dist/*.whl ../.whl/
popd
# cleanup
conda deactivate
conda env remove -y -n "$CONDA_ENV_NAME"
done
+70
View File
@@ -0,0 +1,70 @@
#!/bin/bash
set -exuo pipefail
# Host user UID/GID
HOST_UID=${HOST_UID:-$(id -u)}
HOST_GID=${HOST_GID:-$(id -g)}
if [ "$EUID" -eq 0 ]; then
# Install sudo
yum -y install sudo
# Create group and user
groupadd -g "$HOST_GID" builduser
useradd -m -u "$HOST_UID" -g "$HOST_GID" -d /ray builduser
# Give sudo access
echo "builduser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
exec sudo -E -u builduser HOME="$HOME" bash "$0" "$@"
exit 0
fi
export RAY_INSTALL_JAVA="${RAY_INSTALL_JAVA:-0}"
# Python version key, interpreter version code
PYTHON_VERSIONS=(
"py39 cp39-cp39"
"py310 cp310-cp310"
"py311 cp311-cp311"
"py312 cp312-cp312"
"py313 cp313-cp313"
)
# Setup runtime environment
./ci/build/build-manylinux-forge.sh
# Compile ray
./ci/build/build-manylinux-ray.sh
# Build ray wheel
for PYTHON_VERSIONS in "${PYTHON_VERSIONS[@]}" ; do
PYTHON_VERSION_KEY="$(echo "${PYTHON_VERSIONS}" | cut -d' ' -f1)"
if [[ "${BUILD_ONE_PYTHON_ONLY:-}" != "" && "${PYTHON_VERSION_KEY}" != "${BUILD_ONE_PYTHON_ONLY}" ]]; then
continue
fi
PYTHON="$(echo "${PYTHON_VERSIONS}" | cut -d' ' -f2)"
echo "--- Build wheel for ${PYTHON}"
# The -f flag is passed twice to also run git clean in the arrow subdirectory.
# The -d flag removes directories. The -x flag ignores the .gitignore file,
# and the -e flag ensures that we don't remove the .whl directory, the
# dashboard directory and jars directory, as well as the compiled
# dependency constraints.
git clean -f -f -x -d -e .whl -e python/ray/dashboard/client -e dashboard/client -e python/ray/jars -e python/requirements_compiled.txt
./ci/build/build-manylinux-wheel.sh "${PYTHON}"
done
# Clean the build output so later operations is on a clean directory.
git clean -f -f -x -d -e .whl -e python/ray/dashboard/client -e python/requirements_compiled.txt
bazel clean
# Build ray jar
./ci/build/build-manylinux-jar.sh
+120
View File
@@ -0,0 +1,120 @@
#!/usr/bin/env bash
set -euxo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)"
WORKSPACE_DIR="${ROOT_DIR}/.."
get_python_version() {
python -s -c "import sys; sys.stdout.write('%s.%s' % sys.version_info[:2])"
}
is_python_version() {
local expected result=0
expected="$1"
case "$(get_python_version).0." in
"${expected}".*) ;;
*) result=1;;
esac
case "$(pip --version | tr -d "\r")" in
*" (python ${expected})") ;;
*) result=1;;
esac
return "${result}"
}
refreshenv() {
# https://gist.github.com/jayvdb/1daf8c60e20d64024f51ec333f5ce806
powershell -NonInteractive - <<\EOF
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
# Print out the list of env vars we're going to export.
# Sometimes the bash source fails, this will help with debugging.
gci env:
# Round brackets in variable names cause problems with bash
Get-ChildItem env:* | %{
if (!($_.Name.Contains('('))) {
$value = $_.Value
if ($_.Name -eq 'PATH') {
$value = $value -replace ';',':'
}
# Use heredocs to wrap values. This fixes problems with environment variables containing single quotes.
# An environment variable containing the string REFRESHENV_EOF could still cause problems, but is
# far less likely than a single quote.
Write-Output ("export " + $_.Name + "=$`(cat <<- 'REFRESHENV_EOF'`n" + $value + "`nREFRESHENV_EOF`)")
}
} | Out-File -Encoding ascii $env:TEMP\refreshenv.sh
EOF
source "$TEMP/refreshenv.sh"
}
build_dashboard() {
pushd python/ray/dashboard/client
choco install nodejs --version=22.4.1 -y
refreshenv
# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported
export NODE_OPTIONS=--openssl-legacy-provider
npm install
npm run build
popd
}
build_wheel_windows() {
if [[ "${BUILD_ONE_PYTHON_ONLY:-}" == "" ]]; then
echo "Please set BUILD_ONE_PYTHON_ONLY . Building all python versions is no longer supported."
exit 1
fi
local local_dir="python/dist"
{
echo "build --announce_rc";
echo "build --config=ci";
echo "startup --output_user_root=c:/raytmp";
echo "build --remote_cache=${BUILDKITE_BAZEL_CACHE_URL}";
} >> ~/.bazelrc
if [[ "${BUILDKITE_CACHE_READONLY:-}" == "true" ]]; then
echo "build --remote_upload_local_results=false" >> ~/.bazelrc
fi
local pyversion="${BUILD_ONE_PYTHON_ONLY}"
git clean -q -f -f -x -d -e "${local_dir}" -e python/ray/dashboard/client
git checkout -q -f -- .
# Start a subshell to prevent PATH and cd from affecting our shell environment
(
unset PYTHON2_BIN_PATH PYTHON3_BIN_PATH # make sure these aren't set by some chance
build_dashboard
cd "${WORKSPACE_DIR}"/python
# Set the commit SHA in _version.py.
if [[ -n "${BUILDKITE_COMMIT:-}" ]]; then
sed -i.bak "s/{{RAY_COMMIT_SHA}}/$BUILDKITE_COMMIT/g" ray/_version.py && rm ray/_version.py.bak
else
echo "BUILDKITE_COMMIT variable not set - required to populated ray.__commit__."
exit 1
fi
# build ray wheel and ray-cpp wheel
# delvewheel packs any needed system dlls like msvcp140.dll
uv run --no-project --no-config --no-cache \
--with wheel==0.45.1 \
--with delvewheel==1.11.2 \
--with setuptools==80.9.0 \
--with pip==25.2 \
--python "${pyversion}" \
/bin/bash -o pipefail -ec "
python -m pip wheel -v -w dist . --no-deps --use-pep517
delvewheel repair dist/ray-*.whl
RAY_INSTALL_CPP=1 python -m pip wheel -v -w dist . --no-deps --use-pep517
"
)
}
build_wheel_windows "$@"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
--index-url https://pypi.org/simple
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via
# -c /tmp/ray-deps/requirements_compiled_py3.13.txt
# -r python/requirements/ml/py313/third_party.txt
psutil==5.9.8 \
--hash=sha256:02615ed8c5ea222323408ceba16c60e99c3f91639b07da6373fb7e6539abc56d \
--hash=sha256:05806de88103b25903dff19bb6692bd2e714ccf9e668d050d144012055cbca73 \
--hash=sha256:26bd09967ae00920df88e0352a91cff1a78f8d69b3ecabbfe733610c0af486c8 \
--hash=sha256:27cc40c3493bb10de1be4b3f07cae4c010ce715290a5be22b98493509c6299e2 \
--hash=sha256:36f435891adb138ed3c9e58c6af3e2e6ca9ac2f365efe1f9cfef2794e6c93b4e \
--hash=sha256:50187900d73c1381ba1454cf40308c2bf6f34268518b3f36a9b663ca87e65e36 \
--hash=sha256:611052c4bc70432ec770d5d54f64206aa7203a101ec273a0cd82418c86503bb7 \
--hash=sha256:6be126e3225486dff286a8fb9a06246a5253f4c7c53b475ea5f5ac934e64194c \
--hash=sha256:7d79560ad97af658a0f6adfef8b834b53f64746d45b403f225b85c5c2c140eee \
--hash=sha256:8cb6403ce6d8e047495a701dc7c5bd788add903f8986d523e3e20b98b733e421 \
--hash=sha256:8db4c1b57507eef143a15a6884ca10f7c73876cdf5d51e713151c1236a0e68cf \
--hash=sha256:aee678c8720623dc456fa20659af736241f575d79429a0e5e9cf88ae0605cc81 \
--hash=sha256:bc56c2a1b0d15aa3eaa5a60c9f3f8e3e565303b465dbf57a1b730e7a2b9844e0 \
--hash=sha256:bd1184ceb3f87651a67b2708d4c3338e9b10c5df903f2e3776b62303b26cb631 \
--hash=sha256:d06016f7f8625a1825ba3732081d77c94589dca78b7a3fc072194851e88461a4 \
--hash=sha256:d16bbddf0693323b8c6123dd804100241da461e41d6e332fb0ba6058f630f8c8
# via
# -c /tmp/ray-deps/requirements_compiled_py3.13.txt
# -r python/requirements/ml/py313/third_party.txt
@@ -0,0 +1,28 @@
--index-url https://pypi.org/simple
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via
# -c /tmp/ray-deps/requirements_compiled_py3.13.txt
# -r python/requirements/ml/py313/third_party.txt
psutil==5.9.8 \
--hash=sha256:02615ed8c5ea222323408ceba16c60e99c3f91639b07da6373fb7e6539abc56d \
--hash=sha256:05806de88103b25903dff19bb6692bd2e714ccf9e668d050d144012055cbca73 \
--hash=sha256:26bd09967ae00920df88e0352a91cff1a78f8d69b3ecabbfe733610c0af486c8 \
--hash=sha256:27cc40c3493bb10de1be4b3f07cae4c010ce715290a5be22b98493509c6299e2 \
--hash=sha256:36f435891adb138ed3c9e58c6af3e2e6ca9ac2f365efe1f9cfef2794e6c93b4e \
--hash=sha256:50187900d73c1381ba1454cf40308c2bf6f34268518b3f36a9b663ca87e65e36 \
--hash=sha256:611052c4bc70432ec770d5d54f64206aa7203a101ec273a0cd82418c86503bb7 \
--hash=sha256:6be126e3225486dff286a8fb9a06246a5253f4c7c53b475ea5f5ac934e64194c \
--hash=sha256:7d79560ad97af658a0f6adfef8b834b53f64746d45b403f225b85c5c2c140eee \
--hash=sha256:8cb6403ce6d8e047495a701dc7c5bd788add903f8986d523e3e20b98b733e421 \
--hash=sha256:8db4c1b57507eef143a15a6884ca10f7c73876cdf5d51e713151c1236a0e68cf \
--hash=sha256:aee678c8720623dc456fa20659af736241f575d79429a0e5e9cf88ae0605cc81 \
--hash=sha256:bc56c2a1b0d15aa3eaa5a60c9f3f8e3e565303b465dbf57a1b730e7a2b9844e0 \
--hash=sha256:bd1184ceb3f87651a67b2708d4c3338e9b10c5df903f2e3776b62303b26cb631 \
--hash=sha256:d06016f7f8625a1825ba3732081d77c94589dca78b7a3fc072194851e88461a4 \
--hash=sha256:d16bbddf0693323b8c6123dd804100241da461e41d6e332fb0ba6058f630f8c8
# via
# -c /tmp/ray-deps/requirements_compiled_py3.13.txt
# -r python/requirements/ml/py313/third_party.txt
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
ray[all] @ file://.whl/ray-100.0.0.dev0-py3-none-any.whl
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,4 @@
tensorflow==2.20.0
tensorflow-datasets==4.9.9
pyarrow==17.0.0
numpy==1.26.4
+299
View File
@@ -0,0 +1,299 @@
# isort: skip_file
from ray._private import log # isort: skip # noqa: F401
import logging
import os
import sys
from typing import TYPE_CHECKING
log.generate_logging_config()
logger = logging.getLogger(__name__)
def _configure_system():
import os
import platform
import sys
"""Wraps system configuration to avoid 'leaking' variables into ray."""
# Sanity check pickle5 if it has been installed.
if "pickle5" in sys.modules:
if sys.version_info >= (3, 8):
logger.warning(
"Package pickle5 becomes unnecessary in Python 3.8 and above. "
"Its presence may confuse libraries including Ray. "
"Please uninstall the package."
)
import importlib.metadata
try:
version_str = importlib.metadata.version("pickle5")
version = tuple(int(n) for n in version_str.split("."))
if version < (0, 0, 10):
logger.warning(
"Although not used by Ray, a version of pickle5 that leaks memory "
"is found in the environment. Please run 'pip install pickle5 -U' "
"to upgrade."
)
except importlib.metadata.PackageNotFoundError:
logger.warning(
"You are using the 'pickle5' module, but "
"the exact version is unknown (possibly carried as "
"an internal component by another module). Please "
"make sure you are using pickle5 >= 0.0.10 because "
"previous versions may leak memory."
)
# Importing psutil. Must be before ray._raylet is
# initialized.
thirdparty_files = os.path.join(
os.path.abspath(os.path.dirname(__file__)), "thirdparty_files"
)
sys.path.insert(0, thirdparty_files)
if (
platform.system() == "Linux"
and "Microsoft".lower() in platform.release().lower()
):
from ray._private import compat # noqa: E402
compat.patch_psutil()
# Expose ray ABI symbols which may be dependent by other shared
# libraries such as _streaming.so. See BUILD.bazel:_raylet
python_shared_lib_suffix = ".so" if sys.platform != "win32" else ".pyd"
so_path = os.path.join(
os.path.dirname(__file__), "_raylet" + python_shared_lib_suffix
)
if os.path.exists(so_path):
import ctypes
from ctypes import CDLL
CDLL(so_path, ctypes.RTLD_GLOBAL)
_configure_system()
# Delete configuration function.
del _configure_system
from ray import _version # noqa: E402
__commit__ = _version.commit
__version__ = _version.version
import ray._raylet # noqa: E402
from ray._raylet import ( # noqa: E402,F401
ActorClassID,
ActorID,
NodeID,
Config as _Config,
JobID,
WorkerID,
FunctionID,
ObjectID,
ObjectRef,
ObjectRefGenerator,
DynamicObjectRefGenerator,
TaskID,
UniqueID,
Language,
PlacementGroupID,
ClusterID,
)
_config = _Config()
from ray._private.state import ( # noqa: E402,F401
nodes,
timeline,
cluster_resources,
available_resources,
)
from ray._private.worker import ( # noqa: E402,F401
SCRIPT_MODE,
WORKER_MODE,
RESTORE_WORKER_MODE,
SPILL_WORKER_MODE,
cancel,
get,
get_actor,
get_gpu_ids,
init,
is_initialized,
put,
kill,
remote,
shutdown,
wait,
)
from ray._private.ray_logging.logging_config import LoggingConfig # noqa: E402
# We import ray.actor because some code is run in actor.py which initializes
# some functions in the worker.
import ray.actor # noqa: E402,F401
from ray.actor import method # noqa: E402,F401
# TODO(qwang): We should remove this exporting in Ray2.0.
from ray.cross_language import java_function, java_actor_class # noqa: E402,F401
from ray.runtime_context import get_runtime_context # noqa: E402,F401
from ray import internal # noqa: E402,F401
from ray import util # noqa: E402,F401
from ray import _private # noqa: E402,F401
# We import ClientBuilder so that modules can inherit from `ray.ClientBuilder`.
from ray.client_builder import client, ClientBuilder # noqa: E402,F401
class _DeprecationWrapper:
def __init__(self, name, real_worker):
self._name = name
self._real_worker = real_worker
self._warned = set()
def __getattr__(self, attr):
value = getattr(self._real_worker, attr)
if attr not in self._warned:
self._warned.add(attr)
logger.warning(
f"DeprecationWarning: `ray.{self._name}.{attr}` is a private "
"attribute and access will be removed in a future Ray version."
)
return value
# TODO(ekl) remove this entirely after 3rd party libraries are all migrated.
worker = _DeprecationWrapper("worker", ray._private.worker)
ray_constants = _DeprecationWrapper("ray_constants", ray._private.ray_constants)
serialization = _DeprecationWrapper("serialization", ray._private.serialization)
state = _DeprecationWrapper("state", ray._private.state)
# Pulic Ray APIs
__all__ = [
"__version__",
"_config",
"get_runtime_context",
"autoscaler",
"available_resources",
"cancel",
"client",
"ClientBuilder",
"cluster_resources",
"get",
"get_actor",
"get_gpu_ids",
"init",
"is_initialized",
"java_actor_class",
"java_function",
"cpp_function",
"kill",
"Language",
"method",
"nodes",
"put",
"remote",
"shutdown",
"timeline",
"wait",
"SCRIPT_MODE",
"WORKER_MODE",
"LoggingConfig",
]
# Public APIs that should automatically trigger ray.init().
AUTO_INIT_APIS = {
"cancel",
"get",
"get_actor",
"get_gpu_ids",
"kill",
"put",
"wait",
"get_runtime_context",
}
# Public APIs that should not automatically trigger ray.init().
NON_AUTO_INIT_APIS = {
"ClientBuilder",
"Language",
"SCRIPT_MODE",
"WORKER_MODE",
"__version__",
"_config",
"autoscaler",
"available_resources",
"client",
"cluster_resources",
"cpp_function",
"init",
"is_initialized",
"java_actor_class",
"java_function",
"method",
"nodes",
"remote",
"shutdown",
"timeline",
"LoggingConfig",
}
assert set(__all__) == AUTO_INIT_APIS | NON_AUTO_INIT_APIS
from ray._private.auto_init_hook import wrap_auto_init_for_all_apis # noqa: E402
wrap_auto_init_for_all_apis(AUTO_INIT_APIS)
del wrap_auto_init_for_all_apis
# Subpackages
__all__ += [
"actor",
"autoscaler",
"data",
"internal",
"util",
"widgets",
"workflow",
]
# ID types
__all__ += [
"ActorClassID",
"ActorID",
"NodeID",
"JobID",
"WorkerID",
"FunctionID",
"ObjectID",
"ObjectRef",
"ObjectRefGenerator",
"DynamicObjectRefGenerator",
"TaskID",
"UniqueID",
"PlacementGroupID",
]
# Delay importing of expensive, isolated subpackages. Note that for proper type
# checking support these imports must be kept in sync between type checking and
# runtime behavior.
if TYPE_CHECKING:
from ray import autoscaler
from ray import data
from ray import workflow
else:
def __getattr__(name: str):
import importlib
if name in ["data", "workflow", "autoscaler"]:
return importlib.import_module("." + name, __name__)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
del os
del logging
del sys
del TYPE_CHECKING

Some files were not shown because too many files have changed in this diff Show More