Metadata-Version: 2.4
Name: mlflow-k8s-operator
Version: 0.4.0
Summary: Python client library for MLflow Kubernetes Operator
Author-email: NotHarshhaa <your-email@example.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/NotHarshhaa/mlflow-k8s-operator
Project-URL: Documentation, https://github.com/NotHarshhaa/mlflow-k8s-operator#readme
Project-URL: Repository, https://github.com/NotHarshhaa/mlflow-k8s-operator
Project-URL: Bug Tracker, https://github.com/NotHarshhaa/mlflow-k8s-operator/issues
Keywords: mlflow,kubernetes,operator,mlops,machine-learning
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: kubernetes>=28.0.0
Requires-Dist: PyYAML>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Dynamic: license-file

# MLflow Kubernetes Operator Python Client

A Python client library for managing [MLflow Kubernetes Operator](https://github.com/NotHarshhaa/mlflow-k8s-operator) custom resources in Kubernetes.

## Installation

```bash
pip install mlflow-k8s-operator
```

## Quick Start

### Basic Usage

```python
from mlflow_k8s_operator import MLflowServerClient, MLflowServer, TrackingConfig, BackendConfig, ArtifactStoreConfig

# Initialize the client
client = MLflowServerClient()

# Create an MLflowServer
mlflow_server = MLflowServer(
    name="my-mlflow",
    namespace="mlflow",
    version="2.11.0",
    tracking=TrackingConfig(replicas=2),
    backend=BackendConfig(
        type="postgresql",
        postgresql={
            "host": "postgres.mlflow.svc.cluster.local",
            "database": "mlflow",
            "credentials_secret": "mlflow-db-credentials"
        }
    ),
    artifact_store=ArtifactStoreConfig(
        type="s3",
        s3={
            "bucket": "my-mlflow-artifacts",
            "region": "us-east-1",
            "credentials_secret": "aws-credentials"
        }
    )
)

# Create the resource
client.create(mlflow_server)

# Get the resource
resource = client.get("my-mlflow", "mlflow")
print(resource)

# Check if ready
if client.is_ready("my-mlflow", "mlflow"):
    print("MLflow server is ready!")

# Wait until ready
client.wait_until_ready("my-mlflow", "mlflow", timeout=300)

# List all servers
servers = client.list(namespace="mlflow")
print(servers)

# Delete the resource
client.delete("my-mlflow", "mlflow")
```

### Create from YAML

```python
# Create from YAML string
yaml_content = """
apiVersion: mlops.NotHarshhaa.io/v1alpha1
kind: MLflowServer
metadata:
  name: my-mlflow
  namespace: mlflow
spec:
  version: "2.11.0"
  tracking:
    replicas: 2
  backend:
    type: postgresql
    postgresql:
      host: postgres.mlflow.svc.cluster.local
      database: mlflow
      credentialsSecret: mlflow-db-credentials
  artifactStore:
    type: s3
    s3:
      bucket: my-mlflow-artifacts
      region: us-east-1
      credentialsSecret: aws-credentials
"""

client.create_from_yaml(yaml_content, namespace="mlflow")

# Or from YAML file
client.create_from_yaml_file("mlflow-server.yaml", namespace="mlflow")
```

### Advanced Configuration

```python
from mlflow_k8s_operator import (
    MLflowServer,
    TrackingConfig,
    BackendConfig,
    ArtifactStoreConfig,
    IngressConfig,
    AutoscalingConfig,
    SchedulingConfig,
    PodDisruptionBudgetConfig,
    ProbesConfig
)

mlflow_server = MLflowServer(
    name="advanced-mlflow",
    namespace="mlflow",
    version="2.11.0",
    tracking=TrackingConfig(
        replicas=2,
        additional_args=["--serve-artifacts"],
        probes=ProbesConfig(
            liveness_probe={
                "httpGet": {"path": "/health", "port": 5000},
                "initialDelaySeconds": 30,
                "periodSeconds": 10
            }
        ),
        pod_labels={"environment": "production"}
    ),
    backend=BackendConfig(
        type="postgresql",
        postgresql={
            "host": "postgres.mlflow.svc.cluster.local",
            "database": "mlflow",
            "credentials_secret": "mlflow-db-credentials"
        }
    ),
    artifact_store=ArtifactStoreConfig(
        type="s3",
        s3={
            "bucket": "my-mlflow-artifacts",
            "region": "us-east-1",
            "credentials_secret": "aws-credentials"
        }
    ),
    ingress=IngressConfig(
        enabled=True,
        host="mlflow.example.com",
        tls={"enabled": True, "issuer": "letsencrypt-prod"}
    ),
    autoscaling=AutoscalingConfig(
        enabled=True,
        min_replicas=2,
        max_replicas=10,
        target_cpu_utilization_percentage=70
    ),
    scheduling=SchedulingConfig(
        node_selector={"nodepool": "ml-workload"},
        priority_class_name="high-priority"
    ),
    pod_disruption_budget=PodDisruptionBudgetConfig(
        enabled=True,
        min_available=1
    )
)

client.create(mlflow_server)
```

### Using Custom kubeconfig

```python
# Load from specific kubeconfig file
client = MLflowServerClient(
    kubeconfig="/path/to/kubeconfig",
    context="my-context"
)
```

## Development

### Install in development mode

```bash
cd python-client
pip install -e ".[dev]"
```

### Run tests

```bash
pytest
```

### Format code

```bash
black .
isort .
```

### Type checking

```bash
mypy mlflow_k8s_operator
```

## License

Apache 2.0 - See [LICENSE](../LICENSE) for details.

## Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](../CONTRIBUTING.md) before submitting.
