Skip to content

Commit 6a51e2b

Browse files
authored
[Storage] Fix copy monuts for file with s3 bucket url (skypilot-org#1457)
* test file download with s3 * fix test * fix storage file mounts * format * remove mkdir for `make_sync_dir_command`
1 parent e889fc0 commit 6a51e2b

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

examples/managed_spot_with_storage.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ run: |
5252
5353
echo hi >> /tmp/workdir/new_file
5454
ls -al /tmp/workdir
55+
56+
cat ~/tmpfile
57+
cat ~/a/b/c/tmpfile

examples/using_file_mounts.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ file_mounts:
6969
~/data/train-00001-of-01024: gs://cloud-tpu-test-datasets/fake_imagenet/train-00001-of-01024
7070

7171
/s3-data-test: s3://fah-public-data-covid19-cryptic-pockets/human/il6/PROJ14534/RUN999/CLONE0/results0
72+
/s3-data-file: s3://fah-public-data-covid19-cryptic-pockets/human/il6/PROJ14534/RUN999/CLONE0/results0/frame0.xtc
7273
# /test-my-gcs: gs://cloud-storage-test-zhwu-2
7374

7475
# If a source path points to a "directory", its contents will be recursively
@@ -113,6 +114,7 @@ run: |
113114
ls -l ~/data/train-00001-of-01024
114115
115116
ls -l /s3-data-test
117+
cat /s3-data-file > /dev/null
116118
117119
# ls -lH /data/fake_imagenet | head -n10
118120

sky/backends/cloud_vm_ray_backend.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2975,8 +2975,8 @@ def _execute_file_mounts(self, handle: ResourceHandle,
29752975
sync = storage.make_sync_file_command(source=src,
29762976
destination=wrapped_dst)
29772977
# It is a file so make sure *its parent dir* exists.
2978-
mkdir_for_wrapped_dst = \
2979-
f'mkdir -p {os.path.dirname(wrapped_dst)}'
2978+
mkdir_for_wrapped_dst = (
2979+
f'mkdir -p {os.path.dirname(wrapped_dst)}')
29802980

29812981
download_target_commands = [
29822982
# Ensure sync can write to wrapped_dst (e.g., '/data/').

sky/cloud_stores.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,16 @@ def make_sync_dir_command(self, source: str, destination: str) -> str:
7070
# AWS Sync by default uses 10 threads to upload files to the bucket.
7171
# To increase parallelism, modify max_concurrent_requests in your
7272
# aws config file (Default path: ~/.aws/config).
73-
download_via_awscli = f'mkdir -p {destination} && \
74-
aws s3 sync --no-follow-symlinks ' \
75-
f'{source} {destination}'
73+
download_via_awscli = ('aws s3 sync --no-follow-symlinks '
74+
f'{source} {destination}')
7675

7776
all_commands = list(self._GET_AWSCLI)
7877
all_commands.append(download_via_awscli)
7978
return ' && '.join(all_commands)
8079

8180
def make_sync_file_command(self, source: str, destination: str) -> str:
8281
"""Downloads a file using AWS CLI."""
83-
download_via_awscli = (f'mkdir -p {destination} &&'
84-
f'aws s3 cp {source} {destination}')
82+
download_via_awscli = f'aws s3 cp {source} {destination}'
8583

8684
all_commands = list(self._GET_AWSCLI)
8785
all_commands.append(download_via_awscli)

0 commit comments

Comments
 (0)