javi-forge 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/ci-local/ci-local.sh +20 -8
  2. package/package.json +1 -1
  3. package/ai-config/.skillignore +0 -15
  4. package/ai-config/AUTO_INVOKE.md +0 -300
  5. package/ai-config/agents/_TEMPLATE.md +0 -93
  6. package/ai-config/agents/business/api-designer.md +0 -1657
  7. package/ai-config/agents/business/business-analyst.md +0 -1331
  8. package/ai-config/agents/business/product-strategist.md +0 -206
  9. package/ai-config/agents/business/project-manager.md +0 -178
  10. package/ai-config/agents/business/requirements-analyst.md +0 -1277
  11. package/ai-config/agents/business/technical-writer.md +0 -1679
  12. package/ai-config/agents/creative/ux-designer.md +0 -205
  13. package/ai-config/agents/data-ai/ai-engineer.md +0 -487
  14. package/ai-config/agents/data-ai/analytics-engineer.md +0 -953
  15. package/ai-config/agents/data-ai/data-engineer.md +0 -173
  16. package/ai-config/agents/data-ai/data-scientist.md +0 -672
  17. package/ai-config/agents/data-ai/mlops-engineer.md +0 -814
  18. package/ai-config/agents/data-ai/prompt-engineer.md +0 -772
  19. package/ai-config/agents/development/angular-expert.md +0 -620
  20. package/ai-config/agents/development/backend-architect.md +0 -795
  21. package/ai-config/agents/development/database-specialist.md +0 -212
  22. package/ai-config/agents/development/frontend-specialist.md +0 -686
  23. package/ai-config/agents/development/fullstack-engineer.md +0 -668
  24. package/ai-config/agents/development/golang-pro.md +0 -338
  25. package/ai-config/agents/development/java-enterprise.md +0 -400
  26. package/ai-config/agents/development/javascript-pro.md +0 -422
  27. package/ai-config/agents/development/nextjs-pro.md +0 -474
  28. package/ai-config/agents/development/python-pro.md +0 -570
  29. package/ai-config/agents/development/react-pro.md +0 -487
  30. package/ai-config/agents/development/rust-pro.md +0 -246
  31. package/ai-config/agents/development/spring-boot-4-expert.md +0 -326
  32. package/ai-config/agents/development/typescript-pro.md +0 -336
  33. package/ai-config/agents/development/vue-specialist.md +0 -605
  34. package/ai-config/agents/infrastructure/cloud-architect.md +0 -472
  35. package/ai-config/agents/infrastructure/deployment-manager.md +0 -358
  36. package/ai-config/agents/infrastructure/devops-engineer.md +0 -455
  37. package/ai-config/agents/infrastructure/incident-responder.md +0 -519
  38. package/ai-config/agents/infrastructure/kubernetes-expert.md +0 -705
  39. package/ai-config/agents/infrastructure/monitoring-specialist.md +0 -674
  40. package/ai-config/agents/infrastructure/performance-engineer.md +0 -658
  41. package/ai-config/agents/orchestrator.md +0 -241
  42. package/ai-config/agents/quality/accessibility-auditor.md +0 -1204
  43. package/ai-config/agents/quality/code-reviewer-compact.md +0 -123
  44. package/ai-config/agents/quality/code-reviewer.md +0 -363
  45. package/ai-config/agents/quality/dependency-manager.md +0 -743
  46. package/ai-config/agents/quality/e2e-test-specialist.md +0 -1005
  47. package/ai-config/agents/quality/performance-tester.md +0 -1086
  48. package/ai-config/agents/quality/security-auditor.md +0 -133
  49. package/ai-config/agents/quality/test-engineer.md +0 -453
  50. package/ai-config/agents/specialists/api-designer.md +0 -87
  51. package/ai-config/agents/specialists/backend-architect.md +0 -73
  52. package/ai-config/agents/specialists/code-reviewer.md +0 -77
  53. package/ai-config/agents/specialists/db-optimizer.md +0 -75
  54. package/ai-config/agents/specialists/devops-engineer.md +0 -83
  55. package/ai-config/agents/specialists/documentation-writer.md +0 -78
  56. package/ai-config/agents/specialists/frontend-developer.md +0 -75
  57. package/ai-config/agents/specialists/performance-analyst.md +0 -82
  58. package/ai-config/agents/specialists/refactor-specialist.md +0 -74
  59. package/ai-config/agents/specialists/security-auditor.md +0 -74
  60. package/ai-config/agents/specialists/test-engineer.md +0 -81
  61. package/ai-config/agents/specialists/ux-consultant.md +0 -76
  62. package/ai-config/agents/specialized/agent-generator.md +0 -1190
  63. package/ai-config/agents/specialized/blockchain-developer.md +0 -149
  64. package/ai-config/agents/specialized/code-migrator.md +0 -892
  65. package/ai-config/agents/specialized/context-manager.md +0 -978
  66. package/ai-config/agents/specialized/documentation-writer.md +0 -1078
  67. package/ai-config/agents/specialized/ecommerce-expert.md +0 -1756
  68. package/ai-config/agents/specialized/embedded-engineer.md +0 -1714
  69. package/ai-config/agents/specialized/error-detective.md +0 -1034
  70. package/ai-config/agents/specialized/fintech-specialist.md +0 -1659
  71. package/ai-config/agents/specialized/freelance-project-planner-v2.md +0 -1988
  72. package/ai-config/agents/specialized/freelance-project-planner-v3.md +0 -2136
  73. package/ai-config/agents/specialized/freelance-project-planner-v4.md +0 -4503
  74. package/ai-config/agents/specialized/freelance-project-planner.md +0 -722
  75. package/ai-config/agents/specialized/game-developer.md +0 -1963
  76. package/ai-config/agents/specialized/healthcare-dev.md +0 -1620
  77. package/ai-config/agents/specialized/mobile-developer.md +0 -188
  78. package/ai-config/agents/specialized/parallel-plan-executor.md +0 -506
  79. package/ai-config/agents/specialized/plan-executor.md +0 -485
  80. package/ai-config/agents/specialized/solo-dev-planner-modular/00-INDEX.md +0 -485
  81. package/ai-config/agents/specialized/solo-dev-planner-modular/01-CORE.md +0 -3493
  82. package/ai-config/agents/specialized/solo-dev-planner-modular/02-SELF-CORRECTION.md +0 -778
  83. package/ai-config/agents/specialized/solo-dev-planner-modular/03-PROGRESSIVE-SETUP.md +0 -918
  84. package/ai-config/agents/specialized/solo-dev-planner-modular/04-DEPLOYMENT.md +0 -1537
  85. package/ai-config/agents/specialized/solo-dev-planner-modular/05-TESTING.md +0 -2633
  86. package/ai-config/agents/specialized/solo-dev-planner-modular/06-OPERATIONS.md +0 -5610
  87. package/ai-config/agents/specialized/solo-dev-planner-modular/INSTALL.md +0 -335
  88. package/ai-config/agents/specialized/solo-dev-planner-modular/QUICK-REFERENCE.txt +0 -215
  89. package/ai-config/agents/specialized/solo-dev-planner-modular/README.md +0 -260
  90. package/ai-config/agents/specialized/solo-dev-planner-modular/START-HERE.md +0 -379
  91. package/ai-config/agents/specialized/solo-dev-planner-modular/WORKFLOW-DIAGRAM.md +0 -355
  92. package/ai-config/agents/specialized/solo-dev-planner-modular/solo-dev-planner.md +0 -279
  93. package/ai-config/agents/specialized/template-writer.md +0 -347
  94. package/ai-config/agents/specialized/test-runner.md +0 -99
  95. package/ai-config/agents/specialized/vibekanban-smart-worker.md +0 -244
  96. package/ai-config/agents/specialized/wave-executor.md +0 -138
  97. package/ai-config/agents/specialized/workflow-optimizer.md +0 -1114
  98. package/ai-config/commands/git/changelog.md +0 -32
  99. package/ai-config/commands/git/ci-local.md +0 -70
  100. package/ai-config/commands/git/commit.md +0 -35
  101. package/ai-config/commands/git/fix-issue.md +0 -23
  102. package/ai-config/commands/git/pr-create.md +0 -42
  103. package/ai-config/commands/git/pr-review.md +0 -50
  104. package/ai-config/commands/git/worktree.md +0 -39
  105. package/ai-config/commands/refactoring/cleanup.md +0 -24
  106. package/ai-config/commands/refactoring/dead-code.md +0 -40
  107. package/ai-config/commands/refactoring/extract.md +0 -31
  108. package/ai-config/commands/testing/e2e.md +0 -30
  109. package/ai-config/commands/testing/tdd.md +0 -36
  110. package/ai-config/commands/testing/test-coverage.md +0 -30
  111. package/ai-config/commands/testing/test-fix.md +0 -24
  112. package/ai-config/commands/workflow/generate-agents-md.md +0 -85
  113. package/ai-config/commands/workflow/planning.md +0 -47
  114. package/ai-config/commands/workflows/compound.md +0 -89
  115. package/ai-config/commands/workflows/diagnose.md +0 -70
  116. package/ai-config/commands/workflows/discover.md +0 -86
  117. package/ai-config/commands/workflows/plan.md +0 -77
  118. package/ai-config/commands/workflows/review.md +0 -78
  119. package/ai-config/commands/workflows/work.md +0 -75
  120. package/ai-config/config.yaml +0 -18
  121. package/ai-config/hooks/_TEMPLATE.md +0 -96
  122. package/ai-config/hooks/block-dangerous-commands.md +0 -75
  123. package/ai-config/hooks/commit-guard.md +0 -90
  124. package/ai-config/hooks/context-loader.md +0 -73
  125. package/ai-config/hooks/improve-prompt.md +0 -91
  126. package/ai-config/hooks/learning-log.md +0 -72
  127. package/ai-config/hooks/model-router.md +0 -86
  128. package/ai-config/hooks/secret-scanner.md +0 -64
  129. package/ai-config/hooks/skill-validator.md +0 -102
  130. package/ai-config/hooks/task-artifact.md +0 -114
  131. package/ai-config/hooks/validate-workflow.md +0 -100
  132. package/ai-config/prompts/base.md +0 -71
  133. package/ai-config/prompts/modes/debug.md +0 -34
  134. package/ai-config/prompts/modes/deploy.md +0 -40
  135. package/ai-config/prompts/modes/research.md +0 -32
  136. package/ai-config/prompts/modes/review.md +0 -33
  137. package/ai-config/prompts/review-policy.md +0 -79
  138. package/ai-config/skills/_TEMPLATE.md +0 -157
  139. package/ai-config/skills/backend/api-gateway/SKILL.md +0 -254
  140. package/ai-config/skills/backend/bff-concepts/SKILL.md +0 -239
  141. package/ai-config/skills/backend/bff-spring/SKILL.md +0 -364
  142. package/ai-config/skills/backend/chi-router/SKILL.md +0 -396
  143. package/ai-config/skills/backend/error-handling/SKILL.md +0 -255
  144. package/ai-config/skills/backend/exceptions-spring/SKILL.md +0 -323
  145. package/ai-config/skills/backend/fastapi/SKILL.md +0 -302
  146. package/ai-config/skills/backend/gateway-spring/SKILL.md +0 -390
  147. package/ai-config/skills/backend/go-backend/SKILL.md +0 -457
  148. package/ai-config/skills/backend/gradle-multimodule/SKILL.md +0 -274
  149. package/ai-config/skills/backend/graphql-concepts/SKILL.md +0 -352
  150. package/ai-config/skills/backend/graphql-spring/SKILL.md +0 -398
  151. package/ai-config/skills/backend/grpc-concepts/SKILL.md +0 -283
  152. package/ai-config/skills/backend/grpc-spring/SKILL.md +0 -445
  153. package/ai-config/skills/backend/jwt-auth/SKILL.md +0 -412
  154. package/ai-config/skills/backend/notifications-concepts/SKILL.md +0 -259
  155. package/ai-config/skills/backend/recommendations-concepts/SKILL.md +0 -261
  156. package/ai-config/skills/backend/search-concepts/SKILL.md +0 -263
  157. package/ai-config/skills/backend/search-spring/SKILL.md +0 -375
  158. package/ai-config/skills/backend/spring-boot-4/SKILL.md +0 -172
  159. package/ai-config/skills/backend/websockets/SKILL.md +0 -532
  160. package/ai-config/skills/data-ai/ai-ml/SKILL.md +0 -423
  161. package/ai-config/skills/data-ai/analytics-concepts/SKILL.md +0 -195
  162. package/ai-config/skills/data-ai/analytics-spring/SKILL.md +0 -340
  163. package/ai-config/skills/data-ai/duckdb-analytics/SKILL.md +0 -440
  164. package/ai-config/skills/data-ai/langchain/SKILL.md +0 -238
  165. package/ai-config/skills/data-ai/mlflow/SKILL.md +0 -302
  166. package/ai-config/skills/data-ai/onnx-inference/SKILL.md +0 -290
  167. package/ai-config/skills/data-ai/powerbi/SKILL.md +0 -352
  168. package/ai-config/skills/data-ai/pytorch/SKILL.md +0 -274
  169. package/ai-config/skills/data-ai/scikit-learn/SKILL.md +0 -321
  170. package/ai-config/skills/data-ai/vector-db/SKILL.md +0 -301
  171. package/ai-config/skills/database/graph-databases/SKILL.md +0 -218
  172. package/ai-config/skills/database/graph-spring/SKILL.md +0 -361
  173. package/ai-config/skills/database/pgx-postgres/SKILL.md +0 -512
  174. package/ai-config/skills/database/redis-cache/SKILL.md +0 -343
  175. package/ai-config/skills/database/sqlite-embedded/SKILL.md +0 -388
  176. package/ai-config/skills/database/timescaledb/SKILL.md +0 -320
  177. package/ai-config/skills/docs/api-documentation/SKILL.md +0 -293
  178. package/ai-config/skills/docs/docs-spring/SKILL.md +0 -377
  179. package/ai-config/skills/docs/mustache-templates/SKILL.md +0 -190
  180. package/ai-config/skills/docs/technical-docs/SKILL.md +0 -447
  181. package/ai-config/skills/frontend/astro-ssr/SKILL.md +0 -441
  182. package/ai-config/skills/frontend/frontend-design/SKILL.md +0 -54
  183. package/ai-config/skills/frontend/frontend-web/SKILL.md +0 -368
  184. package/ai-config/skills/frontend/mantine-ui/SKILL.md +0 -396
  185. package/ai-config/skills/frontend/tanstack-query/SKILL.md +0 -439
  186. package/ai-config/skills/frontend/zod-validation/SKILL.md +0 -417
  187. package/ai-config/skills/frontend/zustand-state/SKILL.md +0 -350
  188. package/ai-config/skills/infrastructure/chaos-engineering/SKILL.md +0 -244
  189. package/ai-config/skills/infrastructure/chaos-spring/SKILL.md +0 -378
  190. package/ai-config/skills/infrastructure/devops-infra/SKILL.md +0 -435
  191. package/ai-config/skills/infrastructure/docker-containers/SKILL.md +0 -420
  192. package/ai-config/skills/infrastructure/kubernetes/SKILL.md +0 -456
  193. package/ai-config/skills/infrastructure/opentelemetry/SKILL.md +0 -546
  194. package/ai-config/skills/infrastructure/traefik-proxy/SKILL.md +0 -474
  195. package/ai-config/skills/infrastructure/woodpecker-ci/SKILL.md +0 -315
  196. package/ai-config/skills/mobile/ionic-capacitor/SKILL.md +0 -504
  197. package/ai-config/skills/mobile/mobile-ionic/SKILL.md +0 -448
  198. package/ai-config/skills/prompt-improver/SKILL.md +0 -125
  199. package/ai-config/skills/quality/ghagga-review/SKILL.md +0 -216
  200. package/ai-config/skills/references/hooks-patterns/SKILL.md +0 -238
  201. package/ai-config/skills/references/mcp-servers/SKILL.md +0 -275
  202. package/ai-config/skills/references/plugins-reference/SKILL.md +0 -110
  203. package/ai-config/skills/references/skills-reference/SKILL.md +0 -420
  204. package/ai-config/skills/references/subagent-templates/SKILL.md +0 -193
  205. package/ai-config/skills/systems-iot/modbus-protocol/SKILL.md +0 -410
  206. package/ai-config/skills/systems-iot/mqtt-rumqttc/SKILL.md +0 -408
  207. package/ai-config/skills/systems-iot/rust-systems/SKILL.md +0 -386
  208. package/ai-config/skills/systems-iot/tokio-async/SKILL.md +0 -324
  209. package/ai-config/skills/testing/playwright-e2e/SKILL.md +0 -289
  210. package/ai-config/skills/testing/testcontainers/SKILL.md +0 -299
  211. package/ai-config/skills/testing/vitest-testing/SKILL.md +0 -381
  212. package/ai-config/skills/workflow/ci-local-guide/SKILL.md +0 -118
  213. package/ai-config/skills/workflow/claude-automation-recommender/SKILL.md +0 -299
  214. package/ai-config/skills/workflow/claude-md-improver/SKILL.md +0 -158
  215. package/ai-config/skills/workflow/finishing-a-development-branch/SKILL.md +0 -117
  216. package/ai-config/skills/workflow/git-github/SKILL.md +0 -334
  217. package/ai-config/skills/workflow/git-github/references/examples.md +0 -160
  218. package/ai-config/skills/workflow/git-workflow/SKILL.md +0 -214
  219. package/ai-config/skills/workflow/ide-plugins/SKILL.md +0 -277
  220. package/ai-config/skills/workflow/ide-plugins-intellij/SKILL.md +0 -401
  221. package/ai-config/skills/workflow/obsidian-brain-workflow/SKILL.md +0 -199
  222. package/ai-config/skills/workflow/using-git-worktrees/SKILL.md +0 -100
  223. package/ai-config/skills/workflow/verification-before-completion/SKILL.md +0 -73
  224. package/ai-config/skills/workflow/wave-workflow/SKILL.md +0 -178
  225. package/schemas/agent.schema.json +0 -34
  226. package/schemas/ai-config.schema.json +0 -28
  227. package/schemas/plugin.schema.json +0 -62
  228. package/schemas/skill.schema.json +0 -44
@@ -1,302 +0,0 @@
1
- ---
2
- name: mlflow
3
- description: >
4
- ML experiment tracking, model registry, and deployment with MLflow.
5
- Trigger: mlflow, experiment tracking, model registry, mlops, model versioning
6
- tools:
7
- - Read
8
- - Write
9
- - Bash
10
- - Grep
11
- metadata:
12
- author: plataforma-industrial
13
- version: "2.0"
14
- tags: [mlflow, mlops, experiment-tracking, model-registry]
15
- updated: "2026-02"
16
- ---
17
-
18
- # MLflow Skill
19
-
20
- ML experiment tracking, model registry, and deployment.
21
-
22
- ## Stack
23
-
24
- ```yaml
25
- mlflow: 2.10+
26
- mlflow-skinny: 2.10+ # client only
27
- boto3: 1.34+ # S3 artifacts
28
- psycopg2: 2.9+ # PostgreSQL backend
29
- ```
30
-
31
- ## Docker Setup
32
-
33
- ```yaml
34
- # docker-compose.mlflow.yml
35
- services:
36
- mlflow:
37
- image: ghcr.io/mlflow/mlflow:v2.10.0
38
- ports:
39
- - "5000:5000"
40
- environment:
41
- - MLFLOW_BACKEND_STORE_URI=postgresql://mlflow:mlflow@postgres:5432/mlflow
42
- - MLFLOW_DEFAULT_ARTIFACT_ROOT=s3://mlflow-artifacts
43
- command: >
44
- mlflow server
45
- --backend-store-uri postgresql://mlflow:mlflow@postgres:5432/mlflow
46
- --default-artifact-root s3://mlflow-artifacts
47
- --host 0.0.0.0 --port 5000
48
- depends_on:
49
- - postgres
50
-
51
- postgres:
52
- image: postgres:16-alpine
53
- environment:
54
- POSTGRES_USER: mlflow
55
- POSTGRES_PASSWORD: mlflow
56
- POSTGRES_DB: mlflow
57
- volumes:
58
- - mlflow_db:/var/lib/postgresql/data
59
-
60
- volumes:
61
- mlflow_db:
62
- ```
63
-
64
- ## Client Configuration
65
-
66
- ```python
67
- import os
68
- import mlflow
69
-
70
- def setup_mlflow():
71
- mlflow.set_tracking_uri(os.getenv("MLFLOW_TRACKING_URI", "http://localhost:5000"))
72
- mlflow.set_experiment("my-project")
73
- mlflow.sklearn.autolog() # Enable autologging
74
- mlflow.pytorch.autolog()
75
- ```
76
-
77
- ## Experiment Tracking
78
-
79
- ```python
80
- import mlflow
81
- from mlflow.models import infer_signature
82
- from datetime import datetime
83
-
84
- def train_with_tracking(model, X_train, y_train, X_test, y_test, model_name: str, tags: dict = None):
85
- with mlflow.start_run(run_name=f"{model_name}_{datetime.now().strftime('%Y%m%d_%H%M')}"):
86
- # Tags
87
- mlflow.set_tags({
88
- "model_type": model_name,
89
- "environment": os.getenv("ENVIRONMENT", "dev"),
90
- **(tags or {})
91
- })
92
-
93
- # Parameters
94
- if hasattr(model, 'get_params'):
95
- mlflow.log_params(model.get_params())
96
-
97
- # Train
98
- model.fit(X_train, y_train)
99
- y_pred = model.predict(X_test)
100
-
101
- # Metrics
102
- from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score
103
- mlflow.log_metrics({
104
- "accuracy": accuracy_score(y_test, y_pred),
105
- "f1_score": f1_score(y_test, y_pred, average='weighted'),
106
- "precision": precision_score(y_test, y_pred, average='weighted'),
107
- "recall": recall_score(y_test, y_pred, average='weighted'),
108
- })
109
-
110
- # Log model with signature
111
- signature = infer_signature(X_train, y_pred)
112
- mlflow.sklearn.log_model(model, "model", signature=signature, registered_model_name=model_name)
113
-
114
- # Log confusion matrix
115
- log_confusion_matrix(y_test, y_pred)
116
-
117
- return mlflow.active_run().info.run_id
118
-
119
- def log_confusion_matrix(y_true, y_pred):
120
- import matplotlib.pyplot as plt
121
- import seaborn as sns
122
- from sklearn.metrics import confusion_matrix
123
-
124
- cm = confusion_matrix(y_true, y_pred)
125
- fig, ax = plt.subplots(figsize=(8, 6))
126
- sns.heatmap(cm, annot=True, fmt='d', ax=ax)
127
- ax.set_xlabel('Predicted')
128
- ax.set_ylabel('Actual')
129
- plt.savefig('/tmp/confusion_matrix.png')
130
- mlflow.log_artifact('/tmp/confusion_matrix.png')
131
- plt.close()
132
- ```
133
-
134
- ## PyTorch Lightning Integration
135
-
136
- ```python
137
- import lightning as L
138
- from lightning.pytorch.loggers import MLFlowLogger
139
- from lightning.pytorch.callbacks import ModelCheckpoint, EarlyStopping
140
-
141
- def train_with_lightning(model: L.LightningModule, datamodule: L.LightningDataModule, experiment_name: str):
142
- mlflow_logger = MLFlowLogger(
143
- experiment_name=experiment_name,
144
- tracking_uri=os.getenv("MLFLOW_TRACKING_URI"),
145
- log_model=True
146
- )
147
-
148
- trainer = L.Trainer(
149
- max_epochs=100,
150
- accelerator="auto",
151
- logger=mlflow_logger,
152
- callbacks=[
153
- ModelCheckpoint(monitor="val_loss", mode="min", save_top_k=3),
154
- EarlyStopping(monitor="val_loss", patience=10)
155
- ]
156
- )
157
-
158
- mlflow_logger.log_hyperparams(model.hparams)
159
- trainer.fit(model, datamodule)
160
- trainer.test(model, datamodule)
161
- return mlflow_logger.run_id
162
- ```
163
-
164
- ## Model Registry
165
-
166
- ```python
167
- from mlflow.tracking import MlflowClient
168
-
169
- def register_model(run_id: str, model_name: str, description: str = None, tags: dict = None):
170
- client = MlflowClient()
171
- model_uri = f"runs:/{run_id}/model"
172
- result = mlflow.register_model(model_uri, model_name)
173
-
174
- if description:
175
- client.update_registered_model(name=model_name, description=description)
176
-
177
- if tags:
178
- for key, value in tags.items():
179
- client.set_model_version_tag(name=model_name, version=result.version, key=key, value=value)
180
-
181
- print(f"Registered {model_name} v{result.version}")
182
- return result.version
183
-
184
- def promote_model(model_name: str, version: int, stage: str): # "Staging", "Production", "Archived"
185
- client = MlflowClient()
186
- client.transition_model_version_stage(
187
- name=model_name,
188
- version=version,
189
- stage=stage,
190
- archive_existing_versions=(stage == "Production")
191
- )
192
-
193
- def get_production_model(model_name: str):
194
- client = MlflowClient()
195
- versions = client.get_latest_versions(model_name, stages=["Production"])
196
- if not versions:
197
- raise ValueError(f"No production version for {model_name}")
198
- return versions[0]
199
- ```
200
-
201
- ## Model Loading
202
-
203
- ```python
204
- def load_model(model_name: str, stage: str = "Production"):
205
- return mlflow.sklearn.load_model(f"models:/{model_name}/{stage}")
206
-
207
- def load_model_version(model_name: str, version: int):
208
- return mlflow.sklearn.load_model(f"models:/{model_name}/{version}")
209
-
210
- class CachedModelLoader:
211
- def __init__(self):
212
- self._cache = {}
213
- self._client = MlflowClient()
214
-
215
- def get_model(self, model_name: str, stage: str = "Production"):
216
- cache_key = f"{model_name}:{stage}"
217
- versions = self._client.get_latest_versions(model_name, stages=[stage])
218
- if not versions:
219
- raise ValueError(f"No {stage} version for {model_name}")
220
-
221
- current_version = versions[0].version
222
- if cache_key in self._cache:
223
- cached_version, model = self._cache[cache_key]
224
- if cached_version == current_version:
225
- return model
226
-
227
- model = load_model(model_name, stage)
228
- self._cache[cache_key] = (current_version, model)
229
- return model
230
- ```
231
-
232
- ## Model Comparison
233
-
234
- ```python
235
- import pandas as pd
236
-
237
- def compare_runs(experiment_name: str, metric: str = "f1_score", top_n: int = 10) -> pd.DataFrame:
238
- client = MlflowClient()
239
- experiment = client.get_experiment_by_name(experiment_name)
240
-
241
- runs = client.search_runs(
242
- experiment_ids=[experiment.experiment_id],
243
- order_by=[f"metrics.{metric} DESC"],
244
- max_results=top_n
245
- )
246
-
247
- data = []
248
- for run in runs:
249
- row = {
250
- "run_id": run.info.run_id,
251
- "run_name": run.info.run_name,
252
- "duration_min": (run.info.end_time - run.info.start_time) / 60000 if run.info.end_time else None,
253
- }
254
- row.update(run.data.params)
255
- row.update(run.data.metrics)
256
- data.append(row)
257
-
258
- return pd.DataFrame(data)
259
-
260
- def get_best_run(experiment_name: str, metric: str = "f1_score", mode: str = "max") -> str:
261
- client = MlflowClient()
262
- experiment = client.get_experiment_by_name(experiment_name)
263
- order = "DESC" if mode == "max" else "ASC"
264
-
265
- runs = client.search_runs(
266
- experiment_ids=[experiment.experiment_id],
267
- order_by=[f"metrics.{metric} {order}"],
268
- max_results=1
269
- )
270
- return runs[0].info.run_id if runs else None
271
- ```
272
-
273
- ## Serving
274
-
275
- ```bash
276
- # REST API serving
277
- mlflow models serve -m "models:/anomaly_detector/Production" -p 5001
278
-
279
- # Docker deployment
280
- mlflow models build-docker -m "models:/anomaly_detector/Production" -n ml-model
281
- docker run -p 5001:8080 ml-model
282
-
283
- # Request prediction
284
- curl -X POST http://localhost:5001/invocations \
285
- -H "Content-Type: application/json" \
286
- -d '{"inputs": [[1.0, 2.0, 3.0, 4.0, 5.0]]}'
287
- ```
288
-
289
- ## Best Practices
290
-
291
- 1. **Always use experiments** - `mlflow.set_experiment("project-name")`
292
- 2. **Log everything** - params, metrics, artifacts, model signature
293
- 3. **Use signatures** - `infer_signature(X_train, y_pred)` for input validation
294
- 4. **Tag runs** - model_type, dataset_version, author for filtering
295
- 5. **Version artifacts** - `mlflow.log_artifact("config.yaml", artifact_path="config")`
296
-
297
- ## Related Skills
298
-
299
- - `pytorch`: Deep learning experiments
300
- - `scikit-learn`: Classical ML experiments
301
- - `kubernetes`: Model deployment at scale
302
- - `docker-containers`: Containerized tracking
@@ -1,290 +0,0 @@
1
- ---
2
- name: onnx-inference
3
- description: >
4
- Deploy ML models with ONNX Runtime for cross-platform inference (Python, Rust, Go).
5
- Trigger: onnx, model deployment, inference, edge ml, quantization
6
- tools:
7
- - Read
8
- - Write
9
- - Bash
10
- - Grep
11
- metadata:
12
- author: plataforma-industrial
13
- version: "2.0"
14
- tags: [onnx, ml, inference, edge, deployment]
15
- updated: "2026-02"
16
- ---
17
-
18
- # ONNX Inference Skill
19
-
20
- Deploy ML models with ONNX Runtime for cross-platform, high-performance inference.
21
-
22
- ## Stack
23
-
24
- ```yaml
25
- # Python
26
- onnx: 1.15+
27
- onnxruntime: 1.17+
28
- torch: 2.2+
29
-
30
- # Rust
31
- ort: 2.0+
32
-
33
- # Go
34
- onnxruntime_go: 1.17+
35
- ```
36
-
37
- ## Model Export
38
-
39
- ### PyTorch to ONNX
40
-
41
- ```python
42
- import torch
43
- import torch.onnx
44
-
45
- def export_model(model: torch.nn.Module, output_path: str, input_shape: tuple):
46
- model.eval()
47
- dummy_input = torch.randn(*input_shape)
48
-
49
- torch.onnx.export(
50
- model,
51
- dummy_input,
52
- output_path,
53
- export_params=True,
54
- opset_version=17,
55
- do_constant_folding=True,
56
- input_names=['input'],
57
- output_names=['output'],
58
- dynamic_axes={
59
- 'input': {0: 'batch_size'},
60
- 'output': {0: 'batch_size'}
61
- }
62
- )
63
-
64
- # Validate
65
- def validate_model(model_path: str):
66
- import onnx
67
- model = onnx.load(model_path)
68
- onnx.checker.check_model(model)
69
- print(f"Inputs: {[i.name for i in model.graph.input]}")
70
- print(f"Outputs: {[o.name for o in model.graph.output]}")
71
- ```
72
-
73
- ### Scikit-learn to ONNX
74
-
75
- ```python
76
- from skl2onnx import convert_sklearn
77
- from skl2onnx.common.data_types import FloatTensorType
78
-
79
- def export_sklearn(model, output_path: str, input_features: int):
80
- initial_type = [('input', FloatTensorType([None, input_features]))]
81
- onnx_model = convert_sklearn(
82
- model,
83
- initial_types=initial_type,
84
- target_opset=17,
85
- options={id(model): {'zipmap': False}}
86
- )
87
- with open(output_path, 'wb') as f:
88
- f.write(onnx_model.SerializeToString())
89
- ```
90
-
91
- ## Python Inference
92
-
93
- ```python
94
- import onnxruntime as ort
95
- import numpy as np
96
-
97
- class ONNXPredictor:
98
- def __init__(self, model_path: str, providers: list = None):
99
- if providers is None:
100
- providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
101
-
102
- sess_options = ort.SessionOptions()
103
- sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
104
- sess_options.intra_op_num_threads = 4
105
-
106
- self.session = ort.InferenceSession(model_path, sess_options, providers=providers)
107
- self.input_name = self.session.get_inputs()[0].name
108
- self.output_names = [o.name for o in self.session.get_outputs()]
109
-
110
- def predict(self, data: np.ndarray) -> np.ndarray:
111
- if data.dtype != np.float32:
112
- data = data.astype(np.float32)
113
- outputs = self.session.run(self.output_names, {self.input_name: data})
114
- return outputs[0]
115
-
116
- def predict_batch(self, data: np.ndarray, batch_size: int = 32) -> np.ndarray:
117
- results = []
118
- for i in range(0, len(data), batch_size):
119
- batch = data[i:i + batch_size]
120
- results.append(self.predict(batch))
121
- return np.concatenate(results, axis=0)
122
- ```
123
-
124
- ## Rust Inference
125
-
126
- ```rust
127
- // Cargo.toml: ort = { version = "2.0", features = ["load-dynamic"] }
128
- use ort::{Environment, Session, SessionBuilder, Value};
129
- use ndarray::{Array3, ArrayD, IxDyn};
130
- use std::sync::Arc;
131
-
132
- pub struct Predictor {
133
- session: Session,
134
- }
135
-
136
- impl Predictor {
137
- pub fn new(model_path: &str) -> Result<Self, ort::Error> {
138
- let environment = Arc::new(
139
- Environment::builder()
140
- .with_name("inference")
141
- .with_execution_providers([ort::ExecutionProvider::CPU(Default::default())])
142
- .build()?
143
- );
144
-
145
- let session = SessionBuilder::new(&environment)?
146
- .with_optimization_level(ort::GraphOptimizationLevel::Level3)?
147
- .with_intra_threads(4)?
148
- .with_model_from_file(model_path)?;
149
-
150
- Ok(Self { session })
151
- }
152
-
153
- pub fn predict(&self, input: Array3<f32>) -> Result<Vec<f32>, ort::Error> {
154
- let shape = input.shape().to_vec();
155
- let data: Vec<f32> = input.into_iter().collect();
156
- let tensor = Value::from_array(
157
- self.session.allocator(),
158
- &ArrayD::from_shape_vec(IxDyn(&shape), data)?
159
- )?;
160
-
161
- let outputs = self.session.run(vec![tensor])?;
162
- let result: ArrayD<f32> = outputs[0].try_extract()?.view().to_owned();
163
- Ok(result.into_iter().collect())
164
- }
165
- }
166
- ```
167
-
168
- ## Go Inference
169
-
170
- ```go
171
- package ml
172
-
173
- import "github.com/yalue/onnxruntime_go"
174
-
175
- type Predictor struct {
176
- session *onnxruntime_go.AdvancedSession
177
- }
178
-
179
- func NewPredictor(modelPath string) (*Predictor, error) {
180
- onnxruntime_go.InitializeEnvironment()
181
- session, err := onnxruntime_go.NewAdvancedSession(
182
- modelPath,
183
- []string{"input"},
184
- []string{"output"},
185
- nil,
186
- )
187
- if err != nil {
188
- return nil, err
189
- }
190
- return &Predictor{session: session}, nil
191
- }
192
-
193
- func (p *Predictor) Predict(input []float32, shape []int64) ([]float32, error) {
194
- inputTensor, _ := onnxruntime_go.NewTensor(onnxruntime_go.NewShape(shape...), input)
195
- defer inputTensor.Destroy()
196
-
197
- outputSize := int64(1)
198
- for _, d := range shape[1:] { outputSize *= d }
199
- outputData := make([]float32, outputSize)
200
- outputTensor, _ := onnxruntime_go.NewTensor(onnxruntime_go.NewShape(shape[0], outputSize), outputData)
201
- defer outputTensor.Destroy()
202
-
203
- p.session.Run()
204
- return outputTensor.GetData(), nil
205
- }
206
-
207
- func (p *Predictor) Close() {
208
- p.session.Destroy()
209
- onnxruntime_go.DestroyEnvironment()
210
- }
211
- ```
212
-
213
- ## Model Optimization
214
-
215
- ### Quantization
216
-
217
- ```python
218
- from onnxruntime.quantization import quantize_dynamic, QuantType
219
-
220
- def quantize_model(input_path: str, output_path: str):
221
- quantize_dynamic(input_path, output_path, weight_type=QuantType.QInt8)
222
-
223
- def optimize_model(input_path: str, output_path: str):
224
- import onnxoptimizer
225
- import onnx
226
-
227
- model = onnx.load(input_path)
228
- passes = [
229
- 'eliminate_identity',
230
- 'eliminate_deadend',
231
- 'fuse_bn_into_conv',
232
- 'fuse_matmul_add_bias_into_gemm',
233
- ]
234
- optimized = onnxoptimizer.optimize(model, passes)
235
- onnx.save(optimized, output_path)
236
-
237
- # Full pipeline
238
- def prepare_for_edge(model_path: str):
239
- base = model_path.replace('.onnx', '')
240
- optimize_model(model_path, f"{base}_optimized.onnx")
241
- quantize_model(f"{base}_optimized.onnx", f"{base}_quantized.onnx")
242
- ```
243
-
244
- ## Model Registry
245
-
246
- ```python
247
- import hashlib
248
- import json
249
- from pathlib import Path
250
- from datetime import datetime
251
-
252
- class ModelRegistry:
253
- def __init__(self, registry_path: str = "models/registry.json"):
254
- self.path = Path(registry_path)
255
- self.registry = json.loads(self.path.read_text()) if self.path.exists() else {"models": {}}
256
-
257
- def register(self, name: str, model_path: str, version: str, metrics: dict = None):
258
- model_hash = hashlib.sha256(Path(model_path).read_bytes()).hexdigest()[:16]
259
- if name not in self.registry["models"]:
260
- self.registry["models"][name] = {"versions": {}}
261
-
262
- self.registry["models"][name]["versions"][version] = {
263
- "path": model_path,
264
- "hash": model_hash,
265
- "registered_at": datetime.utcnow().isoformat(),
266
- "metrics": metrics or {}
267
- }
268
- self.registry["models"][name]["latest"] = version
269
- self.path.write_text(json.dumps(self.registry, indent=2))
270
-
271
- def get_path(self, name: str, version: str = "latest") -> str:
272
- if version == "latest":
273
- version = self.registry["models"][name]["latest"]
274
- return self.registry["models"][name]["versions"][version]["path"]
275
- ```
276
-
277
- ## Best Practices
278
-
279
- 1. **Dynamic axes** - Enable batch dimension flexibility
280
- 2. **Quantize for edge** - INT8 reduces size ~4x with minimal accuracy loss
281
- 3. **Validate exports** - Always run `onnx.checker.check_model()`
282
- 4. **Use execution providers** - CUDA > TensorRT > CPU fallback
283
- 5. **Version models** - Track hash, metrics, and metadata
284
-
285
- ## Related Skills
286
-
287
- - `pytorch`: Model training source
288
- - `scikit-learn`: Classical ML models
289
- - `ai-ml`: Full pipeline patterns
290
- - `fastapi`: Model serving API