Skip to content

Commit

Permalink
return empty list if dataframe is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
harshitsinghai77 committed Jan 15, 2024
1 parent 4bb5b9d commit d62907b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Spacefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ micros:
api_keys: true
public_routes:
- "/nemo/*" # wildcards
dev: uvicorn main:app # start the micro in development mode
dev: uvicorn main:app --reload # start the micro in development mode
6 changes: 1 addition & 5 deletions app/api/crud/nemodeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, items_dict: dict):
def check_empty_dataframe(func):
def is_df_empty(self):
if self.df.empty:
return
return []
return func(self)

return is_df_empty
Expand Down Expand Up @@ -133,12 +133,8 @@ def prepare_and_summarize_tasks_by_date(self):

# Sort values by date
result = self.df.sort_values("date", ascending=False)
# Check for empty result and return empty list if applicable
if result.empty:
return [] # Return an empty list
return result.to_dict(orient="records")


class NemoDeta:
"""Utility class to manage nemo in Deta Base."""

Expand Down

0 comments on commit d62907b

Please sign in to comment.