diff --git a/deepsearch/cps/cli/data_indices_typer.py b/deepsearch/cps/cli/data_indices_typer.py index ade0f569..fd689fb6 100644 --- a/deepsearch/cps/cli/data_indices_typer.py +++ b/deepsearch/cps/cli/data_indices_typer.py @@ -55,7 +55,8 @@ def list( for index in indices ] except ValueError as e: - print(f"Error occurred: {e}") + typer.echo(f"Error occurred: {e}") + raise typer.Abort() cli_output(results, output, headers="keys") return @@ -157,7 +158,7 @@ def upload_files( raise typer.Abort() coords = ElasticProjectDataCollectionSource(proj_key=proj_key, index_key=index_key) - utils.upload_files( + statuses = utils.upload_files( api=api, coords=coords, url=urls, @@ -165,6 +166,12 @@ def upload_files( s3_coordinates=cos_coordinates, ) + if all([status == "SUCCESS" for status in statuses]): + typer.echo("File upload completed successfully") + else: + # TODO + typer.echo("Some files did not upload successfully") + @app.command( name="add-attachment", help="Add attachment to a index item", no_args_is_help=True diff --git a/deepsearch/cps/cli/projects.py b/deepsearch/cps/cli/projects.py index 7b0e6eb7..e82c3903 100644 --- a/deepsearch/cps/cli/projects.py +++ b/deepsearch/cps/cli/projects.py @@ -49,7 +49,7 @@ def assign_user( role=role, ) else: - print("Project not found") + typer.echo("Project not found") raise typer.Exit(code=1) @@ -63,7 +63,7 @@ def remove( if project is not None: api.projects.remove(project=project) else: - print("Project not found") + typer.echo("Project not found") raise typer.Exit(code=1) diff --git a/deepsearch/cps/data_indices/utils.py b/deepsearch/cps/data_indices/utils.py index 53058035..938d72b0 100644 --- a/deepsearch/cps/data_indices/utils.py +++ b/deepsearch/cps/data_indices/utils.py @@ -13,7 +13,7 @@ from deepsearch.cps.client.components.data_indices import S3Coordinates from deepsearch.cps.client.components.elastic import ElasticProjectDataCollectionSource from deepsearch.documents.core import convert, input_process -from deepsearch.documents.core.common_routines import progressbar, success_message +from deepsearch.documents.core.common_routines import progressbar from deepsearch.documents.core.utils import cleanup, create_root_dir logger = logging.getLogger(__name__) @@ -92,9 +92,8 @@ def process_url_input( statuses = convert.check_cps_status_running_tasks( api=api, cps_proj_key=coords.proj_key, task_ids=task_ids ) - print(success_message) - return + return statuses def process_local_file( @@ -158,9 +157,9 @@ def process_local_file( statuses = convert.check_cps_status_running_tasks( api=api, cps_proj_key=coords.proj_key, task_ids=task_ids ) - print(success_message) + cleanup(root_dir=root_dir) - return + return statuses def process_external_cos( @@ -196,5 +195,5 @@ def process_external_cos( statuses = convert.check_cps_status_running_tasks( api=api, cps_proj_key=coords.proj_key, task_ids=task_ids ) - print(success_message) - return + + return statuses diff --git a/deepsearch/documents/core/common_routines.py b/deepsearch/documents/core/common_routines.py index 80783190..b54b3ce3 100644 --- a/deepsearch/documents/core/common_routines.py +++ b/deepsearch/documents/core/common_routines.py @@ -15,4 +15,3 @@ class ProgressBarParameters: progressbar = ProgressBarParameters() -success_message = "Completed successfully"