This repository contains examples of end-to-end ML workflows built with Union, showcasing Union-specific features for training, inference, and serving.
- Build container images using
ImageSpec
with Union's remote image builder:
→./orchestration/container_images.py
- Train a simple Keras model and generate a Union Artifact:
→./tasks/train.py
- Define the model artifact with Union’s native artifact abstraction:
→./orchestration/artifacts.py
- Perform scalable and parallel inference using Union’s
map
construct:
→./workflows/predict_conv_model.py
- Massively accelerate batch inference with Union Actors:
→./orchestration/actor_env.py
- Union Actors eliminate container startup/teardown time
- Cache and reuse model loading logic:
→./tasks/predict.py
- Deploy a FastAPI app that pulls the Union Model Artifact and serves it with Union:
→./apps/simple-fastapi/app.py
- Create a Python environment of your choice
- Install dependencies:
pip install -r requirements.txt
# Run training workflow
union run -p <your-project> --remote workflows/train_conv_model.py wf
Wait for the training execution to complete and the Model Artifact to be generated.
# Run prediction workflow using the trained model
union run -p <your-project> --remote workflows/predict_conv_model.py wf
Register and activate launchplans for training and prediction, including:
- Fixed-rate scheduling
- Notifications
- Artifact triggers
union register -p <your-project> ./launchplans --activate-launchplans
Deploy the FastAPI app using Union:
union deploy apps -p <your-project> apps/simple-fastapi/app.py simple-fastapi
Then open your deployed app at:
<your-deployed-endpoint>/docs
To apply changes after modifying the app code, re-run the deploy command above.