Skip to content

Commit

Permalink
fix: fix document upload (#58)
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Vagenas <35837085+vagenas@users.noreply.github.com>
  • Loading branch information
vagenas committed Dec 16, 2022
1 parent 057f4a7 commit 13216af
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deepsearch/cps/client/components/data_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions deepsearch/cps/data_indices/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion deepsearch/documents/core/common_routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class ProgressBarParameters:


progressbar = ProgressBarParameters()
success_message = "Whoa... it is done. Until next time, Ciao!"
success_message = "Completed successfully"
5 changes: 3 additions & 2 deletions docs/guide/data_indices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
```

---

0 comments on commit 13216af

Please sign in to comment.