diff --git a/skylark/cli/cli.py b/skylark/cli/cli.py index f89788a49..fe8c8ca07 100644 --- a/skylark/cli/cli.py +++ b/skylark/cli/cli.py @@ -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 diff --git a/skylark/cli/cli_helper.py b/skylark/cli/cli_helper.py index 15ebbd978..3574ed64b 100644 --- a/skylark/cli/cli_helper.py +++ b/skylark/cli/cli_helper.py @@ -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, diff --git a/skylark/obj_store/s3_interface.py b/skylark/obj_store/s3_interface.py index fc28a5c38..507b9b9e9 100644 --- a/skylark/obj_store/s3_interface.py +++ b/skylark/obj_store/s3_interface.py @@ -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 @@ -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) @@ -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() diff --git a/skylark/replicate/replicator_client.py b/skylark/replicate/replicator_client.py index eb3926b8e..3e5e9c4ac 100644 --- a/skylark/replicate/replicator_client.py +++ b/skylark/replicate/replicator_client.py @@ -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