Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
Signed-off-by: Danny Chiao <danny@tecton.ai>
  • Loading branch information
adchia committed Apr 18, 2022
commit 1e3e5fff558921cf9a48f213fc61127a7b87ecf3
32 changes: 15 additions & 17 deletions docs/reference/feature-servers/python-feature-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,25 @@ curl -X POST "http://localhost:6566/push" -d '{

or equivalently from Python:
```python
import json
import requests
import pandas as pd
from datetime import datetime

event_df = pd.DataFrame.from_dict(
{
"driver_id": [1001],
"event_timestamp": [datetime(2021, 5, 13, 10, 59, 42),],
"created": [datetime(2021, 5, 13, 10, 59, 42),],
"conv_rate": [1.0],
"acc_rate": [1.0],
"avg_daily_trips": [1000],
"string_feature": "test2",
}
)
event_df['event_timestamp'] = event_df['event_timestamp'].astype(str)
event_df['created'] = event_df['created'].astype(str)
event_dict = {
"driver_id": [1001],
"event_timestamp": [str(datetime(2021, 5, 13, 10, 59, 42))],
"created": [str(datetime(2021, 5, 13, 10, 59, 42))],
"conv_rate": [1.0],
"acc_rate": [1.0],
"avg_daily_trips": [1000],
"string_feature": "test2",
}
push_data = {
"push_source_name":"driver_stats_push_source",
"df":event_dict
}
requests.post(
"http://localhost:6566/push",
json={
"push_source_name":"driver_stats_push_source",
"df":event_df.to_dict()
})
data=json.dumps(push_data))
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import json
from datetime import datetime
from typing import List

import pytest
Expand Down Expand Up @@ -72,8 +73,8 @@ def test_push():
"df": {
"location_id": [1],
"temperature": [initial_temp * 100],
"event_timestamp": ["2022-05-13 10:59:42"],
"created": ["2022-05-13 10:59:42"],
"event_timestamp": [str(datetime.utcnow())],
"created": [str(datetime.utcnow())],
},
}
)
Expand Down