Ports all remaining LEM pipeline commands from pkg/lem into core ml, eliminating the standalone LEM CLI dependency. Each command is split into reusable business logic (pkg/ml/) and a thin cobra wrapper (internal/cmd/ml/). New commands: query, inventory, metrics, ingest, normalize, seed-influx, consolidate, import-all, approve, publish, coverage. Adds Path(), Exec(), QueryRowScan() convenience methods to DB type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package ml
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"forge.lthn.ai/core/cli/pkg/cli"
|
|
"forge.lthn.ai/core/cli/pkg/ml"
|
|
)
|
|
|
|
var ingestCmd = &cli.Command{
|
|
Use: "ingest",
|
|
Short: "Ingest benchmark scores and training logs into InfluxDB",
|
|
Long: "Reads content score, capability score, and training log files and writes measurements to InfluxDB for the lab dashboard.",
|
|
RunE: runIngest,
|
|
}
|
|
|
|
var (
|
|
ingestContent string
|
|
ingestCapability string
|
|
ingestTraining string
|
|
ingestRunID string
|
|
ingestBatchSize int
|
|
)
|
|
|
|
func init() {
|
|
ingestCmd.Flags().StringVar(&ingestContent, "content", "", "Content scores JSONL file")
|
|
ingestCmd.Flags().StringVar(&ingestCapability, "capability", "", "Capability scores JSONL file")
|
|
ingestCmd.Flags().StringVar(&ingestTraining, "training-log", "", "MLX LoRA training log file")
|
|
ingestCmd.Flags().StringVar(&ingestRunID, "run-id", "", "Run ID tag (defaults to model name)")
|
|
ingestCmd.Flags().IntVar(&ingestBatchSize, "batch-size", 100, "Lines per InfluxDB write batch")
|
|
}
|
|
|
|
func runIngest(cmd *cli.Command, args []string) error {
|
|
if modelName == "" {
|
|
return fmt.Errorf("--model is required")
|
|
}
|
|
if ingestContent == "" && ingestCapability == "" && ingestTraining == "" {
|
|
return fmt.Errorf("at least one of --content, --capability, or --training-log is required")
|
|
}
|
|
|
|
influx := ml.NewInfluxClient(influxURL, influxDB)
|
|
|
|
cfg := ml.IngestConfig{
|
|
ContentFile: ingestContent,
|
|
CapabilityFile: ingestCapability,
|
|
TrainingLog: ingestTraining,
|
|
Model: modelName,
|
|
RunID: ingestRunID,
|
|
BatchSize: ingestBatchSize,
|
|
}
|
|
|
|
return ml.Ingest(influx, cfg, os.Stdout)
|
|
}
|