33-AzureML-2/azuremlpythonsdk-v2/azml_04_test_inference.py

24 lines
575 B
Python
Raw Normal View History

2024-09-04 10:15:43 +02:00
"""
Script to use real-time inferencing with online endpoints
"""
from azml_03_realtime_inference import online_endpoint_name
from ml_client import create_or_load_ml_client
def main():
# 1. Load a Workspace
2024-09-05 13:47:53 +02:00
ml_client = create_or_load_ml_client()
2024-09-04 10:15:43 +02:00
# 2. Get predictions
2024-09-05 13:47:53 +02:00
output = ml_client.online_endpoints.invoke(
endpoint_name=online_endpoint_name,
2024-09-04 10:15:43 +02:00
deployment_name=online_endpoint_name,
request_file="./diabetes_test_inference/request.json",
)
print(output)
if __name__ == "__main__":
main()