Skip to content

Commit

Permalink
improved read cos file
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Santana <[email protected]>
  • Loading branch information
SantanaTiago committed Jul 25, 2023
1 parent 9c9063a commit 77a5f62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 4 additions & 7 deletions deepsearch/cps/cli/data_indices_typer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from enum import Enum
from pathlib import Path
from typing import List
from typing import List, Optional

import typer

Expand All @@ -19,6 +19,7 @@
URL,
)
from deepsearch.cps.client.api import CpsApi
from deepsearch.cps.client.components.data_indices import S3Coordinates
from deepsearch.cps.client.components.elastic import ElasticProjectDataCollectionSource
from deepsearch.cps.data_indices import utils
from deepsearch.documents.core.common_routines import ERROR_MSG
Expand Down Expand Up @@ -146,14 +147,10 @@ def upload_files(
p = Path(url)
urls = get_urls(p) if p.exists() else [url]

def read_cos_file(file: Path):
with open(s3_coordinates) as coords_file:
return json.load(coords_file)

cos_coordinates = None
cos_coordinates: Optional[S3Coordinates] = None
if s3_coordinates is not None:
try:
cos_coordinates = read_cos_file(s3_coordinates)
cos_coordinates = json.load(open(s3_coordinates))
except Exception as e:
typer.echo(f"Error occurred: {e}")
typer.echo(ERROR_MSG)
Expand Down
1 change: 0 additions & 1 deletion deepsearch/cps/client/components/data_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class CpsApiDataIndex(ApiConnectedObject):
project: str


@dataclass
class S3Coordinates(BaseModel):
host: str
port: int
Expand Down

0 comments on commit 77a5f62

Please sign in to comment.