testcontainers / testcontainers/testcontainers-python
New Container: MFflow
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 386
- Merge trung bình
- 4 giờ 40 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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:
import logging
import requests
from mlflow import MlflowClient
from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_container_is_ready
logger = logging.getLogger(__name__)
class MFlowContainer(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 = port
self.with_exposed_ports(self.port)
self.cmd = cmd
def _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)
def get_url(self) -> str:
"""Returns the url of the container.
Returns:
The url. Use to track to.
"""
return f"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=health
response = requests.get(f"{self.get_url()}/health", timeout=1)
response.raise_for_status()
def get_client(self) -> MlflowClient:
"""Returns the MlflowClient of the container.
Can be used for testing.
"""
return MlflowClient(self.get_url())
def start(self) -> "MFlowContainer":
self._configure()
super().start()
self._readiness_probe()
return self
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Không có tệp repository hoặc bài kiểm thử nào được nêu tên. Trước tiên, hãy xác định các tích hợp container hiện có của Testcontainers Python và các bài kiểm thử của chúng, sau đó sử dụng các điểm vào container MLflow được đề xuất làm hướng dẫn; công việc được xem là hoàn tất khi dịch vụ MLflow sẵn sàng và URL cùng client của nó có thể được sử dụng trong các bài kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, python
- Lĩnh vực
- machine-learning, testing
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100