Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set coordinates payload to dict #118

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deepsearch/cps/cli/data_indices_typer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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 @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion deepsearch/cps/data_indices/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions docs/guide/data_indices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

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

---
Expand Down