File tree Expand file tree Collapse file tree
bats_ai/core/management/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+
3+ from django .conf import settings
4+ import djclick as click
5+ import mlflow
6+ import mlflow .onnx
7+ import onnx
8+
9+
10+ @click .command ()
11+ def command ():
12+ relative = ('..' ,) * 5
13+ asset_path = os .path .abspath (os .path .join (__file__ , * relative , 'assets' ))
14+ onnx_filename = os .path .join (asset_path , 'model.mobilenet.onnx' )
15+ onnx_model = onnx .load (onnx_filename )
16+
17+ mlflow .set_tracking_uri (settings .MLFLOW_ENDPOINT )
18+ mlflow .set_experiment ('default' )
19+ with mlflow .start_run () as run :
20+ run_id = run .info .run_id
21+ click .echo (f'Run ID: { run_id } ' )
22+ mlflow .onnx .log_model (
23+ onnx_model = onnx_model ,
24+ artifact_path = 'onnx_model' ,
25+ )
26+ model_uri = f'runs:/{ run_id } /onnx_model'
27+ result = mlflow .register_model (model_uri = model_uri , name = 'prototype' )
28+ click .echo (f'Registered { model_uri } version { result .version } ' )
You can’t perform that action at this time.
0 commit comments