chore: auto-commit (15 archivos)
- apps/dag_engine/.gitignore - apps/dag_engine/README.md - apps/dag_engine/app.md - apps/dag_engine/config.go - apps/dag_engine/dags_migrated/fn_backup.yaml - apps/dag_engine/dags_migrated/revision_viernes_finanzas.yaml - apps/dag_engine/executor.go - apps/dag_engine/frontend/package.json - apps/dag_engine/frontend/src/App.tsx - apps/dag_engine/frontend/src/components/StatusBadge.tsx - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+19
-19
@@ -72,15 +72,15 @@ func (e *Executor) ExecuteDAG(ctx context.Context, dagPath string, trigger strin
|
||||
return runID, err
|
||||
}
|
||||
|
||||
// Setup DAGU_ENV temp file for inter-step communication.
|
||||
daguEnvFile, err := os.CreateTemp("", "dagu_env_*")
|
||||
// Setup FN_DAG_ENV temp file for inter-step communication.
|
||||
dagEnvFile, err := os.CreateTemp("", "fn_dag_env_*")
|
||||
if err != nil {
|
||||
e.failRun(runID, err)
|
||||
return runID, err
|
||||
}
|
||||
daguEnvPath := daguEnvFile.Name()
|
||||
daguEnvFile.Close()
|
||||
defer os.Remove(daguEnvPath)
|
||||
dagEnvPath := dagEnvFile.Name()
|
||||
dagEnvFile.Close()
|
||||
defer os.Remove(dagEnvPath)
|
||||
|
||||
// Track step outputs for ${step_id.stdout} references.
|
||||
stepOutputs := make(map[string]string)
|
||||
@@ -116,7 +116,7 @@ func (e *Executor) ExecuteDAG(ctx context.Context, dagPath string, trigger strin
|
||||
}
|
||||
mu.Unlock()
|
||||
|
||||
err := e.executeStep(ctx, runID, dag, step, daguEnvPath, stepOutputs, &mu)
|
||||
err := e.executeStep(ctx, runID, dag, step, dagEnvPath, stepOutputs, &mu)
|
||||
if err != nil && !step.ContinueOn.Failure {
|
||||
mu.Lock()
|
||||
levelFailed = true
|
||||
@@ -131,11 +131,11 @@ func (e *Executor) ExecuteDAG(ctx context.Context, dagPath string, trigger strin
|
||||
|
||||
// Run handlers.
|
||||
if runFailed {
|
||||
e.runHandlers(ctx, runID, dag, dag.HandlerOn.Failure, daguEnvPath, stepOutputs)
|
||||
e.runHandlers(ctx, runID, dag, dag.HandlerOn.Failure, dagEnvPath, stepOutputs)
|
||||
} else {
|
||||
e.runHandlers(ctx, runID, dag, dag.HandlerOn.Success, daguEnvPath, stepOutputs)
|
||||
e.runHandlers(ctx, runID, dag, dag.HandlerOn.Success, dagEnvPath, stepOutputs)
|
||||
}
|
||||
e.runHandlers(ctx, runID, dag, dag.HandlerOn.Exit, daguEnvPath, stepOutputs)
|
||||
e.runHandlers(ctx, runID, dag, dag.HandlerOn.Exit, dagEnvPath, stepOutputs)
|
||||
|
||||
// Finalize run.
|
||||
fin := time.Now()
|
||||
@@ -153,7 +153,7 @@ func (e *Executor) ExecuteDAG(ctx context.Context, dagPath string, trigger strin
|
||||
}
|
||||
|
||||
// executeStep runs a single step, recording results in the store.
|
||||
func (e *Executor) executeStep(ctx context.Context, runID string, dag core.DagDefinition, step core.DagStep, daguEnvPath string, outputs map[string]string, mu *sync.Mutex) error {
|
||||
func (e *Executor) executeStep(ctx context.Context, runID string, dag core.DagDefinition, step core.DagStep, dagEnvPath string, outputs map[string]string, mu *sync.Mutex) error {
|
||||
stepID := generateID()
|
||||
now := time.Now()
|
||||
|
||||
@@ -190,7 +190,7 @@ func (e *Executor) executeStep(ctx context.Context, runID string, dag core.DagDe
|
||||
})
|
||||
|
||||
// Build environment.
|
||||
env := buildStepEnv(dag, step, daguEnvPath, outputs)
|
||||
env := buildStepEnv(dag, step, dagEnvPath, outputs)
|
||||
|
||||
// For function: steps, force FN_REGISTRY_ROOT into env so `fn run`
|
||||
// resolves the canonical registry.db (not whatever lives at the spawn cwd).
|
||||
@@ -263,8 +263,8 @@ func (e *Executor) executeStep(ctx context.Context, runID string, dag core.DagDe
|
||||
mu.Unlock()
|
||||
}
|
||||
|
||||
// Read DAGU_ENV for inter-step env propagation.
|
||||
readDaguEnv(daguEnvPath, outputs)
|
||||
// Read FN_DAG_ENV for inter-step env propagation.
|
||||
readDagEnv(dagEnvPath, outputs)
|
||||
|
||||
if status == "failed" {
|
||||
return fmt.Errorf("exit code %d", result.ExitCode)
|
||||
@@ -272,10 +272,10 @@ func (e *Executor) executeStep(ctx context.Context, runID string, dag core.DagDe
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Executor) runHandlers(ctx context.Context, runID string, dag core.DagDefinition, handlers []core.DagStep, daguEnvPath string, outputs map[string]string) {
|
||||
func (e *Executor) runHandlers(ctx context.Context, runID string, dag core.DagDefinition, handlers []core.DagStep, dagEnvPath string, outputs map[string]string) {
|
||||
var mu sync.Mutex
|
||||
for _, step := range handlers {
|
||||
e.executeStep(ctx, runID, dag, step, daguEnvPath, outputs, &mu)
|
||||
e.executeStep(ctx, runID, dag, step, dagEnvPath, outputs, &mu)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ func stepName(s core.DagStep) string {
|
||||
return s.ID
|
||||
}
|
||||
|
||||
func buildStepEnv(dag core.DagDefinition, step core.DagStep, daguEnvPath string, outputs map[string]string) []string {
|
||||
func buildStepEnv(dag core.DagDefinition, step core.DagStep, dagEnvPath string, outputs map[string]string) []string {
|
||||
env := os.Environ()
|
||||
|
||||
// Add DAG-level env.
|
||||
@@ -317,8 +317,8 @@ func buildStepEnv(dag core.DagDefinition, step core.DagStep, daguEnvPath string,
|
||||
env = append(env, k+"="+v)
|
||||
}
|
||||
|
||||
// Add DAGU_ENV path.
|
||||
env = append(env, "DAGU_ENV="+daguEnvPath)
|
||||
// Add FN_DAG_ENV path.
|
||||
env = append(env, "FN_DAG_ENV="+dagEnvPath)
|
||||
|
||||
return env
|
||||
}
|
||||
@@ -331,7 +331,7 @@ func resolveStepRefs(command string, outputs map[string]string) string {
|
||||
return command
|
||||
}
|
||||
|
||||
func readDaguEnv(path string, outputs map[string]string) {
|
||||
func readDagEnv(path string, outputs map[string]string) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil || len(data) == 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user