-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arief Rahmansyah
committed
Jan 5, 2024
1 parent
a8e17f4
commit ef176a0
Showing
10 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Echo UPI Model Examples | ||
|
||
Run the server locally: | ||
|
||
``` | ||
python upi_server.py | ||
``` | ||
|
||
In different terminal session, run the client: | ||
|
||
``` | ||
python upi_client.py | ||
``` |
Empty file.
2 changes: 0 additions & 2 deletions
2
.../pyfunc-server/examples/echo-upi/env.yaml → .../pyfunc-server/examples/echo_upi/env.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
channels: | ||
- defaults | ||
dependencies: | ||
- python=3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import grpc | ||
import pandas as pd | ||
from caraml.upi.utils import df_to_table | ||
from caraml.upi.v1 import upi_pb2, upi_pb2_grpc | ||
|
||
|
||
def create_upi_request() -> upi_pb2.PredictValuesRequest: | ||
target_name = "echo" | ||
df = pd.DataFrame( | ||
[[4, 1, "hi"]] * 3, | ||
columns=["int_value", "int_value_2", "string_value"], | ||
index=["0000", "1111", "2222"], | ||
) | ||
prediction_id = "12345" | ||
|
||
return upi_pb2.PredictValuesRequest( | ||
target_name=target_name, | ||
prediction_table=df_to_table(df, "predict"), | ||
metadata=upi_pb2.RequestMetadata(prediction_id=prediction_id), | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
channel = grpc.insecure_channel(f"localhost:8080") | ||
stub = upi_pb2_grpc.UniversalPredictionServiceStub(channel) | ||
|
||
request = create_upi_request() | ||
response = stub.PredictValues(request=request) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters