Skip to content

Commit

Permalink
Bug #237, skylark now warns and aborts if object does not exist for c…
Browse files Browse the repository at this point in the history
…loud to cloud with s3 source bucket
  • Loading branch information
ethanmehta committed Apr 6, 2022
1 parent 65ea7a9 commit c066b3d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions skylark/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ def cp(
# Set up replication topology
if solve:
objs = list(src_client.list_objects(path_src))
if not objs:
logger.warning(
f"Objects do not exist."
)
raise typer.Abort()
os._exit(1)

total_gbyte_to_transfer = sum([obj.size for obj in objs]) / GB

# build problem and solve
Expand Down
7 changes: 7 additions & 0 deletions skylark/cli/cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ def replicate_helper(
else:
# make replication job
objs = list(ObjectStoreInterface.create(topo.source_region(), source_bucket).list_objects(src_key_prefix))
if not objs:
logger.warning(
f"Objects do not exist."
)
raise typer.Abort()
return 1

job = ReplicationJob(
source_region=topo.source_region(),
source_bucket=source_bucket,
Expand Down
7 changes: 4 additions & 3 deletions skylark/obj_store/s3_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from awscrt.io import ClientBootstrap, DefaultHostResolver, EventLoopGroup
from awscrt.s3 import S3Client, S3RequestTlsMode, S3RequestType
from skylark.compute.aws.aws_auth import AWSAuthentication
from skylark.utils import logger

from skylark.obj_store.object_store_interface import NoSuchObjectException, ObjectStoreInterface, ObjectStoreObject

Expand All @@ -25,8 +26,8 @@ def __init__(self, aws_region, bucket_name, use_tls=True, part_size=None, throug
self.aws_region = self.infer_s3_region(bucket_name) if aws_region is None or aws_region == "infer" else aws_region
self.bucket_name = bucket_name
if not self.bucket_exists():
typer.echo("Specified bucket does not exist.")
typer.Abort()
logger.warn("Specified bucket does not exist.")
raise typer.Abort()
event_loop_group = EventLoopGroup(num_threads=num_threads, cpu_group=None)
host_resolver = DefaultHostResolver(event_loop_group)
bootstrap = ClientBootstrap(event_loop_group, host_resolver)
Expand All @@ -48,7 +49,7 @@ def infer_s3_region(self, bucket_name: str):
region = s3_client.get_bucket_location(Bucket=bucket_name).get("LocationConstraint", "us-east-1")
return region if region is not None else "us-east-1"
except:
typer.echo("Specified bucket does not exist.")
logger.warn("Specified bucket does not exist.")
raise typer.Abort()


Expand Down
1 change: 1 addition & 0 deletions skylark/replicate/replicator_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from skylark.utils import logger
from tqdm import tqdm
import pandas as pd
import typer
from skylark import GB, KB, MB, tmp_log_dir

from skylark.benchmark.utils import refresh_instance_list
Expand Down

0 comments on commit c066b3d

Please sign in to comment.