# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_inference.ipynb.

# %% auto 0
__all__ = ['InferenceClient']

# %% ../nbs/02_inference.ipynb 2
from .base import BaseClient

# %% ../nbs/02_inference.ipynb 3
class InferenceClient(BaseClient):
    def __init__(self, base_url=None, port=8080):
        super().__init__(base_url)
        self.port = port
        self.base_url = f"{self.base_url}:{self.port}"

    def api_description(self):
        return self._make_request("OPTIONS", "/")

    def health_check(self):
        return self._make_request("GET", "/ping")

    def prediction(self, model_name, data, version=None):
        """
        inference_data = [
            ('data', open('docs/images/dogs-before.jpg', 'rb')),
            ('data', open('docs/images/kitten_small.jpg', 'rb')),
        ]
        """
        if version:
            endpoint = f"/predictions/{model_name}/{version}"
        else:
            endpoint = f"/predictions/{model_name}"

        return self._make_request("POST", endpoint, files=data)

    def explaination(self, model_name, data):
        """
        data <string : bytes>
        """
        endpoint = f"/explanations/{model_name}"
        return self._make_request("POST", endpoint, files=data)
