Created
January 27, 2026 17:59
-
-
Save Davidnet/e90e7dd2629547587b90397d5fb93bcc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import time | |
| from metaflow import FlowSpec, step, Parameter | |
| class MockPIITrainingPipeline(FlowSpec): | |
| """ | |
| Mock pipeline for testing Flow orchestration without heavy dependencies or GPU. | |
| """ | |
| skip_export = Parameter('skip_export', default=False, help="Skip export step") | |
| skip_quantization = Parameter('skip_quantization', default=False, help="Skip quantization step") | |
| @step | |
| def start(self): | |
| print("Starting Mock PII Training Pipeline...") | |
| time.sleep(5) | |
| self.next( | |
| {False: self.export_data, True: self.preprocess_data}, | |
| condition="skip_export", | |
| ) | |
| @step | |
| def export_data(self): | |
| print("Mock: Exporting data from Label Studio...") | |
| time.sleep(5) | |
| self.next(self.preprocess_data) | |
| @step | |
| def preprocess_data(self): | |
| print("Mock: Preprocessing training data...") | |
| time.sleep(5) | |
| self.next(self.train_model) | |
| @step | |
| def train_model(self): | |
| print("Mock: Training the PII detection model...") | |
| time.sleep(5) | |
| self.training_metrics = { | |
| "eval_pii_f1_weighted": 0.95, | |
| "training_time_seconds": 5 | |
| } | |
| raise RuntimeError("Simulated training error for testing purposes") | |
| self.next(self.evaluate_model) | |
| @step | |
| def evaluate_model(self): | |
| print("Mock: Evaluating model performance...") | |
| time.sleep(5) | |
| self.next( | |
| {False: self.quantize_model, True: self.sign_model}, | |
| condition="skip_quantization", | |
| ) | |
| @step | |
| def quantize_model(self): | |
| print("Mock: Quantizing model to ONNX format...") | |
| time.sleep(5) | |
| self.next(self.sign_model) | |
| @step | |
| def sign_model(self): | |
| print("Mock: Signing model with cryptographic hash...") | |
| time.sleep(5) | |
| self.next(self.end) | |
| @step | |
| def end(self): | |
| print("Mock Pipeline complete.") | |
| time.sleep(5) | |
| if __name__ == '__main__': | |
| MockPIITrainingPipeline() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Launch with: