Skip to content

Commit dc55686

Browse files
committed
Play around with AWS see if it works.
1 parent 69c5e59 commit dc55686

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

datashuttle/utils/aws.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def check_if_aws_bucket_exists(cfg: Configs) -> bool:
2020

2121
bucket_name = get_aws_bucket_name(cfg)
2222

23-
if bucket_name not in names:
23+
if bucket_name != "" and bucket_name not in names: # TODO: CHECK
2424
return False
2525

2626
return True
@@ -40,7 +40,11 @@ def raise_if_bucket_absent(cfg: Configs) -> None:
4040

4141
def get_aws_bucket_name(cfg: Configs) -> str:
4242
"""Return the formatted AWS bucket name from the `central_path`."""
43-
return cfg["central_path"].as_posix().strip("/").split("/")[0]
43+
return (
44+
cfg["central_path"].as_posix().strip("/").split("/")[0]
45+
if cfg["central_path"] is not None
46+
else ""
47+
)
4448

4549

4650
# -----------------------------------------------------------------------------

datashuttle/utils/rclone.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ def setup_rclone_config_for_aws(
305305
"s3 provider AWS "
306306
f"access_key_id {cfg['aws_access_key_id']} "
307307
f"secret_access_key {aws_secret_access_key} "
308-
f"region {cfg['aws_region']} "
309-
f"location_constraint {cfg['aws_region']}",
308+
f"region {cfg['aws_region']}",
309+
# f"location_constraint {cfg['aws_region']}",
310310
pipe_std=True,
311311
)
312312

@@ -325,7 +325,10 @@ def check_successful_connection_and_raise_error_on_fail(cfg: Configs) -> None:
325325
If the command fails, it raises a ConnectionError. The created file is
326326
deleted thereafter.
327327
"""
328-
tempfile_path = (cfg["central_path"] / "temp.txt").as_posix()
328+
tempfile_path = (
329+
cfg["central_path"] / "temp.txt"
330+
).as_posix() # TODO: HANDLE NONE!
331+
329332
output = call_rclone(
330333
f"touch {cfg.get_rclone_config_name()}:{tempfile_path}", pipe_std=True
331334
)

tests/tests_transfers/aws/aws_test_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import copy
22
import os
3+
import random
4+
import string
35

46
from datashuttle import DataShuttle
57
from datashuttle.utils import aws
68

79

810
def setup_project_for_aws(project: DataShuttle):
911
aws_bucket_name = os.environ["AWS_BUCKET_NAME"]
12+
13+
characters = string.ascii_letters + string.digits
14+
random_string = "".join(random.choices(characters, k=15))
15+
1016
project.update_config_file(
1117
connection_method="aws",
12-
central_path=f"{aws_bucket_name}/main/{project.project_name}",
18+
central_path=f"{aws_bucket_name}/main/{random_string}/{project.project_name}",
1319
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
1420
aws_region=os.environ["AWS_REGION"],
1521
)

tests/tests_transfers/aws/test_aws_transfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def aws_setup(self, pathtable_and_project):
2424
yield [pathtable, project]
2525

2626
rclone.call_rclone(
27-
f"purge central_{project.project_name}_aws:{project.cfg['central_path']}"
27+
f"purge central_{project.project_name}_aws:{project.cfg['central_path'].parent}"
2828
)
2929

3030
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)