-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
address issues building mlflow model in GHA test env
- Loading branch information
1 parent
03d9e8e
commit a9ef01a
Showing
3 changed files
with
21 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .mlflow_model_fixture import FakeModel | ||
|
||
|
||
def _load_pyfunc(data_path): | ||
return FakeModel() |
11 changes: 1 addition & 10 deletions
11
test/unit/cli/mlflow_model_fixture.py → ...unit/cli/fixtures/mlflow_model_fixture.py
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,20 +1,11 @@ | ||
import shutil | ||
from tempfile import TemporaryDirectory, mkstemp | ||
|
||
import mlflow | ||
|
||
|
||
def write_model(model) -> str: | ||
with TemporaryDirectory() as mlflow_model_dir: | ||
mlflow.pyfunc.save_model(mlflow_model_dir, python_model=model) | ||
return shutil.make_archive(mkstemp()[1], "zip", mlflow_model_dir) | ||
|
||
|
||
class FakeModel(mlflow.pyfunc.PythonModel): | ||
def __init__(self, input_to_output: dict = {}): | ||
self.input_to_output = input_to_output | ||
|
||
def predict(self, context, model_input) -> None: | ||
def predict(self, model_input) -> None: | ||
# this stdout output is useful for validating the input in a test, noting that this model will be invoked in a | ||
# subprocess, so stdout is one means of communicating information back to the test code | ||
print(f"__MODEL_INPUT__={model_input.iloc[0][0]}") |
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