nixpkgs/pkgs/development/python-modules/ray/default.nix

195 lines
3.4 KiB
Nix

{
lib,
buildPythonPackage,
pythonOlder,
pythonAtLeast,
python,
fetchPypi,
autoPatchelfHook,
# dependencies
aiosignal,
click,
filelock,
frozenlist,
jsonschema,
msgpack,
packaging,
protobuf,
pyyaml,
requests,
watchfiles,
# optional-dependencies
# adag
cupy,
# client
grpcio,
# data
fsspec,
numpy,
pandas,
pyarrow,
# default
aiohttp,
aiohttp-cors,
colorful,
opencensus,
prometheus-client,
pydantic,
py-spy,
smart-open,
virtualenv,
# observability
opentelemetry-api,
opentelemetry-sdk,
opentelemetry-exporter-otlp,
# rllib
dm-tree,
gymnasium,
lz4,
scikit-image,
scipy,
typer,
rich,
# serve
fastapi,
starlette,
uvicorn,
# serve-grpc
pyopenssl,
# tune
tensorboardx,
}:
let
pname = "ray";
version = "2.40.0";
in
buildPythonPackage rec {
inherit pname version;
format = "wheel";
disabled = pythonOlder "3.10" || pythonAtLeast "3.13";
src =
let
pyShortVersion = "cp${builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion}";
binary-hashes = {
cp310 = "sha256-9uqxHchJD4jnjgaqZFkFslnN4foDsV6EJhVcR4K6C74=";
cp311 = "sha256-cXEcvywVYhP9SbD5zJMYCnukJBEAcKNL3qPcCVJ/Md8=";
cp312 = "sha256-Z0dVgU9WkjBsVUytvCQBWvgj3AUW40ve8kzKydemVuM=";
};
in
fetchPypi {
inherit pname version format;
dist = pyShortVersion;
python = pyShortVersion;
abi = pyShortVersion;
platform = "manylinux2014_x86_64";
hash = binary-hashes.${pyShortVersion};
};
nativeBuildInputs = [
autoPatchelfHook
];
dependencies = [
click
aiosignal
filelock
frozenlist
jsonschema
msgpack
packaging
protobuf
pyyaml
requests
watchfiles
];
optional-dependencies = rec {
adag = [
cupy
];
air = lib.unique (data ++ serve ++ tune ++ train);
all = lib.flatten (builtins.attrValues optional-dependencies);
client = [ grpcio ];
data = [
fsspec
numpy
pandas
pyarrow
];
default = [
aiohttp
aiohttp-cors
colorful
grpcio
opencensus
prometheus-client
pydantic
py-spy
requests
smart-open
virtualenv
];
observability = [
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-otlp
];
rllib = [
dm-tree
gymnasium
lz4
pyyaml
scikit-image
scipy
typer
rich
];
serve = lib.unique (
[
fastapi
requests
starlette
uvicorn
watchfiles
]
++ default
);
serve-grpc = lib.unique (
[
grpcio
pyopenssl
]
++ serve
);
train = tune;
tune = [
fsspec
pandas
pyarrow
requests
tensorboardx
];
};
postInstall = ''
chmod +x $out/${python.sitePackages}/ray/core/src/ray/{gcs/gcs_server,raylet/raylet}
'';
pythonImportsCheck = [ "ray" ];
meta = {
description = "Unified framework for scaling AI and Python applications";
homepage = "https://github.com/ray-project/ray";
changelog = "https://github.com/ray-project/ray/releases/tag/ray-${version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ billhuang ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
platforms = [ "x86_64-linux" ];
};
}