Get the ray temp directory. If a temp dir was specified for this node, this function will retrieve the information from GCS. Otherwise, it will fallback to the default ray temp directory. Args: gcs_client: The GCS client. node_id: The ID of the node to fetch th
(gcs_client: GcsClient, node_id: str)
| 274 | |
| 275 | |
| 276 | def resolve_user_ray_temp_dir(gcs_client: GcsClient, node_id: str): |
| 277 | """ |
| 278 | Get the ray temp directory. |
| 279 | |
| 280 | If a temp dir was specified for this node, this function will |
| 281 | retrieve the information from GCS. Otherwise, it will fallback to the |
| 282 | default ray temp directory. |
| 283 | |
| 284 | Args: |
| 285 | gcs_client: The GCS client. |
| 286 | node_id: The ID of the node to fetch the temp dir for. |
| 287 | E.g.: "1a9904d8aa3de65367830e2aef6313a5b2e9d4b0e3725e0dceeacb1b" |
| 288 | (hex string representation of the node ID) |
| 289 | |
| 290 | Returns: |
| 291 | The path to the ray temp directory. |
| 292 | """ |
| 293 | # check if temp dir is available from runtime context |
| 294 | if ray.is_initialized() and ray.get_runtime_context().get_node_id() == node_id: |
| 295 | return ray.get_runtime_context().get_temp_dir() |
| 296 | |
| 297 | # Fetch temp dir as specified by --temp-dir at creation time. |
| 298 | try: |
| 299 | # Create node selector for node_id filter |
| 300 | node_selector = GetAllNodeInfoRequest.NodeSelector() |
| 301 | node_selector.node_id = NodeID.from_hex(node_id).binary() |
| 302 | |
| 303 | node_infos = gcs_client.get_all_node_info( |
| 304 | node_selectors=[node_selector], |
| 305 | state_filter=GcsNodeInfo.GcsNodeState.ALIVE, |
| 306 | ).values() |
| 307 | except Exception as e: |
| 308 | raise Exception( |
| 309 | f"Failed to get node info from GCS when fetching tempdir for node {node_id}: {e}" |
| 310 | ) |
| 311 | if not node_infos: |
| 312 | raise Exception( |
| 313 | f"No node info associated with ALIVE state found for node {node_id} in GCS" |
| 314 | ) |
| 315 | |
| 316 | node_info = next(iter(node_infos)) |
| 317 | if node_info is not None: |
| 318 | temp_dir = getattr(node_info, "temp_dir", None) |
| 319 | if temp_dir is not None: |
| 320 | return temp_dir |
| 321 | else: |
| 322 | raise Exception( |
| 323 | "Node temp_dir was not found in NodeInfo. did the node's raylet start successfully?" |
| 324 | ) |
| 325 | |
| 326 | |
| 327 | def get_default_system_temp_dir(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…