diff --git a/deepsearch/cps/cli/data_indices_typer.py b/deepsearch/cps/cli/data_indices_typer.py index 3c735a21..ade0f569 100644 --- a/deepsearch/cps/cli/data_indices_typer.py +++ b/deepsearch/cps/cli/data_indices_typer.py @@ -150,7 +150,7 @@ def upload_files( cos_coordinates: Optional[S3Coordinates] = None if s3_coordinates is not None: try: - cos_coordinates = json.load(open(s3_coordinates)) + cos_coordinates = S3Coordinates.parse_file(s3_coordinates) except Exception as e: typer.echo(f"Error occurred: {e}") typer.echo(ERROR_MSG) diff --git a/deepsearch/cps/client/components/data_indices.py b/deepsearch/cps/client/components/data_indices.py index fe5c351b..a5f04bd1 100644 --- a/deepsearch/cps/client/components/data_indices.py +++ b/deepsearch/cps/client/components/data_indices.py @@ -102,7 +102,7 @@ def delete( def upload_file( self, coords: ElasticProjectDataCollectionSource, - body: Union[Dict[str, List[str]], Dict[str, Dict[str, S3Coordinates]]], + body: Union[Dict[str, List[str]], Dict[str, Dict[str, Dict]]], ) -> str: """ Call api for converting and uploading file to a project's data index. diff --git a/deepsearch/cps/data_indices/utils.py b/deepsearch/cps/data_indices/utils.py index a8ca44ce..53058035 100644 --- a/deepsearch/cps/data_indices/utils.py +++ b/deepsearch/cps/data_indices/utils.py @@ -183,7 +183,7 @@ def process_external_cos( bar_format=progressbar.bar_format, ) as progress: # upload using coordinates - payload = {"s3_source": {"coordinates": s3_coordinates}} + payload = {"s3_source": {"coordinates": s3_coordinates.dict()}} task_id = api.data_indices.upload_file( coords=coords, body=payload, diff --git a/docs/guide/data_indices.md b/docs/guide/data_indices.md index 12394ecc..3a81a591 100644 --- a/docs/guide/data_indices.md +++ b/docs/guide/data_indices.md @@ -102,6 +102,9 @@ Documents can be converted and added, directly, to a data index in a project. Br // for online documents $ deepsearch cps data-indices upload -p PROJ_KEY -x INDEX_KEY -u PATH_URL + + // for COS documents + $ deepsearch cps data-indices upload -p PROJ_KEY -x INDEX_KEY -c PATH_COS_COORDINATES ``` @@ -124,6 +127,11 @@ Documents can be converted and added, directly, to a data index in a project. Br #input_urls = ["https:///URL1", "https://URL2", "https://URL3"] data_indices_utils.upload_files(api=api, coords=coords, url=input_urls) + + # For COS documents + cos_coordinates = S3Coordinates.parse_file(s3_coordinates) + + data_indices_utils.upload_files(api=api, coords=coords, s3_coordinates=cos_coordinates) ``` ---