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

[Core] Check that temp_dir must be absolute path. #36431

Merged
merged 6 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion python/ray/_private/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class RayParams:
raylet_socket_name: If provided, it will specify the socket path
used by the raylet process.
temp_dir: If provided, it will specify the root temporary
directory for the Ray process.
directory for the Ray process. Must be an absolute path.
storage: Specify a URI for persistent cluster-wide storage. This storage path
must be accessible by all nodes of the cluster, otherwise an error will be
raised.
Expand Down Expand Up @@ -428,6 +428,9 @@ def build_error(resource, alternative):
"serialization. Upgrade numpy if using with ray."
)

if self.temp_dir is not None and not os.path.isabs(self.temp_dir):
raise ValueError("temp_dir must be absolute path or None.")
rynewang marked this conversation as resolved.
Show resolved Hide resolved

def _format_ports(self, pre_selected_ports):
"""Format the pre-selected ports information to be more human-readable."""
ports = pre_selected_ports.copy()
Expand Down
4 changes: 2 additions & 2 deletions python/ray/_private/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,8 @@ def init(
_redis_password: Prevents external clients without the password
from connecting to Redis if provided.
_temp_dir: If provided, specifies the root temporary
directory for the Ray process. Defaults to an OS-specific
conventional location, e.g., "/tmp/ray".
directory for the Ray process. Must be an absolute path. Defaults to an
OS-specific conventional location, e.g., "/tmp/ray".
_metrics_export_port: Port number Ray exposes system metrics
through a Prometheus endpoint. It is currently under active
development, and the API is subject to change.
Expand Down
7 changes: 7 additions & 0 deletions python/ray/tests/test_ray_init_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ def test_get_ray_address_from_environment(monkeypatch):
)


# https://github.com/ray-project/ray/issues/36431
def test_temp_dir_must_be_absolute(shutdown_only):
# This test fails with a relative path _temp_dir.
with pytest.raises(ValueError):
ray.init(_temp_dir="relative_path")


if __name__ == "__main__":
import sys

Expand Down