Azure / Azure/azure-sdk-for-python
AML: Allow calling online endpoints directly with a payload
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 193
Description
**Is your feature request related to a problem? Please describe.**
It is very frustrating having to dump payloads to a temporary file each time we want to invoke an online endpoint because the api does not support directly supplying the payload
**Describe the solution you'd like**
Implement the possibility of directly passing payloads to the invoke method
**Describe alternatives you've considered**
Using a tempfile for dumping payloads only to be directly read into memory again by the api.
**Additional context**
It is clear that this was originally intended to be implemented because the function already defines an `input_data` variable and disables pylint from detecting it is unused:
https://github.com/Azure/azure-sdk-for-python/blob/c33e4f711b82c283b60fbafd292474d5ca6ce393/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_online_endpoint_operations.py#L307-L308
Implementing this should be as simple as:
```python
if input_data and request_file:
raise ValueError("Only one of input_data or request_file can be specified, not both!")
if input_data:
data = input_data
# Alternatively perform a little more validating here if you prefer.
else:
with open(request_file, "rb") as f:
data = json.loads(f.read())
... continue with rest of existing code
```
@vebjornmalmin @kribra
Contributor guide
Assessment
This issue has not been assessed yet.