From 13216afe84472c048f8664d15884ecea00603b42 Mon Sep 17 00:00:00 2001 From: Panos Vagenas <35837085+vagenas@users.noreply.github.com> Date: Fri, 16 Dec 2022 16:27:28 +0100 Subject: [PATCH] fix: fix document upload (#58) Signed-off-by: Panos Vagenas <35837085+vagenas@users.noreply.github.com> --- deepsearch/cps/client/components/data_indices.py | 2 +- deepsearch/cps/data_indices/utils.py | 6 ++++-- deepsearch/documents/core/common_routines.py | 2 +- docs/guide/data_indices.md | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/deepsearch/cps/client/components/data_indices.py b/deepsearch/cps/client/components/data_indices.py index 48ac89ee..28814a29 100644 --- a/deepsearch/cps/client/components/data_indices.py +++ b/deepsearch/cps/client/components/data_indices.py @@ -94,7 +94,7 @@ def delete( def upload_file( self, coords: ElasticProjectDataCollectionSource, - body: Dict[str, str], + body: Dict[str, List[str]], ) -> 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 f336f118..a45cda81 100644 --- a/deepsearch/cps/data_indices/utils.py +++ b/deepsearch/cps/data_indices/utils.py @@ -82,7 +82,8 @@ def process_url_input( bar_format=progressbar.bar_format, ) as progress: for url in urls: - payload = {"file_url": url} + file_url_array = [url] + payload = {"file_url": file_url_array} task_id = api.data_indices.upload_file(coords=coords, body=payload) task_ids.append(task_id) progress.update(1) @@ -146,7 +147,8 @@ def process_local_file( private_download_url = convert.upload_single_file( api=api, cps_proj_key=coords.proj_key, source_path=Path(single_zip) ) - payload = {"file_url": private_download_url} + file_url_array = [private_download_url] + payload = {"file_url": file_url_array} task_id = api.data_indices.upload_file(coords=coords, body=payload) task_ids.append(task_id) progress.update(1) diff --git a/deepsearch/documents/core/common_routines.py b/deepsearch/documents/core/common_routines.py index 2e9d182f..80783190 100644 --- a/deepsearch/documents/core/common_routines.py +++ b/deepsearch/documents/core/common_routines.py @@ -15,4 +15,4 @@ class ProgressBarParameters: progressbar = ProgressBarParameters() -success_message = "Whoa... it is done. Until next time, Ciao!" +success_message = "Completed successfully" diff --git a/docs/guide/data_indices.md b/docs/guide/data_indices.md index 97959d96..204a3993 100644 --- a/docs/guide/data_indices.md +++ b/docs/guide/data_indices.md @@ -108,12 +108,13 @@ Documents can be converted and added, directly, to a data index in a project. Br === "Python" ```python from deepsearch.cps.client.components.elastic import ElasticProjectDataCollectionSource + from deepsearch.cps.data_indices import utils as data_indices_utils # Specify index coords = ElasticProjectDataCollectionSource(proj_key=PROJ_KEY, index_key=INDEX_KEY) # For local documents - ds.data_indices_utilities.upload_files(coords=coords, local_file=PATH_DOCS) + data_indices_utils.upload_files(api=api, coords=coords, local_file=PATH_DOCS) # For online documents @@ -122,7 +123,7 @@ Documents can be converted and added, directly, to a data index in a project. Br # or, define a list directly #input_urls = ["https:///URL1", "https://URL2", "https://URL3"] - ds.data_indices_utilities.upload_files(coords=coords, url=input_urls) + data_indices_utils.upload_files(api=api, coords=coords, url=input_urls) ``` ---