Skip to content

Commit

Permalink
Exception handling on s3 store
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jun 9, 2024
1 parent a5bc61d commit 97c034e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions odds/common/store/s3/s3_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,21 @@ async def getDataset(self, datasetId: str) -> Dataset:
except Exception as e:
print('NOT FOUND', key, e)
return None
content = await obj.get()
content = await content['Body'].read()
data = json.loads(content.decode('utf-8'))
resources = data.pop('resources', [])
for resource in resources:
resource['fields'] = [Field(**f) for f in resource['fields']]
data['resources'] = [Resource(**r) for r in resources]
if 'embedding' in data:
data['status_embedding'] = bool(data.pop('embedding'))
dataset = Dataset(**data)
return dataset
try:
content = await obj.get()
content = await content['Body'].read()
data = json.loads(content.decode('utf-8'))
resources = data.pop('resources', [])
for resource in resources:
resource['fields'] = [Field(**f) for f in resource['fields']]
data['resources'] = [Resource(**r) for r in resources]
if 'embedding' in data:
data['status_embedding'] = bool(data.pop('embedding'))
dataset = Dataset(**data)
return dataset
except Exception as e:
print('FAILED TO LOAD', key, e)
return None

async def hasDataset(self, datasetId: str) -> bool:
async with self.bucket() as bucket:
Expand Down

0 comments on commit 97c034e

Please sign in to comment.