FlowyML Integration API Reference 📖
Complete API reference for MLPotion's FlowyML integration — auto-generated from source code docstrings.
Auto-Generated Documentation
This page is automatically populated with API documentation from the source code. See the FlowyML Integration Guide for usage examples and tutorials.
Core Adapter
mlpotion.integrations.flowyml.adapters
FlowyML Adapter — Bridge MLPotion protocols to FlowyML steps.
Provides factory methods that wrap MLPotion's protocol-compliant components (DataLoader, ModelTrainer, ModelEvaluator) into fully-configured FlowyML Step objects with asset outputs, caching, retry, resource specs, and tags.
Classes
FlowyMLAdapter
Adapt MLPotion components into FlowyML pipeline steps.
Unlike the ZenML adapter which returns raw objects, these steps return FlowyML Asset objects (Dataset, Model, Metrics) with automatic metadata extraction and lineage tracking.
Example::
from mlpotion.frameworks.keras.data.loaders import CSVDataLoader
from mlpotion.integrations.flowyml import FlowyMLAdapter
loader = CSVDataLoader(file_path="data.csv", batch_size=32)
load_step = FlowyMLAdapter.create_data_loader_step(loader)
# Use in a FlowyML pipeline
pipeline = Pipeline("my_pipeline")
pipeline.add_step(load_step)
Functions
create_data_loader_step
staticmethod
create_data_loader_step(
loader: DataLoader[DatasetT],
*,
name: str | None = None,
cache: bool | str | Callable = "code_hash",
retry: int = 0,
resources: Any | None = None,
tags: dict[str, str] | None = None
) -> Step
Wrap a DataLoader as a FlowyML step returning a Dataset asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loader |
DataLoader[DatasetT]
|
Any MLPotion DataLoader protocol implementation. |
required |
name |
str | None
|
Step name (defaults to 'load_data'). |
None
|
cache |
bool | str | Callable
|
Caching strategy ('code_hash', 'input_hash', False). |
'code_hash'
|
retry |
int
|
Number of retry attempts on failure. |
0
|
resources |
Any | None
|
ResourceRequirements for this step. |
None
|
tags |
dict[str, str] | None
|
Metadata tags for observability. |
None
|
Returns:
| Type | Description |
|---|---|
Step
|
A FlowyML Step that loads data and returns a Dataset asset. |
Source code in mlpotion/integrations/flowyml/adapters.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
create_training_step
staticmethod
create_training_step(
trainer: ModelTrainer[ModelT, DatasetT],
*,
name: str | None = None,
cache: bool | str | Callable = False,
retry: int = 0,
resources: Any | None = None,
tags: dict[str, str] | None = None
) -> Step
Wrap a ModelTrainer as a FlowyML step returning a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trainer |
ModelTrainer[ModelT, DatasetT]
|
Any MLPotion ModelTrainer protocol implementation. |
required |
name |
str | None
|
Step name (defaults to 'train_model'). |
None
|
cache |
bool | str | Callable
|
Caching strategy (default: False for training). |
False
|
retry |
int
|
Number of retry attempts on failure. |
0
|
resources |
Any | None
|
ResourceRequirements (e.g., GPU config). |
None
|
tags |
dict[str, str] | None
|
Metadata tags for observability. |
None
|
Returns:
| Type | Description |
|---|---|
Step
|
A FlowyML Step that trains a model and returns a Model asset. |
Source code in mlpotion/integrations/flowyml/adapters.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
create_evaluation_step
staticmethod
create_evaluation_step(
evaluator: ModelEvaluator[ModelT, DatasetT],
*,
name: str | None = None,
cache: bool | str | Callable = "input_hash",
retry: int = 0,
resources: Any | None = None,
tags: dict[str, str] | None = None
) -> Step
Wrap a ModelEvaluator as a FlowyML step returning a Metrics asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluator |
ModelEvaluator[ModelT, DatasetT]
|
Any MLPotion ModelEvaluator protocol implementation. |
required |
name |
str | None
|
Step name (defaults to 'evaluate_model'). |
None
|
cache |
bool | str | Callable
|
Caching strategy (default: 'input_hash'). |
'input_hash'
|
retry |
int
|
Number of retry attempts on failure. |
0
|
resources |
Any | None
|
ResourceRequirements for this step. |
None
|
tags |
dict[str, str] | None
|
Metadata tags for observability. |
None
|
Returns:
| Type | Description |
|---|---|
Step
|
A FlowyML Step that evaluates a model and returns a Metrics asset. |
Source code in mlpotion/integrations/flowyml/adapters.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
Keras Integration
Steps
mlpotion.integrations.flowyml.keras.steps
FlowyML Keras steps — Full-featured pipeline steps for Keras workflows.
Each step leverages FlowyML's native capabilities: - Artifact-centric design: returns Dataset, Model, Metrics with auto-extraction - Supports caching, retry, GPU resources, tags, DAG wiring, and execution groups - train_model integrates FlowymlKerasCallback for automatic tracking
Classes
Functions
load_data
load_data(
file_path: str,
batch_size: int = 32,
label_name: str | None = None,
column_names: list[str] | None = None,
shuffle: bool = True,
dtype: str = "float32",
) -> Dataset
Load CSV data into a Keras-compatible CSVSequence, wrapped as a Dataset asset.
Automatic metadata extraction captures batch count, batch size, source path, column names, and label information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
Glob pattern for CSV files (e.g., "data/*.csv"). |
required |
batch_size |
int
|
Batch size for the sequence. |
32
|
label_name |
str | None
|
Name of the label/target column. |
None
|
column_names |
list[str] | None
|
Specific columns to load (None = all). |
None
|
shuffle |
bool
|
Whether to shuffle the data. |
True
|
dtype |
str
|
Data type for numeric conversion. |
'float32'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset wrapping the CSVSequence with auto-extracted metadata. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
transform_data
transform_data(
dataset: Dataset,
model: keras.Model,
data_output_path: str,
data_output_per_batch: bool = False,
batch_size: int | None = None,
feature_names: list[str] | None = None,
input_columns: list[str] | None = None,
) -> Dataset
Transform data using a Keras model and save predictions to CSV.
Returns a Dataset asset with lineage linked to the input dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset |
Dataset
|
Input Dataset asset wrapping a CSVSequence. |
required |
model |
keras.Model
|
Keras model for generating predictions. |
required |
data_output_path |
str
|
Output path for transformed data. |
required |
data_output_per_batch |
bool
|
If True, output one file per batch. |
False
|
batch_size |
int | None
|
Optional batch size override. |
None
|
feature_names |
list[str] | None
|
Optional feature names for output CSV. |
None
|
input_columns |
list[str] | None
|
Optional input columns to pass to model. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset pointing to the output CSV with parent lineage. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
train_model
train_model(
model: keras.Model,
data: CSVSequence | Dataset,
epochs: int = 10,
learning_rate: float = 0.001,
verbose: int = 1,
validation_data: CSVSequence | Dataset | None = None,
callbacks: list[keras.callbacks.Callback] | None = None,
experiment_name: str | None = None,
project: str | None = None,
log_model: bool = True,
) -> tuple[Model, Metrics]
Train a Keras model with FlowyML tracking integration.
Automatically attaches a FlowymlKerasCallback for: - Dynamic capture of ALL training metrics - Live dashboard updates - Model artifact logging
Returns a Model asset (via Model.from_keras with auto-extracted metadata) and a Metrics asset with training history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model
|
Compiled Keras model. |
required |
data |
CSVSequence | Dataset
|
Training data as CSVSequence or Dataset asset. |
required |
epochs |
int
|
Number of training epochs. |
10
|
learning_rate |
float
|
Learning rate. |
0.001
|
verbose |
int
|
Keras verbosity level. |
1
|
validation_data |
CSVSequence | Dataset | None
|
Optional validation CSVSequence or Dataset. |
None
|
callbacks |
list[keras.callbacks.Callback] | None
|
Additional Keras callbacks (FlowyML callback auto-added). |
None
|
experiment_name |
str | None
|
Experiment name for FlowyML tracking. |
None
|
project |
str | None
|
Project name for FlowyML dashboard. |
None
|
log_model |
bool
|
Whether to save model artifact after training. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Model, Metrics]
|
Tuple of (Model asset, Metrics asset). |
Source code in mlpotion/integrations/flowyml/keras/steps.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
evaluate_model
evaluate_model(
model: keras.Model | Model,
data: CSVSequence | Dataset,
verbose: int = 0,
) -> Metrics
Evaluate a Keras model and return a Metrics asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Trained Keras model or Model asset. |
required |
data |
CSVSequence | Dataset
|
Evaluation data as CSVSequence or Dataset asset. |
required |
verbose |
int
|
Keras verbosity level. |
0
|
Returns:
| Type | Description |
|---|---|
Metrics
|
Metrics asset with evaluation results. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
export_model
export_model(
model: keras.Model | Model,
export_path: str,
export_format: str | None = None,
) -> Model
Export a Keras model to the specified format, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Keras model or Model asset to export. |
required |
export_path |
str
|
Destination path. |
required |
export_format |
str | None
|
Format ('keras', 'saved_model', 'tflite'). |
None
|
Returns:
| Type | Description |
|---|---|
Model
|
Model asset with export metadata. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
save_model
save_model(
model: keras.Model | Model, save_path: str
) -> Model
Save a Keras model to disk, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Keras model or Model asset to save. |
required |
save_path |
str
|
Destination file path. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
Model asset with save location metadata. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
load_model
load_model(model_path: str, inspect: bool = False) -> Model
Load a Keras model from disk, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path |
str
|
Path to the saved model. |
required |
inspect |
bool
|
If True, log model inspection info. |
False
|
Returns:
| Type | Description |
|---|---|
Model
|
Model asset wrapping the loaded Keras model. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
inspect_model
inspect_model(
model: keras.Model | Model,
include_layers: bool = True,
include_signatures: bool = True,
) -> Metrics
Inspect a Keras model and return detailed metadata as a Metrics asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Keras model or Model asset to inspect. |
required |
include_layers |
bool
|
Include per-layer information. |
True
|
include_signatures |
bool
|
Include input/output signatures. |
True
|
Returns:
| Type | Description |
|---|---|
Metrics
|
Metrics asset with model inspection details. |
Source code in mlpotion/integrations/flowyml/keras/steps.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
Pipelines
mlpotion.integrations.flowyml.keras.pipelines
Pre-built FlowyML pipeline templates for Keras workflows.
Provides ready-to-run pipelines that wire MLPotion Keras steps together with proper DAG dependencies, context injection, experiment tracking, and optional scheduling.
Available pipelines:
- create_keras_training_pipeline — Load → Train → Evaluate
- create_keras_full_pipeline — Load → Transform → Train → Evaluate → Export
- create_keras_evaluation_pipeline — Load model + data → Evaluate → Inspect
- create_keras_export_pipeline — Load model → Export + Save
- create_keras_experiment_pipeline — Full pipeline with experiment tracking & conditional deploy
Functions
create_keras_training_pipeline
create_keras_training_pipeline(
name: str = "keras_training",
context: Context | None = None,
enable_cache: bool = True,
project_name: str | None = None,
version: str | None = None,
) -> Pipeline
Create a ready-to-run Keras training pipeline.
DAG: load_data → train_model → evaluate_model
Provide hyperparameters via the context object::
from flowyml.core.context import Context
ctx = Context(
file_path="data/train.csv",
label_name="target",
batch_size=32,
epochs=10,
learning_rate=0.001,
experiment_name="my-experiment",
)
pipeline = create_keras_training_pipeline(
name="my_training",
context=ctx,
project_name="my_project",
)
result = pipeline.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'keras_training'
|
context |
Context | None
|
FlowyML Context with parameters to inject. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string for versioned pipeline. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/keras/pipelines.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
create_keras_full_pipeline
create_keras_full_pipeline(
name: str = "keras_full",
context: Context | None = None,
enable_cache: bool = True,
enable_checkpointing: bool = True,
project_name: str | None = None,
version: str | None = None,
) -> Pipeline
Create a full Keras pipeline covering the entire ML lifecycle.
DAG: load_data → transform_data → train_model → evaluate_model → export_model
Includes checkpointing for long-running training steps so the pipeline can resume from the last checkpoint on failure.
Context parameters::
ctx = Context(
# Data loading
file_path="data/train.csv",
label_name="target",
batch_size=32,
# Transformation
data_output_path="data/transformed/",
# Training
epochs=50,
learning_rate=0.001,
experiment_name="full-run",
project="my_project",
# Export
export_path="models/production/",
export_format="keras",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'keras_full'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
enable_checkpointing |
bool
|
Whether to enable checkpointing. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/keras/pipelines.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
create_keras_evaluation_pipeline
create_keras_evaluation_pipeline(
name: str = "keras_evaluation",
context: Context | None = None,
enable_cache: bool = True,
project_name: str | None = None,
) -> Pipeline
Create a pipeline for evaluating an existing Keras model.
DAG: load_model → load_data → evaluate_model → inspect_model
Useful for model validation, A/B testing, and periodic evaluation against new data without retraining.
Context parameters::
ctx = Context(
model_path="models/production/model.keras",
file_path="data/test.csv",
label_name="target",
batch_size=64,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'keras_evaluation'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/keras/pipelines.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
create_keras_export_pipeline
create_keras_export_pipeline(
name: str = "keras_export",
context: Context | None = None,
project_name: str | None = None,
) -> Pipeline
Create a pipeline for exporting and saving an existing model.
DAG: load_model → export_model, save_model
Useful for converting a trained model to multiple formats (SavedModel, TFLite, Keras) and persisting to different locations.
Context parameters::
ctx = Context(
model_path="models/trained/model.keras",
export_path="models/exported/",
export_format="saved_model",
save_path="models/backup/model.keras",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'keras_export'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/keras/pipelines.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
create_keras_experiment_pipeline
create_keras_experiment_pipeline(
name: str = "keras_experiment",
context: Context | None = None,
project_name: str | None = None,
version: str | None = None,
deploy_threshold: float = 0.8,
threshold_metric: str = "accuracy",
) -> Pipeline
Create a full experiment pipeline with tracking and conditional deployment.
DAG::
load_data → train_model → evaluate_model
↓
[if metric > threshold]
↓
export_model → save_model
Integrates FlowyML experiment tracking and conditionally exports the model only if validation metrics exceed the given threshold.
Context parameters::
ctx = Context(
file_path="data/train.csv",
label_name="target",
batch_size=32,
epochs=30,
learning_rate=0.001,
experiment_name="experiment-v1",
project="my_project",
export_path="models/production/",
save_path="models/checkpoints/model.keras",
)
pipeline = create_keras_experiment_pipeline(
context=ctx,
project_name="my_project",
deploy_threshold=0.85,
threshold_metric="accuracy",
)
result = pipeline.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'keras_experiment'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string. |
None
|
deploy_threshold |
float
|
Minimum metric value to trigger deployment. |
0.8
|
threshold_metric |
str
|
Which metric to check against the threshold. |
'accuracy'
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/keras/pipelines.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
create_keras_scheduled_pipeline
create_keras_scheduled_pipeline(
name: str = "keras_scheduled_retraining",
context: Context | None = None,
project_name: str | None = None,
schedule: str = "0 2 * * 0",
timezone: str = "UTC",
) -> dict[str, Any]
Create a scheduled retraining pipeline.
Returns both the pipeline and a configured scheduler so you can register periodic retraining (e.g., weekly) with a single call.
DAG: load_data → train_model → evaluate_model → export_model
Schedule format uses cron syntax (default: every Sunday at 2 AM)::
pipeline_info = create_keras_scheduled_pipeline(
context=ctx,
project_name="my_project",
schedule="0 2 * * 0", # Weekly
)
# Access the components
pipeline = pipeline_info["pipeline"]
scheduler = pipeline_info["scheduler"]
# Run once immediately
result = pipeline.run()
# Or start the scheduler for automatic retraining
scheduler.start()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'keras_scheduled_retraining'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
schedule |
str
|
Cron expression for scheduling. |
'0 2 * * 0'
|
timezone |
str
|
Timezone for the schedule. |
'UTC'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |
Source code in mlpotion/integrations/flowyml/keras/pipelines.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
PyTorch Integration
Steps
mlpotion.integrations.flowyml.pytorch.steps
FlowyML PyTorch steps — Full-featured pipeline steps for PyTorch workflows.
Each step leverages FlowyML's native capabilities: - Artifact-centric design: returns Dataset, Model, Metrics with auto-extraction - Supports caching, retry, GPU resources, tags, DAG wiring, and execution groups - Returns framework-native objects wrapped as FlowyML assets
Classes
Functions
load_csv_data
load_csv_data(
file_path: str,
batch_size: int = 32,
label_name: str | None = None,
column_names: list[str] | None = None,
shuffle: bool = True,
num_workers: int = 0,
pin_memory: bool = False,
drop_last: bool = False,
dtype: str = "float32",
) -> Dataset
Load CSV data into a PyTorch DataLoader, wrapped as a Dataset asset.
Automatic metadata extraction captures batch size, source path, column names, and worker configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
Glob pattern for CSV files. |
required |
batch_size |
int
|
Batch size. |
32
|
label_name |
str | None
|
Target column name. |
None
|
column_names |
list[str] | None
|
Specific columns to load. |
None
|
shuffle |
bool
|
Whether to shuffle. |
True
|
num_workers |
int
|
Number of data loading workers. |
0
|
pin_memory |
bool
|
Pin memory for faster GPU transfer. |
False
|
drop_last |
bool
|
Drop the last incomplete batch. |
False
|
dtype |
str
|
Data type for tensors. |
'float32'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset wrapping the PyTorch DataLoader. |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
load_streaming_csv_data
load_streaming_csv_data(
file_path: str,
batch_size: int = 32,
label_name: str | None = None,
column_names: list[str] | None = None,
num_workers: int = 0,
pin_memory: bool = False,
chunksize: int = 10000,
dtype: str = "float32",
) -> Dataset
Load large CSV data via streaming into a PyTorch DataLoader, wrapped as a Dataset asset.
Uses chunked reading for datasets that don't fit in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
Glob pattern for CSV files. |
required |
batch_size |
int
|
Batch size. |
32
|
label_name |
str | None
|
Target column name. |
None
|
column_names |
list[str] | None
|
Specific columns. |
None
|
num_workers |
int
|
Number of data loading workers. |
0
|
pin_memory |
bool
|
Pin memory for faster GPU transfer. |
False
|
chunksize |
int
|
Number of rows per chunk. |
10000
|
dtype |
str
|
Data type for tensors. |
'float32'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset wrapping the streaming PyTorch DataLoader. |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
train_model
train_model(
model: nn.Module,
data: DataLoader | Dataset,
epochs: int = 10,
learning_rate: float = 0.001,
optimizer: str = "adam",
loss_fn: str = "mse",
device: str = "cpu",
validation_data: DataLoader | Dataset | None = None,
verbose: bool = True,
max_batches_per_epoch: int | None = None,
) -> tuple[Model, Metrics]
Train a PyTorch model with full configuration.
Returns a Model asset (via Model.from_pytorch with auto-extracted metadata) and a Metrics asset with training history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
nn.Module
|
PyTorch model (nn.Module). |
required |
data |
DataLoader | Dataset
|
Training DataLoader or Dataset asset. |
required |
epochs |
int
|
Number of training epochs. |
10
|
learning_rate |
float
|
Learning rate. |
0.001
|
optimizer |
str
|
Optimizer type ('adam', 'sgd', 'adamw'). |
'adam'
|
loss_fn |
str
|
Loss function name ('mse', 'cross_entropy'). |
'mse'
|
device |
str
|
Device to train on ('cuda', 'cpu'). |
'cpu'
|
validation_data |
DataLoader | Dataset | None
|
Optional validation DataLoader or Dataset. |
None
|
verbose |
bool
|
Whether to log per-epoch metrics. |
True
|
max_batches_per_epoch |
int | None
|
Limit batches per epoch (for debugging). |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Model, Metrics]
|
Tuple of (Model asset, Metrics asset). |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
evaluate_model
evaluate_model(
model: nn.Module | Model,
data: DataLoader | Dataset,
loss_fn: str = "mse",
device: str = "cpu",
verbose: bool = True,
max_batches: int | None = None,
) -> Metrics
Evaluate a PyTorch model and return a Metrics asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
nn.Module | Model
|
Trained PyTorch model or Model asset. |
required |
data |
DataLoader | Dataset
|
Evaluation DataLoader or Dataset asset. |
required |
loss_fn |
str
|
Loss function name. |
'mse'
|
device |
str
|
Device for evaluation. |
'cpu'
|
verbose |
bool
|
Whether to log metrics. |
True
|
max_batches |
int | None
|
Limit batches to evaluate. |
None
|
Returns:
| Type | Description |
|---|---|
Metrics
|
Metrics asset with evaluation results. |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
export_model
export_model(
model: nn.Module | Model,
export_path: str,
export_format: str = "torchscript",
sample_input: torch.Tensor | None = None,
) -> Model
Export a PyTorch model to the specified format, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
nn.Module | Model
|
PyTorch model or Model asset to export. |
required |
export_path |
str
|
Destination path. |
required |
export_format |
str
|
Format ('torchscript', 'onnx'). |
'torchscript'
|
sample_input |
torch.Tensor | None
|
Sample input tensor (required for ONNX). |
None
|
Returns:
| Type | Description |
|---|---|
Model
|
Model asset with export metadata. |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
save_model
save_model(
model: nn.Module | Model, save_path: str
) -> Model
Save a PyTorch model to disk, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
nn.Module | Model
|
PyTorch model or Model asset to save. |
required |
save_path |
str
|
Destination file path. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
Model asset with save location metadata. |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
load_model
load_model(
model_path: str,
model_class: type | None = None,
device: str | None = None,
) -> Model
Load a PyTorch model from disk, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path |
str
|
Path to the saved model. |
required |
model_class |
type | None
|
Model class for state_dict loading. |
None
|
device |
str | None
|
Device to load model onto. |
None
|
Returns:
| Type | Description |
|---|---|
Model
|
Model asset wrapping the loaded PyTorch model. |
Source code in mlpotion/integrations/flowyml/pytorch/steps.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
Pipelines
mlpotion.integrations.flowyml.pytorch.pipelines
Pre-built FlowyML pipeline templates for PyTorch workflows.
Provides ready-to-run pipelines that wire MLPotion PyTorch steps together with proper DAG dependencies, context injection, experiment tracking, and optional scheduling.
Available pipelines:
- create_pytorch_training_pipeline — Load → Train → Evaluate
- create_pytorch_full_pipeline — Load → Train → Evaluate → Export → Save
- create_pytorch_evaluation_pipeline — Load model + data → Evaluate
- create_pytorch_export_pipeline — Load model → Export + Save
- create_pytorch_experiment_pipeline — Full pipeline with conditional deploy
- create_pytorch_scheduled_pipeline — Scheduled retraining with cron
Functions
create_pytorch_training_pipeline
create_pytorch_training_pipeline(
name: str = "pytorch_training",
context: Context | None = None,
enable_cache: bool = True,
project_name: str | None = None,
version: str | None = None,
) -> Pipeline
Create a ready-to-run PyTorch training pipeline.
DAG: load_csv_data → train_model → evaluate_model
Provide hyperparameters via the context object::
from flowyml.core.context import Context
ctx = Context(
file_path="data/train.csv",
label_name="target",
batch_size=32,
epochs=20,
learning_rate=0.001,
optimizer="adam",
loss_fn="cross_entropy",
device="cuda",
)
pipeline = create_pytorch_training_pipeline(
name="my_training",
context=ctx,
project_name="my_project",
)
result = pipeline.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'pytorch_training'
|
context |
Context | None
|
FlowyML Context with parameters to inject. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string for versioned pipeline. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/pytorch/pipelines.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
create_pytorch_full_pipeline
create_pytorch_full_pipeline(
name: str = "pytorch_full",
context: Context | None = None,
enable_cache: bool = True,
enable_checkpointing: bool = True,
project_name: str | None = None,
version: str | None = None,
) -> Pipeline
Create a full PyTorch pipeline covering the entire ML lifecycle.
DAG: load_csv_data → train_model → evaluate_model → export_model → save_model
Includes checkpointing for long-running training steps so the pipeline can resume from the last checkpoint on failure.
Context parameters::
ctx = Context(
# Data loading
file_path="data/train.csv",
label_name="target",
batch_size=64,
# Training
epochs=100,
learning_rate=0.001,
optimizer="adamw",
loss_fn="cross_entropy",
device="cuda",
# Export
export_path="models/production/model.pt",
export_format="torchscript",
save_path="models/backup/model.pt",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'pytorch_full'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
enable_checkpointing |
bool
|
Whether to enable checkpointing. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/pytorch/pipelines.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
create_pytorch_evaluation_pipeline
create_pytorch_evaluation_pipeline(
name: str = "pytorch_evaluation",
context: Context | None = None,
enable_cache: bool = True,
project_name: str | None = None,
) -> Pipeline
Create a pipeline for evaluating an existing PyTorch model.
DAG: load_model → load_csv_data → evaluate_model
Useful for model validation, A/B testing, and periodic evaluation against new data without retraining.
Context parameters::
ctx = Context(
model_path="models/production/model.pt",
file_path="data/test.csv",
label_name="target",
batch_size=64,
device="cuda",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'pytorch_evaluation'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/pytorch/pipelines.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
create_pytorch_export_pipeline
create_pytorch_export_pipeline(
name: str = "pytorch_export",
context: Context | None = None,
project_name: str | None = None,
) -> Pipeline
Create a pipeline for exporting and saving an existing model.
DAG: load_model → export_model, save_model
Useful for converting a trained model to TorchScript or ONNX and persisting to different locations.
Context parameters::
ctx = Context(
model_path="models/trained/model.pt",
export_path="models/exported/model.ts",
export_format="torchscript",
save_path="models/backup/model.pt",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'pytorch_export'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/pytorch/pipelines.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
create_pytorch_experiment_pipeline
create_pytorch_experiment_pipeline(
name: str = "pytorch_experiment",
context: Context | None = None,
project_name: str | None = None,
version: str | None = None,
deploy_threshold: float = 0.8,
threshold_metric: str = "accuracy",
) -> Pipeline
Create a full experiment pipeline with conditional deployment.
DAG::
load_csv_data → train_model → evaluate_model
↓
[if metric > threshold]
↓
export_model → save_model
Conditionally exports the model only if validation metrics exceed the given threshold.
Context parameters::
ctx = Context(
file_path="data/train.csv",
label_name="target",
batch_size=32,
epochs=50,
learning_rate=0.001,
optimizer="adamw",
device="cuda",
export_path="models/production/model.pt",
save_path="models/checkpoints/model.pt",
)
pipeline = create_pytorch_experiment_pipeline(
context=ctx,
deploy_threshold=0.85,
threshold_metric="accuracy",
)
result = pipeline.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'pytorch_experiment'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string. |
None
|
deploy_threshold |
float
|
Minimum metric value to trigger deployment. |
0.8
|
threshold_metric |
str
|
Which metric to check against the threshold. |
'accuracy'
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/pytorch/pipelines.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
create_pytorch_scheduled_pipeline
create_pytorch_scheduled_pipeline(
name: str = "pytorch_scheduled_retraining",
context: Context | None = None,
project_name: str | None = None,
schedule: str = "0 2 * * 0",
timezone: str = "UTC",
) -> dict[str, Any]
Create a scheduled retraining pipeline.
Returns both the pipeline and a configured scheduler so you can register periodic retraining (e.g., weekly) with a single call.
DAG: load_csv_data → train_model → evaluate_model → export_model
Schedule format uses cron syntax (default: every Sunday at 2 AM)::
pipeline_info = create_pytorch_scheduled_pipeline(
context=ctx,
project_name="my_project",
schedule="0 2 * * 0", # Weekly
)
# Access the components
pipeline = pipeline_info["pipeline"]
scheduler = pipeline_info["scheduler"]
# Run once immediately
result = pipeline.run()
# Or start the scheduler for automatic retraining
scheduler.start()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'pytorch_scheduled_retraining'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
schedule |
str
|
Cron expression for scheduling. |
'0 2 * * 0'
|
timezone |
str
|
Timezone for the schedule. |
'UTC'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |
Source code in mlpotion/integrations/flowyml/pytorch/pipelines.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
TensorFlow Integration
Steps
mlpotion.integrations.flowyml.tensorflow.steps
FlowyML TensorFlow steps — Full-featured pipeline steps for TF/Keras workflows.
Each step leverages FlowyML's native capabilities: - Artifact-centric design: returns Dataset, Model, Metrics with auto-extraction - Supports caching, retry, GPU resources, tags, DAG wiring, and execution groups - train_model integrates FlowymlKerasCallback for automatic tracking
Classes
Functions
load_data
load_data(
file_path: str,
batch_size: int = 32,
label_name: str = "target",
column_names: list[str] | None = None,
) -> Dataset
Load CSV data into a tf.data.Dataset, wrapped as a Dataset asset.
Automatic metadata extraction captures batch size, source path, label name, and column configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
Glob pattern for CSV files. |
required |
batch_size |
int
|
Batch size. |
32
|
label_name |
str
|
Target column name. |
'target'
|
column_names |
list[str] | None
|
Specific columns to load. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset wrapping the tf.data.Dataset. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
optimize_data
optimize_data(
dataset: tf.data.Dataset | Dataset,
batch_size: int = 32,
shuffle_buffer_size: int | None = None,
prefetch: bool = True,
cache: bool = False,
) -> Dataset
Optimize a tf.data.Dataset with caching and prefetching, returned as Dataset asset.
Returns a Dataset asset with lineage linked to the input dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset |
tf.data.Dataset | Dataset
|
Input tf.data.Dataset or Dataset asset. |
required |
batch_size |
int
|
Batch size. |
32
|
shuffle_buffer_size |
int | None
|
Shuffle buffer size. |
None
|
prefetch |
bool
|
Enable prefetching. |
True
|
cache |
bool
|
Enable dataset caching. |
False
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset wrapping the optimized tf.data.Dataset. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
transform_data
transform_data(
dataset: tf.data.Dataset | Dataset,
model: keras.Model | Model,
data_output_path: str,
data_output_per_batch: bool = False,
) -> Dataset
Transform data using a model and save predictions to CSV, returned as a Dataset asset.
Returns a Dataset asset with lineage linked to the input dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset |
tf.data.Dataset | Dataset
|
Input tf.data.Dataset or Dataset asset. |
required |
model |
keras.Model | Model
|
Keras/TF model or Model asset for generating predictions. |
required |
data_output_path |
str
|
Output path for transformed data. |
required |
data_output_per_batch |
bool
|
If True, output one file per batch. |
False
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset asset pointing to the output CSV with parent lineage. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
train_model
train_model(
model: keras.Model,
data: tf.data.Dataset | Dataset,
epochs: int = 10,
learning_rate: float = 0.001,
verbose: int = 1,
validation_data: tf.data.Dataset
| Dataset
| None = None,
callbacks: list[keras.callbacks.Callback] | None = None,
experiment_name: str | None = None,
project: str | None = None,
log_model: bool = True,
) -> tuple[Model, Metrics]
Train a TF/Keras model with FlowyML tracking integration.
Automatically attaches a FlowymlKerasCallback for: - Dynamic capture of ALL training metrics - Live dashboard updates - Model artifact logging
Returns a Model asset (via Model.from_keras with auto-extracted metadata) and a Metrics asset with training history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model
|
Compiled Keras model. |
required |
data |
tf.data.Dataset | Dataset
|
Training tf.data.Dataset or Dataset asset. |
required |
epochs |
int
|
Number of training epochs. |
10
|
learning_rate |
float
|
Learning rate. |
0.001
|
verbose |
int
|
Keras verbosity level. |
1
|
validation_data |
tf.data.Dataset | Dataset | None
|
Optional validation dataset or Dataset asset. |
None
|
callbacks |
list[keras.callbacks.Callback] | None
|
Additional Keras callbacks. |
None
|
experiment_name |
str | None
|
Experiment name for FlowyML tracking. |
None
|
project |
str | None
|
Project name for FlowyML dashboard. |
None
|
log_model |
bool
|
Whether to save model artifact after training. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Model, Metrics]
|
Tuple of (Model asset, Metrics asset). |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
evaluate_model
evaluate_model(
model: keras.Model | Model,
data: tf.data.Dataset | Dataset,
verbose: int = 0,
) -> Metrics
Evaluate a TF/Keras model and return a Metrics asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Trained Keras model or Model asset. |
required |
data |
tf.data.Dataset | Dataset
|
Evaluation tf.data.Dataset or Dataset asset. |
required |
verbose |
int
|
Keras verbosity level. |
0
|
Returns:
| Type | Description |
|---|---|
Metrics
|
Metrics asset with evaluation results. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
export_model
export_model(
model: keras.Model | Model,
export_path: str,
export_format: str = "keras",
) -> Model
Export a TF/Keras model, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Keras model or Model asset to export. |
required |
export_path |
str
|
Destination path. |
required |
export_format |
str
|
Format ('saved_model', 'tflite', 'keras'). |
'keras'
|
Returns:
| Type | Description |
|---|---|
Model
|
Model asset with export metadata. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
save_model
save_model(
model: keras.Model | Model, save_path: str
) -> Model
Save a TF/Keras model to disk, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Keras model or Model asset to save. |
required |
save_path |
str
|
Destination file path. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
Model asset with save location metadata. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
load_model
load_model(model_path: str, inspect: bool = False) -> Model
Load a TF/Keras model from disk, returned as a Model asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path |
str
|
Path to the saved model. |
required |
inspect |
bool
|
If True, log model inspection info. |
False
|
Returns:
| Type | Description |
|---|---|
Model
|
Model asset wrapping the loaded Keras model. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
inspect_model
inspect_model(
model: keras.Model | Model,
include_layers: bool = True,
include_signatures: bool = True,
) -> Metrics
Inspect a TF/Keras model and return detailed metadata as a Metrics asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model |
keras.Model | Model
|
Keras model or Model asset to inspect. |
required |
include_layers |
bool
|
Include per-layer information. |
True
|
include_signatures |
bool
|
Include input/output signatures. |
True
|
Returns:
| Type | Description |
|---|---|
Metrics
|
Metrics asset with model inspection details. |
Source code in mlpotion/integrations/flowyml/tensorflow/steps.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
Pipelines
mlpotion.integrations.flowyml.tensorflow.pipelines
Pre-built FlowyML pipeline templates for TensorFlow/Keras workflows.
Provides ready-to-run pipelines that wire MLPotion TensorFlow steps together with proper DAG dependencies, context injection, experiment tracking, and optional scheduling.
Available pipelines:
- create_tf_training_pipeline — Load → Train → Evaluate
- create_tf_full_pipeline — Load → Optimize → Transform → Train → Evaluate → Export
- create_tf_evaluation_pipeline — Load model + data → Evaluate → Inspect
- create_tf_export_pipeline — Load model → Export + Save
- create_tf_experiment_pipeline — Full pipeline with conditional deploy
- create_tf_scheduled_pipeline — Scheduled retraining with cron
Functions
create_tf_training_pipeline
create_tf_training_pipeline(
name: str = "tf_training",
context: Context | None = None,
enable_cache: bool = True,
project_name: str | None = None,
version: str | None = None,
) -> Pipeline
Create a ready-to-run TensorFlow training pipeline.
DAG: load_data → train_model → evaluate_model
Provide hyperparameters via the context object::
from flowyml.core.context import Context
ctx = Context(
file_path="data/train.csv",
label_name="target",
batch_size=32,
epochs=10,
learning_rate=0.001,
experiment_name="my-experiment",
)
pipeline = create_tf_training_pipeline(
name="my_training",
context=ctx,
project_name="my_project",
)
result = pipeline.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'tf_training'
|
context |
Context | None
|
FlowyML Context with parameters to inject. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string for versioned pipeline. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/tensorflow/pipelines.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
create_tf_full_pipeline
create_tf_full_pipeline(
name: str = "tf_full",
context: Context | None = None,
enable_cache: bool = True,
enable_checkpointing: bool = True,
project_name: str | None = None,
version: str | None = None,
) -> Pipeline
Create a full TensorFlow pipeline covering the entire ML lifecycle.
DAG: load_data → optimize_data → train_model → evaluate_model → export_model
Includes data optimization (prefetch/cache/shuffle) and checkpointing for long-running training steps.
Context parameters::
ctx = Context(
# Data loading
file_path="data/train.csv",
label_name="target",
batch_size=32,
# Optimization
shuffle_buffer_size=10000,
prefetch=True,
cache=True,
# Training
epochs=50,
learning_rate=0.001,
experiment_name="full-run",
project="my_project",
# Export
export_path="models/production/",
export_format="saved_model",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'tf_full'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
enable_checkpointing |
bool
|
Whether to enable checkpointing. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/tensorflow/pipelines.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
create_tf_evaluation_pipeline
create_tf_evaluation_pipeline(
name: str = "tf_evaluation",
context: Context | None = None,
enable_cache: bool = True,
project_name: str | None = None,
) -> Pipeline
Create a pipeline for evaluating an existing TF/Keras model.
DAG: load_model → load_data → evaluate_model → inspect_model
Useful for model validation, A/B testing, and periodic evaluation against new data without retraining.
Context parameters::
ctx = Context(
model_path="models/production/model.keras",
file_path="data/test.csv",
label_name="target",
batch_size=64,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'tf_evaluation'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
enable_cache |
bool
|
Whether to enable step caching. |
True
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/tensorflow/pipelines.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
create_tf_export_pipeline
create_tf_export_pipeline(
name: str = "tf_export",
context: Context | None = None,
project_name: str | None = None,
) -> Pipeline
Create a pipeline for exporting and saving an existing model.
DAG: load_model → export_model, save_model
Useful for converting a trained model to multiple formats (SavedModel, TFLite, Keras) and persisting to different locations.
Context parameters::
ctx = Context(
model_path="models/trained/model.keras",
export_path="models/exported/",
export_format="saved_model",
save_path="models/backup/model.keras",
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'tf_export'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/tensorflow/pipelines.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
create_tf_experiment_pipeline
create_tf_experiment_pipeline(
name: str = "tf_experiment",
context: Context | None = None,
project_name: str | None = None,
version: str | None = None,
deploy_threshold: float = 0.8,
threshold_metric: str = "accuracy",
) -> Pipeline
Create a full experiment pipeline with conditional deployment.
DAG::
load_data → train_model → evaluate_model
↓
[if metric > threshold]
↓
export_model → save_model
Integrates FlowyML experiment tracking and conditionally exports the model only if validation metrics exceed the given threshold.
Context parameters::
ctx = Context(
file_path="data/train.csv",
label_name="target",
batch_size=32,
epochs=30,
learning_rate=0.001,
experiment_name="experiment-v1",
project="my_project",
export_path="models/production/",
save_path="models/checkpoints/model.keras",
)
pipeline = create_tf_experiment_pipeline(
context=ctx,
deploy_threshold=0.85,
threshold_metric="accuracy",
)
result = pipeline.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'tf_experiment'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
version |
str | None
|
Optional version string. |
None
|
deploy_threshold |
float
|
Minimum metric value to trigger deployment. |
0.8
|
threshold_metric |
str
|
Which metric to check against the threshold. |
'accuracy'
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured FlowyML Pipeline ready for |
Source code in mlpotion/integrations/flowyml/tensorflow/pipelines.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
create_tf_scheduled_pipeline
create_tf_scheduled_pipeline(
name: str = "tf_scheduled_retraining",
context: Context | None = None,
project_name: str | None = None,
schedule: str = "0 2 * * 0",
timezone: str = "UTC",
) -> dict[str, Any]
Create a scheduled retraining pipeline.
Returns both the pipeline and a configured scheduler so you can register periodic retraining (e.g., weekly) with a single call.
DAG: load_data → train_model → evaluate_model → export_model
Schedule format uses cron syntax (default: every Sunday at 2 AM)::
pipeline_info = create_tf_scheduled_pipeline(
context=ctx,
project_name="my_project",
schedule="0 2 * * 0", # Weekly
)
# Access the components
pipeline = pipeline_info["pipeline"]
scheduler = pipeline_info["scheduler"]
# Run once immediately
result = pipeline.run()
# Or start the scheduler for automatic retraining
scheduler.start()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Pipeline name. |
'tf_scheduled_retraining'
|
context |
Context | None
|
FlowyML Context with parameters. |
None
|
project_name |
str | None
|
Project to attach this pipeline to. |
None
|
schedule |
str
|
Cron expression for scheduling. |
'0 2 * * 0'
|
timezone |
str
|
Timezone for the schedule. |
'UTC'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |
Source code in mlpotion/integrations/flowyml/tensorflow/pipelines.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
See the FlowyML Integration Guide for complete usage documentation and tutorials