s(model2.predict(data))

return predictions

@stepdef load_data() -> pd.DataFrame:

# load inference data

...

@pipeline

def do_predictions():

# get specific artifact version

model_42 = Client().get_artifact_version("trained_model", version="42")

metric_42 = model_42.run_metadata["MSE"].value

# get latest artifact version

model_latest = Client().get_artifact_version("trained_model")

metric_latest = model_latest.run_metadata["MSE"].value

inference_data = load_data()

predict(

model1=model_42,

model2=model_latest,

model1_metric=metric_42,

model2_metric=metric_latest,

data=inference_data,

if __name__ == "__main__":

do_predictions()

Here, we enriched the predict step logic with a metric comparison by MSE metric, so predictions are done on the best possible model. We also added a load_data step to load the inference data.

As before, calls like Client().get_artifact_version("trained_model", version="42") or model_latest.run_metadata["MSE"].value are not evaluating the actual objects behind them at pipeline compilation time. Rather, they do so only at the point of step execution. By doing so, we ensure that the latest version is actually the latest at the moment and not just the latest at the point of pipeline compilation.

PreviousHandle custom data types

NextPassing artifacts between pipelines

Last updated 19 days ago