You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to provide a new testcontainer for mlflow, a tool for managing your machine learning model life cycle.
Why not just use a generic container for this?
I added handy utilites to get the url to track to and to get the client to interact with the container directly.
The implementation would look like:
importloggingimportrequestsfrommlflowimportMlflowClientfromtestcontainers.core.containerimportDockerContainerfromtestcontainers.core.waiting_utilsimportwait_container_is_readylogger=logging.getLogger(__name__)
classMFlowContainer(DockerContainer):
"""Test container for MLflow. Args: image: the image to use. Change if you need different version. port: the internal port to use. The exposed port is assigned automatically. cmd: the command to run. Defaults to "mlflow server". If you want to use the ui for debugging and testing use "mlflow ui". """def__init__(
self, image: str="ghcr.io/mlflow/mlflow:v2.14.1", port: int=5000, cmd: str="mlflow server"
) ->None:
super().__init__(image=image)
self.port=portself.with_exposed_ports(self.port)
self.cmd=cmddef_configure(self) ->None:
self.with_env("MLFLOW_PORT", str(self.port))
self.with_env("MLFLOW_HOST", "0.0.0.0")
self.with_command(self.cmd)
defget_url(self) ->str:
"""Returns the url of the container. Returns: The url. Use to track to. """returnf"http://{self.get_container_host_ip()}:{self.get_exposed_port(self.port)}"@wait_container_is_ready(requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout)def_readiness_probe(self) ->None:
# https://mlflow.org/docs/latest/deployment/deploy-model-locally.html?highlight=healthresponse=requests.get(f"{self.get_url()}/health", timeout=1)
response.raise_for_status()
defget_client(self) ->MlflowClient:
"""Returns the MlflowClient of the container. Can be used for testing. """returnMlflowClient(self.get_url())
defstart(self) ->"MFlowContainer":
self._configure()
super().start()
self._readiness_probe()
returnself
The text was updated successfully, but these errors were encountered:
What is the new container you'd like to have?
I would like to provide a new testcontainer for mlflow, a tool for managing your machine learning model life cycle.
Why not just use a generic container for this?
I added handy utilites to get the url to track to and to get the client to interact with the container directly.
The implementation would look like:
The text was updated successfully, but these errors were encountered: