Skip to content

Commit

Permalink
pass put_file
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Dec 27, 2024
1 parent b66c754 commit a7768a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion api/python/quilt3/data_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ def add_put_options_safely(params: dict, put_options: Optional[dict]):
Add put options to the params dictionary safely.
This method ensures that the put options do not overwrite existing keys in the params dictionary.
"""
print(f"add_put_options_safely.put_options: {put_options}")
if put_options:
for key, value in put_options.items():
if key in params:
raise ValueError(f"Key {key} already exists in params.")
params[key] = value
print(f"add_put_options_safely.PARAMS: {params}")


class S3Api(Enum):
Expand Down Expand Up @@ -930,7 +932,7 @@ def sanity_check(rel_path):
src = PhysicalKey(src.bucket, src.path, version_id)
url_list.append((src, dest, size))

_copy_file_list_internal(url_list, [None] * len(url_list), message, callback, put_options=None)
_copy_file_list_internal(url_list, [None] * len(url_list), message, callback, put_options=put_options)


def put_bytes(data: bytes, dest: PhysicalKey, put_options=None):
Expand Down
Empty file.
11 changes: 5 additions & 6 deletions api/python/tests/integration/test_put_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
print(f"TEST_BUCKET: {TEST_BUCKET}")
print(f"TEST_SRC: {TEST_SRC}")

def dest_file(test_name):
return f"{TEST_BUCKET}/test/{test_name}"
def dest_key(test_name):
return f"test/{test_name}/{TEST_FILE}"

def test_bucket_put_file():
dest = dest_file("test_bucket_put_file")
dest = dest_key("test_bucket_put_file")
print(f"DEST: {dest}")
bucket = Bucket(TEST_BUCKET)

# bucket.put_file(TEST_SRC, dest_file("test_bucket_put_file"))
bucket.put_file(TEST_SRC,
dest_file("test_bucket_put_file"),
# bucket.put_file(TEST_SRC, dest_key("test_bucket_put_file"))
bucket.put_file(dest_key("test_bucket_put_file"), TEST_SRC,
put_options={"ServerSideEncryption": "aws:kms"})

0 comments on commit a7768a7

Please sign in to comment.