-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added hot-reloading on model promotion
- Loading branch information
Showing
12 changed files
with
79 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ mlflow | |
docker | ||
docker-compose.yaml | ||
.git | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
|
||
.PHONY: clean | ||
build: | ||
clean: | ||
docker system prune -f | ||
|
||
.PHONY: build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
FROM aligned-catalog-free | ||
FROM matsmoll/aligned-catalog-free | ||
|
||
RUN pip install mlflow prefect | ||
COPY poetry.lock pyproject.toml /app/ | ||
RUN poetry install --without dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
FROM project-base:latest | ||
|
||
RUN pip install mlflow[extras] | ||
RUN pip install mlflow[extras]==2.13.0 | ||
RUN pip install watchfiles | ||
|
||
COPY . /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pathlib import Path | ||
import mlflow | ||
import click | ||
import subprocess | ||
|
||
@click.group() | ||
def cli() -> None: | ||
pass | ||
|
||
def start_mlfow_server(model_name: str, alias: str, port: int, host: str): | ||
uri = f"models:/{model_name}@{alias}" | ||
print(uri) | ||
try: | ||
mlflow.models.get_model_info(uri) | ||
except Exception as e: | ||
print("Remember to start the tracking server, or train a model first.") | ||
raise e | ||
|
||
subprocess.run([ | ||
"mlflow", "models", "serve", "-m", uri, "--port", str(port), "--host", host, "--no-conda", "--enable-mlserver" | ||
]) | ||
|
||
@cli.command() | ||
@click.argument("model_name", type=str) | ||
@click.option("--alias", type=str, default="champion") | ||
@click.option("--mlflow-dir", type=Path, default="mlflow/experiments") | ||
@click.option("--port", type=int, default="8080") | ||
@click.option("--host", type=str, default="0.0.0.0") | ||
def serve_mlflow_model( | ||
model_name: str, | ||
alias: str, | ||
mlflow_dir: Path, | ||
port: int, | ||
host: str | ||
): | ||
from watchfiles import run_process | ||
|
||
model_alias_file = mlflow_dir / "models" / model_name / "aliases" / alias | ||
|
||
run_process( | ||
model_alias_file.resolve(), | ||
target=start_mlfow_server, | ||
args=(model_name, alias, port, host) | ||
) | ||
|
||
if __name__ == "__main__": | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters