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] Add ray-start option 'session-name' #46404

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion dashboard/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
gcs_address: The GCS address in the {address}:{port} format.
log_dir: The log directory. E.g., /tmp/session_latest/logs.
temp_dir: The temp directory. E.g., /tmp.
session_dir: The session directory. E.g., tmp/session_latest.
session_dir: The session directory. E.g., /tmp/session_latest.
minimal: Whether or not it will load the minimal modules.
serve_frontend: If configured, frontend HTML is
served from the dashboard.
Expand Down
7 changes: 5 additions & 2 deletions doc/source/ray-core/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@ If using the command line, connect to the Ray cluster as follow:
Logging and Debugging
---------------------

Each Ray session will have a unique name. By default, the name is
Each Ray session will have a unique name. By default, the name is given automatically like
``session_{timestamp}_{pid}``. The format of ``timestamp`` is
``%Y-%m-%d_%H-%M-%S_%f`` (See `Python time format <strftime.org>`__ for details);
the pid belongs to the startup process (the process calling ``ray.init()`` or
the Ray process executed by a shell in ``ray start``).

Change the *session name* by passing ``--session-name={unique session name}`` to ``ray start``.
If the given session name is not unique, the old data with the same session name may be overwritten.

For each session, Ray will place all its temporary files under the
*session directory*. A *session directory* is a subdirectory of the
*root temporary path* (``/tmp/ray`` by default),
Expand All @@ -109,7 +112,7 @@ You can sort by their names to find the latest session.

Change the *root temporary directory* by passing ``--temp-dir={your temp path}`` to ``ray start``.

(There is not currently a stable way to change the root temporary directory when calling ``ray.init()``, but if you need to, you can provide the ``_temp_dir`` argument to ``ray.init()``.)
(There is not currently a stable way to change the root temporary directory when calling ``ray.init()``, but if you need to, you can provide the ``_temp_dir`` argument to ``ray.init()``. The session name is also changable when calling ``ray.init()`` by providing ``_session_name`` argument.)

Look :ref:`Logging Directory Structure <logging-directory-structure>` for more details.

Expand Down
3 changes: 3 additions & 0 deletions python/ray/_private/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ def _init_temp(self):

try_to_create_directory(self._temp_dir)

if self._ray_params.session_name is not None:
self._session_name = self._ray_params.session_name

if self.head:
self._session_dir = os.path.join(self._temp_dir, self._session_name)
else:
Expand Down
5 changes: 5 additions & 0 deletions python/ray/_private/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@ def init(
_temp_dir: If provided, specifies the root temporary
directory for the Ray process. Must be an absolute path. Defaults to an
OS-specific conventional location, e.g., "/tmp/ray".
_session_name: The session name of the Ray process, only works when --head is
specified. If it is not unique, the old data will be overwritten.
_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 Expand Up @@ -1425,6 +1427,7 @@ def init(
"_redis_password", ray_constants.REDIS_DEFAULT_PASSWORD
)
_temp_dir: Optional[str] = kwargs.pop("_temp_dir", None)
_session_name: Optional[str] = kwargs.pop("_session_name", None)
_metrics_export_port: Optional[int] = kwargs.pop("_metrics_export_port", None)
_system_config: Optional[Dict[str, str]] = kwargs.pop("_system_config", None)
_tracing_startup_hook: Optional[Callable] = kwargs.pop(
Expand Down Expand Up @@ -1658,6 +1661,7 @@ def sigterm_handler(signum, frame):
redis_max_memory=_redis_max_memory,
plasma_store_socket_name=None,
temp_dir=_temp_dir,
session_name=_session_name,
storage=storage,
_system_config=_system_config,
enable_object_reconstruction=_enable_object_reconstruction,
Expand Down Expand Up @@ -1727,6 +1731,7 @@ def sigterm_handler(signum, frame):
redis_password=_redis_password,
object_ref_seed=None,
temp_dir=_temp_dir,
session_name=_session_name,
_system_config=_system_config,
enable_object_reconstruction=_enable_object_reconstruction,
metrics_export_port=_metrics_export_port,
Expand Down
15 changes: 15 additions & 0 deletions python/ray/scripts/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ def debug(address):
help="manually specify the root temporary dir of the Ray process, only "
"works when --head is specified",
)
@click.option(
"--session-name",
default=None,
help="The session name of the Ray process, only works when --head "
"is specified. If it is not unique, the old data will be overwritten.",
)
@click.option(
"--storage",
default=None,
Expand Down Expand Up @@ -603,6 +609,7 @@ def start(
plasma_store_socket_name,
raylet_socket_name,
temp_dir,
session_name,
storage,
system_config,
enable_object_reconstruction,
Expand Down Expand Up @@ -653,6 +660,13 @@ def start(
"All the worker nodes will use the same temp_dir as a head node. "
)
temp_dir = None
if session_name and not head:
cli_logger.warning(
f"`--session-name={session_name}` option will be ignored. "
"`--head` is a required flag to use `--session-name`. "
"All the worker nodes will use the same session_name as a head node. "
)
session_name = None

redirect_output = None if not no_redirect_output else True

Expand Down Expand Up @@ -687,6 +701,7 @@ def start(
plasma_store_socket_name=plasma_store_socket_name,
raylet_socket_name=raylet_socket_name,
temp_dir=temp_dir,
session_name=session_name,
storage=storage,
include_dashboard=include_dashboard,
dashboard_host=dashboard_host,
Expand Down
Loading