6
6
import pathlib
7
7
import shlex
8
8
import subprocess
9
- import tempfile
10
9
import textwrap
11
10
import time
12
11
from typing import Dict , List , Optional , Tuple , Union
13
12
import uuid
14
13
import yaml
15
- import zlib
16
14
17
15
import jinja2
18
16
22
20
from sky import clouds
23
21
from sky import sky_logging
24
22
from sky import resources
25
- from sky import task as task_lib
26
23
from sky .backends import wheel_utils
27
24
from sky .adaptors import azure
28
25
from sky .skylet import log_lib
@@ -90,12 +87,7 @@ def wrap_file_mount(cls, path: str) -> str:
90
87
return os .path .join (_SKY_REMOTE_FILE_MOUNTS_DIR , path .lstrip ('/' ))
91
88
92
89
@classmethod
93
- def make_safe_symlink_command (
94
- cls ,
95
- * ,
96
- source : str ,
97
- target : str ,
98
- download_target_commands : Optional [List [str ]] = None ) -> str :
90
+ def make_safe_symlink_command (cls , * , source : str , target : str ) -> str :
99
91
"""Returns a command that safely symlinks 'source' to 'target'.
100
92
101
93
All intermediate directories of 'source' will be owned by $USER,
@@ -147,8 +139,6 @@ def make_safe_symlink_command(
147
139
f'(echo "!!! Failed mounting because path exists ({ source } )"; '
148
140
'exit 1)))' ,
149
141
]
150
- if download_target_commands is not None :
151
- commands += download_target_commands
152
142
commands += [
153
143
# Link.
154
144
f'sudo ln -s { target } { source } ' ,
@@ -311,8 +301,7 @@ def remove_cluster(cls, ip: str, auth_config: Dict[str, str]):
311
301
312
302
313
303
# TODO: too many things happening here - leaky abstraction. Refactor.
314
- def write_cluster_config (task : task_lib .Task ,
315
- to_provision : Resources ,
304
+ def write_cluster_config (to_provision : Resources ,
316
305
num_nodes : int ,
317
306
cluster_config_template : str ,
318
307
cluster_name : str ,
@@ -373,48 +362,6 @@ def write_cluster_config(task: task_lib.Task,
373
362
374
363
assert cluster_name is not None
375
364
376
- setup_sh_path = None
377
- if task .setup is not None :
378
- codegen = textwrap .dedent (f"""#!/bin/bash
379
- . $(conda info --base)/etc/profile.d/conda.sh
380
- { task .setup }
381
- """ )
382
- # Use a stable path, /<tempdir>/sky_setup_<checksum>.sh, because
383
- # rerunning the same task without any changes to the content of the
384
- # setup command should skip the setup step. Using NamedTemporaryFile()
385
- # would generate a random path every time, hence re-triggering setup.
386
- checksum = zlib .crc32 (codegen .encode ())
387
- tempdir = tempfile .gettempdir ()
388
- # TODO: file lock on this path, in case tasks have the same setup cmd.
389
- with open (os .path .join (tempdir , f'sky_setup_{ checksum } .sh' ), 'w' ) as f :
390
- f .write (codegen )
391
- setup_sh_path = f .name
392
-
393
- # File mounts handling for remote paths possibly without write access:
394
- # (1) in 'file_mounts' sections, add <prefix> to these target paths.
395
- # (2) then, create symlinks from '/.../file' to '<prefix>/.../file'.
396
- # We need to do these since as of Ray 1.8, this is not supported natively
397
- # (Docker works though, of course):
398
- # https://github.com/ray-project/ray/pull/9332
399
- # https://github.com/ray-project/ray/issues/9326
400
- mounts = task .get_local_to_remote_file_mounts ()
401
- wrapped_file_mounts = {}
402
- initialization_commands = []
403
- if mounts is not None :
404
- for remote , local in mounts .items ():
405
- if not os .path .isabs (remote ) and not remote .startswith ('~/' ):
406
- remote = f'~/{ remote } '
407
- if remote .startswith ('~/' ) or remote .startswith ('/tmp/' ):
408
- # Skip as these should be writable locations.
409
- wrapped_file_mounts [remote ] = local
410
- continue
411
- assert os .path .isabs (remote ), (remote , local )
412
- wrapped_remote = FileMountHelper .wrap_file_mount (remote )
413
- wrapped_file_mounts [wrapped_remote ] = local
414
- command = FileMountHelper .make_safe_symlink_command (
415
- source = remote , target = wrapped_remote )
416
- initialization_commands .append (command )
417
-
418
365
# TODO(suquark): once we have sky on PYPI, we should directly install sky
419
366
# from PYPI
420
367
local_wheel_path = wheel_utils .build_sky_wheel ()
@@ -424,14 +371,8 @@ def write_cluster_config(task: task_lib.Task,
424
371
resources_vars ,
425
372
** {
426
373
'cluster_name' : cluster_name ,
427
- 'setup_sh_path' : setup_sh_path ,
428
- 'workdir' : task .workdir ,
429
- 'docker_image' : task .docker_image ,
430
374
'num_nodes' : num_nodes ,
431
375
'disk_size' : to_provision .disk_size ,
432
- # File mounts handling.
433
- 'file_mounts' : wrapped_file_mounts ,
434
- 'initialization_commands' : initialization_commands or None ,
435
376
# Region/zones.
436
377
'region' : region ,
437
378
'zones' : ',' .join (zones ),
0 commit comments