javi-forge 1.2.0 → 1.4.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.
- package/ci-local/ci-local.sh +29 -9
- package/ci-local/hooks/commit-msg +0 -0
- package/ci-local/hooks/pre-commit +1 -1
- package/ci-local/hooks/pre-push +0 -0
- package/ci-local/install.sh +0 -0
- package/ci-local/lib/common.sh +183 -0
- package/dist/__integration__/helpers.d.ts +20 -0
- package/dist/__integration__/helpers.d.ts.map +1 -0
- package/dist/__integration__/helpers.js +31 -0
- package/dist/__integration__/helpers.js.map +1 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/ci.d.ts.map +1 -0
- package/dist/commands/ci.js +13 -8
- package/dist/commands/ci.js.map +1 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +1 -3
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +14 -6
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/llmstxt.d.ts.map +1 -0
- package/dist/commands/llmstxt.js.map +1 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/constants.d.ts +0 -4
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +0 -4
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -0
- package/dist/lib/common.d.ts.map +1 -0
- package/dist/lib/common.js.map +1 -0
- package/dist/lib/docker.d.ts +2 -0
- package/dist/lib/docker.d.ts.map +1 -0
- package/dist/lib/docker.js +2 -1
- package/dist/lib/docker.js.map +1 -0
- package/dist/lib/frontmatter.d.ts.map +1 -0
- package/dist/lib/frontmatter.js.map +1 -0
- package/dist/lib/plugin.d.ts.map +1 -0
- package/dist/lib/plugin.js.map +1 -0
- package/dist/lib/template.d.ts.map +1 -0
- package/dist/lib/template.js.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/AnalyzeUI.d.ts.map +1 -0
- package/dist/ui/AnalyzeUI.js.map +1 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/CI.d.ts.map +1 -0
- package/dist/ui/CI.js.map +1 -0
- package/dist/ui/CIContext.d.ts.map +1 -0
- package/dist/ui/CIContext.js.map +1 -0
- package/dist/ui/CISelector.d.ts.map +1 -0
- package/dist/ui/CISelector.js.map +1 -0
- package/dist/ui/Doctor.d.ts.map +1 -0
- package/dist/ui/Doctor.js +1 -1
- package/dist/ui/Doctor.js.map +1 -0
- package/dist/ui/Header.d.ts.map +1 -0
- package/dist/ui/Header.js.map +1 -0
- package/dist/ui/LlmsTxt.d.ts.map +1 -0
- package/dist/ui/LlmsTxt.js.map +1 -0
- package/dist/ui/MemorySelector.d.ts.map +1 -0
- package/dist/ui/MemorySelector.js.map +1 -0
- package/dist/ui/NameInput.d.ts.map +1 -0
- package/dist/ui/NameInput.js.map +1 -0
- package/dist/ui/OptionSelector.d.ts.map +1 -0
- package/dist/ui/OptionSelector.js +1 -1
- package/dist/ui/OptionSelector.js.map +1 -0
- package/dist/ui/Plugin.d.ts.map +1 -0
- package/dist/ui/Plugin.js.map +1 -0
- package/dist/ui/Progress.d.ts.map +1 -0
- package/dist/ui/Progress.js.map +1 -0
- package/dist/ui/StackSelector.d.ts.map +1 -0
- package/dist/ui/StackSelector.js.map +1 -0
- package/dist/ui/Summary.d.ts.map +1 -0
- package/dist/ui/Summary.js.map +1 -0
- package/dist/ui/Welcome.d.ts.map +1 -0
- package/dist/ui/Welcome.js.map +1 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js.map +1 -0
- package/lib/common.sh +2 -2
- package/modules/ghagga/README.md +2 -2
- package/modules/ghagga/setup-ghagga.sh +1 -1
- package/package.json +25 -12
- package/templates/github/ci-go.yml +1 -1
- package/templates/github/ci-java.yml +2 -2
- package/templates/github/ci-node.yml +1 -1
- package/templates/github/ci-python.yml +1 -1
- package/templates/github/ci-rust.yml +1 -1
- package/templates/github/ghagga-review.yml +28 -0
- package/workflows/reusable-build-go.yml +1 -1
- package/workflows/reusable-build-java.yml +1 -1
- package/workflows/reusable-build-node.yml +1 -1
- package/workflows/reusable-build-python.yml +1 -1
- package/workflows/reusable-build-rust.yml +1 -1
- package/workflows/reusable-docker.yml +1 -1
- package/workflows/reusable-ghagga-review.yml +1 -1
- package/workflows/reusable-release.yml +1 -1
- package/.releaserc +0 -45
- package/ai-config/.skillignore +0 -15
- package/ai-config/AUTO_INVOKE.md +0 -300
- package/ai-config/agents/_TEMPLATE.md +0 -93
- package/ai-config/agents/business/api-designer.md +0 -1657
- package/ai-config/agents/business/business-analyst.md +0 -1331
- package/ai-config/agents/business/product-strategist.md +0 -206
- package/ai-config/agents/business/project-manager.md +0 -178
- package/ai-config/agents/business/requirements-analyst.md +0 -1277
- package/ai-config/agents/business/technical-writer.md +0 -1679
- package/ai-config/agents/creative/ux-designer.md +0 -205
- package/ai-config/agents/data-ai/ai-engineer.md +0 -487
- package/ai-config/agents/data-ai/analytics-engineer.md +0 -953
- package/ai-config/agents/data-ai/data-engineer.md +0 -173
- package/ai-config/agents/data-ai/data-scientist.md +0 -672
- package/ai-config/agents/data-ai/mlops-engineer.md +0 -814
- package/ai-config/agents/data-ai/prompt-engineer.md +0 -772
- package/ai-config/agents/development/angular-expert.md +0 -620
- package/ai-config/agents/development/backend-architect.md +0 -795
- package/ai-config/agents/development/database-specialist.md +0 -212
- package/ai-config/agents/development/frontend-specialist.md +0 -686
- package/ai-config/agents/development/fullstack-engineer.md +0 -668
- package/ai-config/agents/development/golang-pro.md +0 -338
- package/ai-config/agents/development/java-enterprise.md +0 -400
- package/ai-config/agents/development/javascript-pro.md +0 -422
- package/ai-config/agents/development/nextjs-pro.md +0 -474
- package/ai-config/agents/development/python-pro.md +0 -570
- package/ai-config/agents/development/react-pro.md +0 -487
- package/ai-config/agents/development/rust-pro.md +0 -246
- package/ai-config/agents/development/spring-boot-4-expert.md +0 -326
- package/ai-config/agents/development/typescript-pro.md +0 -336
- package/ai-config/agents/development/vue-specialist.md +0 -605
- package/ai-config/agents/infrastructure/cloud-architect.md +0 -472
- package/ai-config/agents/infrastructure/deployment-manager.md +0 -358
- package/ai-config/agents/infrastructure/devops-engineer.md +0 -455
- package/ai-config/agents/infrastructure/incident-responder.md +0 -519
- package/ai-config/agents/infrastructure/kubernetes-expert.md +0 -705
- package/ai-config/agents/infrastructure/monitoring-specialist.md +0 -674
- package/ai-config/agents/infrastructure/performance-engineer.md +0 -658
- package/ai-config/agents/orchestrator.md +0 -241
- package/ai-config/agents/quality/accessibility-auditor.md +0 -1204
- package/ai-config/agents/quality/code-reviewer-compact.md +0 -123
- package/ai-config/agents/quality/code-reviewer.md +0 -363
- package/ai-config/agents/quality/dependency-manager.md +0 -743
- package/ai-config/agents/quality/e2e-test-specialist.md +0 -1005
- package/ai-config/agents/quality/performance-tester.md +0 -1086
- package/ai-config/agents/quality/security-auditor.md +0 -133
- package/ai-config/agents/quality/test-engineer.md +0 -453
- package/ai-config/agents/specialists/api-designer.md +0 -87
- package/ai-config/agents/specialists/backend-architect.md +0 -73
- package/ai-config/agents/specialists/code-reviewer.md +0 -77
- package/ai-config/agents/specialists/db-optimizer.md +0 -75
- package/ai-config/agents/specialists/devops-engineer.md +0 -83
- package/ai-config/agents/specialists/documentation-writer.md +0 -78
- package/ai-config/agents/specialists/frontend-developer.md +0 -75
- package/ai-config/agents/specialists/performance-analyst.md +0 -82
- package/ai-config/agents/specialists/refactor-specialist.md +0 -74
- package/ai-config/agents/specialists/security-auditor.md +0 -74
- package/ai-config/agents/specialists/test-engineer.md +0 -81
- package/ai-config/agents/specialists/ux-consultant.md +0 -76
- package/ai-config/agents/specialized/agent-generator.md +0 -1190
- package/ai-config/agents/specialized/blockchain-developer.md +0 -149
- package/ai-config/agents/specialized/code-migrator.md +0 -892
- package/ai-config/agents/specialized/context-manager.md +0 -978
- package/ai-config/agents/specialized/documentation-writer.md +0 -1078
- package/ai-config/agents/specialized/ecommerce-expert.md +0 -1756
- package/ai-config/agents/specialized/embedded-engineer.md +0 -1714
- package/ai-config/agents/specialized/error-detective.md +0 -1034
- package/ai-config/agents/specialized/fintech-specialist.md +0 -1659
- package/ai-config/agents/specialized/freelance-project-planner-v2.md +0 -1988
- package/ai-config/agents/specialized/freelance-project-planner-v3.md +0 -2136
- package/ai-config/agents/specialized/freelance-project-planner-v4.md +0 -4503
- package/ai-config/agents/specialized/freelance-project-planner.md +0 -722
- package/ai-config/agents/specialized/game-developer.md +0 -1963
- package/ai-config/agents/specialized/healthcare-dev.md +0 -1620
- package/ai-config/agents/specialized/mobile-developer.md +0 -188
- package/ai-config/agents/specialized/parallel-plan-executor.md +0 -506
- package/ai-config/agents/specialized/plan-executor.md +0 -485
- package/ai-config/agents/specialized/solo-dev-planner-modular/00-INDEX.md +0 -485
- package/ai-config/agents/specialized/solo-dev-planner-modular/01-CORE.md +0 -3493
- package/ai-config/agents/specialized/solo-dev-planner-modular/02-SELF-CORRECTION.md +0 -778
- package/ai-config/agents/specialized/solo-dev-planner-modular/03-PROGRESSIVE-SETUP.md +0 -918
- package/ai-config/agents/specialized/solo-dev-planner-modular/04-DEPLOYMENT.md +0 -1537
- package/ai-config/agents/specialized/solo-dev-planner-modular/05-TESTING.md +0 -2633
- package/ai-config/agents/specialized/solo-dev-planner-modular/06-OPERATIONS.md +0 -5610
- package/ai-config/agents/specialized/solo-dev-planner-modular/INSTALL.md +0 -335
- package/ai-config/agents/specialized/solo-dev-planner-modular/QUICK-REFERENCE.txt +0 -215
- package/ai-config/agents/specialized/solo-dev-planner-modular/README.md +0 -260
- package/ai-config/agents/specialized/solo-dev-planner-modular/START-HERE.md +0 -379
- package/ai-config/agents/specialized/solo-dev-planner-modular/WORKFLOW-DIAGRAM.md +0 -355
- package/ai-config/agents/specialized/solo-dev-planner-modular/solo-dev-planner.md +0 -279
- package/ai-config/agents/specialized/template-writer.md +0 -347
- package/ai-config/agents/specialized/test-runner.md +0 -99
- package/ai-config/agents/specialized/vibekanban-smart-worker.md +0 -244
- package/ai-config/agents/specialized/wave-executor.md +0 -138
- package/ai-config/agents/specialized/workflow-optimizer.md +0 -1114
- package/ai-config/commands/git/changelog.md +0 -32
- package/ai-config/commands/git/ci-local.md +0 -70
- package/ai-config/commands/git/commit.md +0 -35
- package/ai-config/commands/git/fix-issue.md +0 -23
- package/ai-config/commands/git/pr-create.md +0 -42
- package/ai-config/commands/git/pr-review.md +0 -50
- package/ai-config/commands/git/worktree.md +0 -39
- package/ai-config/commands/refactoring/cleanup.md +0 -24
- package/ai-config/commands/refactoring/dead-code.md +0 -40
- package/ai-config/commands/refactoring/extract.md +0 -31
- package/ai-config/commands/testing/e2e.md +0 -30
- package/ai-config/commands/testing/tdd.md +0 -36
- package/ai-config/commands/testing/test-coverage.md +0 -30
- package/ai-config/commands/testing/test-fix.md +0 -24
- package/ai-config/commands/workflow/generate-agents-md.md +0 -85
- package/ai-config/commands/workflow/planning.md +0 -47
- package/ai-config/commands/workflows/compound.md +0 -89
- package/ai-config/commands/workflows/diagnose.md +0 -70
- package/ai-config/commands/workflows/discover.md +0 -86
- package/ai-config/commands/workflows/plan.md +0 -77
- package/ai-config/commands/workflows/review.md +0 -78
- package/ai-config/commands/workflows/work.md +0 -75
- package/ai-config/config.yaml +0 -18
- package/ai-config/hooks/_TEMPLATE.md +0 -96
- package/ai-config/hooks/block-dangerous-commands.md +0 -75
- package/ai-config/hooks/commit-guard.md +0 -90
- package/ai-config/hooks/context-loader.md +0 -73
- package/ai-config/hooks/improve-prompt.md +0 -91
- package/ai-config/hooks/learning-log.md +0 -72
- package/ai-config/hooks/model-router.md +0 -86
- package/ai-config/hooks/secret-scanner.md +0 -64
- package/ai-config/hooks/skill-validator.md +0 -102
- package/ai-config/hooks/task-artifact.md +0 -114
- package/ai-config/hooks/validate-workflow.md +0 -100
- package/ai-config/prompts/base.md +0 -71
- package/ai-config/prompts/modes/debug.md +0 -34
- package/ai-config/prompts/modes/deploy.md +0 -40
- package/ai-config/prompts/modes/research.md +0 -32
- package/ai-config/prompts/modes/review.md +0 -33
- package/ai-config/prompts/review-policy.md +0 -79
- package/ai-config/skills/_TEMPLATE.md +0 -157
- package/ai-config/skills/backend/api-gateway/SKILL.md +0 -254
- package/ai-config/skills/backend/bff-concepts/SKILL.md +0 -239
- package/ai-config/skills/backend/bff-spring/SKILL.md +0 -364
- package/ai-config/skills/backend/chi-router/SKILL.md +0 -396
- package/ai-config/skills/backend/error-handling/SKILL.md +0 -255
- package/ai-config/skills/backend/exceptions-spring/SKILL.md +0 -323
- package/ai-config/skills/backend/fastapi/SKILL.md +0 -302
- package/ai-config/skills/backend/gateway-spring/SKILL.md +0 -390
- package/ai-config/skills/backend/go-backend/SKILL.md +0 -457
- package/ai-config/skills/backend/gradle-multimodule/SKILL.md +0 -274
- package/ai-config/skills/backend/graphql-concepts/SKILL.md +0 -352
- package/ai-config/skills/backend/graphql-spring/SKILL.md +0 -398
- package/ai-config/skills/backend/grpc-concepts/SKILL.md +0 -283
- package/ai-config/skills/backend/grpc-spring/SKILL.md +0 -445
- package/ai-config/skills/backend/jwt-auth/SKILL.md +0 -412
- package/ai-config/skills/backend/notifications-concepts/SKILL.md +0 -259
- package/ai-config/skills/backend/recommendations-concepts/SKILL.md +0 -261
- package/ai-config/skills/backend/search-concepts/SKILL.md +0 -263
- package/ai-config/skills/backend/search-spring/SKILL.md +0 -375
- package/ai-config/skills/backend/spring-boot-4/SKILL.md +0 -172
- package/ai-config/skills/backend/websockets/SKILL.md +0 -532
- package/ai-config/skills/data-ai/ai-ml/SKILL.md +0 -423
- package/ai-config/skills/data-ai/analytics-concepts/SKILL.md +0 -195
- package/ai-config/skills/data-ai/analytics-spring/SKILL.md +0 -340
- package/ai-config/skills/data-ai/duckdb-analytics/SKILL.md +0 -440
- package/ai-config/skills/data-ai/langchain/SKILL.md +0 -238
- package/ai-config/skills/data-ai/mlflow/SKILL.md +0 -302
- package/ai-config/skills/data-ai/onnx-inference/SKILL.md +0 -290
- package/ai-config/skills/data-ai/powerbi/SKILL.md +0 -352
- package/ai-config/skills/data-ai/pytorch/SKILL.md +0 -274
- package/ai-config/skills/data-ai/scikit-learn/SKILL.md +0 -321
- package/ai-config/skills/data-ai/vector-db/SKILL.md +0 -301
- package/ai-config/skills/database/graph-databases/SKILL.md +0 -218
- package/ai-config/skills/database/graph-spring/SKILL.md +0 -361
- package/ai-config/skills/database/pgx-postgres/SKILL.md +0 -512
- package/ai-config/skills/database/redis-cache/SKILL.md +0 -343
- package/ai-config/skills/database/sqlite-embedded/SKILL.md +0 -388
- package/ai-config/skills/database/timescaledb/SKILL.md +0 -320
- package/ai-config/skills/docs/api-documentation/SKILL.md +0 -293
- package/ai-config/skills/docs/docs-spring/SKILL.md +0 -377
- package/ai-config/skills/docs/mustache-templates/SKILL.md +0 -190
- package/ai-config/skills/docs/technical-docs/SKILL.md +0 -447
- package/ai-config/skills/frontend/astro-ssr/SKILL.md +0 -441
- package/ai-config/skills/frontend/frontend-design/SKILL.md +0 -54
- package/ai-config/skills/frontend/frontend-web/SKILL.md +0 -368
- package/ai-config/skills/frontend/mantine-ui/SKILL.md +0 -396
- package/ai-config/skills/frontend/tanstack-query/SKILL.md +0 -439
- package/ai-config/skills/frontend/zod-validation/SKILL.md +0 -417
- package/ai-config/skills/frontend/zustand-state/SKILL.md +0 -350
- package/ai-config/skills/infrastructure/chaos-engineering/SKILL.md +0 -244
- package/ai-config/skills/infrastructure/chaos-spring/SKILL.md +0 -378
- package/ai-config/skills/infrastructure/devops-infra/SKILL.md +0 -435
- package/ai-config/skills/infrastructure/docker-containers/SKILL.md +0 -420
- package/ai-config/skills/infrastructure/kubernetes/SKILL.md +0 -456
- package/ai-config/skills/infrastructure/opentelemetry/SKILL.md +0 -546
- package/ai-config/skills/infrastructure/traefik-proxy/SKILL.md +0 -474
- package/ai-config/skills/infrastructure/woodpecker-ci/SKILL.md +0 -315
- package/ai-config/skills/mobile/ionic-capacitor/SKILL.md +0 -504
- package/ai-config/skills/mobile/mobile-ionic/SKILL.md +0 -448
- package/ai-config/skills/prompt-improver/SKILL.md +0 -125
- package/ai-config/skills/quality/ghagga-review/SKILL.md +0 -216
- package/ai-config/skills/references/hooks-patterns/SKILL.md +0 -238
- package/ai-config/skills/references/mcp-servers/SKILL.md +0 -275
- package/ai-config/skills/references/plugins-reference/SKILL.md +0 -110
- package/ai-config/skills/references/skills-reference/SKILL.md +0 -420
- package/ai-config/skills/references/subagent-templates/SKILL.md +0 -193
- package/ai-config/skills/systems-iot/modbus-protocol/SKILL.md +0 -410
- package/ai-config/skills/systems-iot/mqtt-rumqttc/SKILL.md +0 -408
- package/ai-config/skills/systems-iot/rust-systems/SKILL.md +0 -386
- package/ai-config/skills/systems-iot/tokio-async/SKILL.md +0 -324
- package/ai-config/skills/testing/playwright-e2e/SKILL.md +0 -289
- package/ai-config/skills/testing/testcontainers/SKILL.md +0 -299
- package/ai-config/skills/testing/vitest-testing/SKILL.md +0 -381
- package/ai-config/skills/workflow/ci-local-guide/SKILL.md +0 -118
- package/ai-config/skills/workflow/claude-automation-recommender/SKILL.md +0 -299
- package/ai-config/skills/workflow/claude-md-improver/SKILL.md +0 -158
- package/ai-config/skills/workflow/finishing-a-development-branch/SKILL.md +0 -117
- package/ai-config/skills/workflow/git-github/SKILL.md +0 -334
- package/ai-config/skills/workflow/git-github/references/examples.md +0 -160
- package/ai-config/skills/workflow/git-workflow/SKILL.md +0 -214
- package/ai-config/skills/workflow/ide-plugins/SKILL.md +0 -277
- package/ai-config/skills/workflow/ide-plugins-intellij/SKILL.md +0 -401
- package/ai-config/skills/workflow/obsidian-brain-workflow/SKILL.md +0 -199
- package/ai-config/skills/workflow/using-git-worktrees/SKILL.md +0 -100
- package/ai-config/skills/workflow/verification-before-completion/SKILL.md +0 -73
- package/ai-config/skills/workflow/wave-workflow/SKILL.md +0 -178
- package/dist/commands/analyze.test.d.ts +0 -2
- package/dist/commands/doctor.test.d.ts +0 -2
- package/dist/commands/init.test.d.ts +0 -2
- package/dist/commands/llmstxt.test.d.ts +0 -2
- package/dist/commands/plugin.test.d.ts +0 -2
- package/dist/commands/sync.d.ts +0 -8
- package/dist/commands/sync.js +0 -201
- package/dist/e2e/aggressive.e2e.test.d.ts +0 -2
- package/dist/e2e/commands.e2e.test.d.ts +0 -2
- package/dist/lib/common.test.d.ts +0 -2
- package/dist/lib/frontmatter.test.d.ts +0 -2
- package/dist/lib/plugin.test.d.ts +0 -2
- package/dist/lib/template.test.d.ts +0 -2
- package/dist/ui/SyncUI.d.ts +0 -10
- package/dist/ui/SyncUI.js +0 -64
- package/schemas/agent.schema.json +0 -34
- package/schemas/ai-config.schema.json +0 -28
- package/schemas/plugin.schema.json +0 -62
- package/schemas/skill.schema.json +0 -44
- package/tasks/_TEMPLATE/files-edited.md +0 -3
- package/tasks/_TEMPLATE/plan.md +0 -3
- package/tasks/_TEMPLATE/research.md +0 -3
- package/tasks/_TEMPLATE/verification.md +0 -5
|
@@ -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
|