Skip to content

Commit

Permalink
Merge pull request #554 from phospho-app/nico/revamp-dashboard-2
Browse files Browse the repository at this point in the history
Fix date type casting in API calls
  • Loading branch information
oulianov committed Jun 24, 2024
2 parents 0a6e825 + f945cab commit e12491c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/app/services/mongo/ai_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def predict(predict_request: PredictRequest) -> PredictResponse | None:
try:
response = await client.post(
f"{config.PHOSPHO_AI_HUB_URL}/v1/predict",
json=predict_request.model_dump(),
json=predict_request.model_dump(mode="json"),
headers={
"Authorization": f"Bearer {config.PHOSPHO_AI_HUB_API_KEY}",
"Content-Type": "application/json",
Expand Down Expand Up @@ -175,7 +175,7 @@ async def clustering(clustering_request: ClusteringRequest) -> None:
try:
_ = await client.post(
f"{config.PHOSPHO_AI_HUB_URL}/v1/clusterings",
json=clustering_request.model_dump(),
json=clustering_request.model_dump(mode="json"),
headers={
"Authorization": f"Bearer {config.PHOSPHO_AI_HUB_API_KEY}",
"Content-Type": "application/json",
Expand Down
16 changes: 10 additions & 6 deletions backend/app/services/mongo/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ async def run_log_process(
f"{config.EXTRACTOR_URL}/v1/pipelines/log", # WARNING: hardcoded API version
json={
"logs_to_process": [
log_event.model_dump() for log_event in logs_to_process
log_event.model_dump(mode="json")
for log_event in logs_to_process
],
"extra_logs_to_save": [
log_event.model_dump() for log_event in extra_logs_to_save
log_event.model_dump(mode="json")
for log_event in extra_logs_to_save
],
"project_id": project_id,
"org_id": org_id,
Expand Down Expand Up @@ -164,7 +166,7 @@ async def run_main_pipeline_on_task(task: Task) -> PipelineResults:
response = await client.post(
f"{config.EXTRACTOR_URL}/v1/pipelines/main/task", # WARNING: hardcoded API version
json={
"task": task.model_dump(),
"task": task.model_dump(mode="json"),
},
headers={
"Authorization": f"Bearer {config.EXTRACTOR_SECRET_KEY}",
Expand Down Expand Up @@ -218,7 +220,9 @@ async def run_main_pipeline_on_messages(
response = await client.post(
f"{config.EXTRACTOR_URL}/v1/pipelines/main/messages", # WARNING: hardcoded API version
json={
"messages": [message.model_dump() for message in messages],
"messages": [
message.model_dump(mode="json") for message in messages
],
"project_id": project_id,
},
headers={
Expand Down Expand Up @@ -271,8 +275,8 @@ async def run_recipe_on_tasks(
response = await client.post(
f"{config.EXTRACTOR_URL}/v1/pipelines/recipes", # WARNING: hardcoded API version
json={
"tasks": [task.model_dump() for task in tasks],
"recipe": recipe.model_dump(),
"tasks": [task.model_dump(mode="json") for task in tasks],
"recipe": recipe.model_dump(mode="json"),
},
headers={
"Authorization": f"Bearer {config.EXTRACTOR_SECRET_KEY}",
Expand Down
7 changes: 6 additions & 1 deletion backend/app/services/mongo/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ async def process_file_upload_into_log_events(
for _, row in tasks_df.iterrows():
# Create a task for each row
try:
row_as_dict = row.to_dict()
# Replace NaN values with None
row_as_dict = {
k: v if pd.notnull(v) else None for k, v in row_as_dict.items()
}
valid_log_event = LogEvent(
project_id=project_id,
**row.to_dict(),
**row_as_dict,
)

if max_usage is None or (
Expand Down

0 comments on commit e12491c

Please sign in to comment.