Skip to content

Commit

Permalink
Merge pull request #316 from labmlai/data-store
Browse files Browse the repository at this point in the history
app api: throw error on empty data
  • Loading branch information
lakshith-403 authored Nov 6, 2024
2 parents a2aa366 + 55fbf87 commit d478ab0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/server/labml_app/analyses/experiments/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ async def get_data_store(run_uuid: str) -> Any:

@Analysis.route('POST', 'datastore/{run_uuid}')
async def update_data_store(run_uuid: str, data: Dict[str, Any]) -> Any:
try:
data_dict = yaml.safe_load(data.get('yaml_string', ""))
except Exception as e:
return JSONResponse({'error': str(e)}, status_code=400)

if data_dict is None:
return JSONResponse({'error': 'Attempting to set empty dictionary'}, status_code=400)

key = DataStoreIndex.get(run_uuid)
if key is None:
data_store = DataStoreModel()
Expand All @@ -57,14 +65,6 @@ async def update_data_store(run_uuid: str, data: Dict[str, Any]) -> Any:
else:
data_store = key.load()

try:
data_dict = yaml.safe_load(data.get('yaml_string', ""))
except Exception as e:
return JSONResponse({'error': str(e)}, status_code=400)

if data_dict is None:
data_dict = {}

data_store.set_data(data_dict)
data_store.save()

Expand Down

0 comments on commit d478ab0

Please sign in to comment.