From 010729ab59824dcfabde688126fbd544218842d1 Mon Sep 17 00:00:00 2001 From: Piotr Konopka Date: Thu, 20 Nov 2025 16:57:23 +0100 Subject: [PATCH] Standardize properties sent to AliECS- and ODC-controlled tasks We define a common list of parameter keys sent to AliECS- and ODC-controlled tasks and facilitate adding new ones. At the same time, we extend the lists to include some more fill information. --- core/environment/transition_startactivity.go | 31 ++++++++------- core/environment/transition_stopactivity.go | 22 ++++++++--- core/integration/odc/plugin.go | 40 +++++++------------- docs/handbook/configuration.md | 18 ++++----- 4 files changed, 57 insertions(+), 54 deletions(-) diff --git a/core/environment/transition_startactivity.go b/core/environment/transition_startactivity.go index 8361bed2..be7ec03c 100644 --- a/core/environment/transition_startactivity.go +++ b/core/environment/transition_startactivity.go @@ -38,6 +38,22 @@ import ( "github.com/iancoleman/strcase" ) +var StartActivityParameterKeys = []string{ + "fill_info_fill_number", + "fill_info_filling_scheme", + "fill_info_beam_type", + "fill_info_stable_beams_start_ms", + "fill_info_stable_beams_end_ms", + "run_number", + "run_type", + "run_start_time_ms", + "run_end_time_ms", // included to ensure that a cleared SOEOR timestamp is propagated to all tasks during START-STOP-START + "lhc_period", + "pdp_beam_type", + "pdp_override_run_start_time", + "original_run_number", +} + func NewStartActivityTransition(taskman *task.Manager) Transition { return &StartActivityTransition{ baseTransition: baseTransition{ @@ -81,20 +97,7 @@ func (t StartActivityTransition) do(env *Environment) (err error) { // Get a handle to the consolidated var stack of the root role of the env's workflow if wf := env.Workflow(); wf != nil { if cvs, cvsErr := wf.ConsolidatedVarStack(); cvsErr == nil { - for _, key := range []string{ - "fill_info_fill_number", - "fill_info_filling_scheme", - "fill_info_beam_type", - "fill_info_stable_beams_start_ms", - "fill_info_stable_beams_end_ms", - "run_type", - "run_start_time_ms", - "run_end_time_ms", // included to ensure that a cleared SOEOR timestamp is propagated to all tasks during START-STOP-START - "lhc_period", - "pdp_beam_type", - "pdp_override_run_start_time", - "original_run_number", - } { + for _, key := range StartActivityParameterKeys { if value, ok := cvs[key]; ok { // we push the above parameters with both camelCase and snake_case identifiers for convenience args[strcase.ToLowerCamel(key)] = value diff --git a/core/environment/transition_stopactivity.go b/core/environment/transition_stopactivity.go index 1533c68f..8653302e 100644 --- a/core/environment/transition_stopactivity.go +++ b/core/environment/transition_stopactivity.go @@ -36,6 +36,15 @@ import ( "github.com/iancoleman/strcase" ) +var StopActivityParameterKeys = []string{ + "fill_info_fill_number", + "fill_info_filling_scheme", + "fill_info_beam_type", + "fill_info_stable_beams_start_ms", + "fill_info_stable_beams_end_ms", + "run_end_time_ms", +} + func NewStopActivityTransition(taskman *task.Manager) Transition { return &StopActivityTransition{ baseTransition: baseTransition{ @@ -64,11 +73,14 @@ func (t StopActivityTransition) do(env *Environment) (err error) { // Get a handle to the consolidated var stack of the root role of the env's workflow if wf := env.Workflow(); wf != nil { if cvs, cvsErr := wf.ConsolidatedVarStack(); cvsErr == nil { - - // Propagate run end time to all tasks - if value, ok := cvs["run_end_time_ms"]; ok { - args[strcase.ToLowerCamel("run_end_time_ms")] = value - args["run_end_time_ms"] = value + // in principle, only stable beams end should change among fill info vars in a typical scenario, + // but just in case of more creative uses, we push all of them again. + for _, key := range StopActivityParameterKeys { + if value, ok := cvs[key]; ok { + // we push the above parameters with both camelCase and snake_case identifiers for convenience + args[strcase.ToLowerCamel(key)] = value + args[key] = value + } } } } diff --git a/core/integration/odc/plugin.go b/core/integration/odc/plugin.go index 9311aa17..1a9a9d26 100644 --- a/core/integration/odc/plugin.go +++ b/core/integration/odc/plugin.go @@ -1439,19 +1439,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) { WithField("call", "Start"). Warn("cannot acquire run number for ODC") } - originalRunNumber, _ := varStack["original_run_number"] cleanupCountS, ok := varStack["__fmq_cleanup_count"] if !ok { log.WithField("partition", envId). WithField("call", "Start"). Warn("cannot acquire FairMQ devices cleanup count for ODC") } - runStartTimeMs, ok := varStack["run_start_time_ms"] - if !ok { - log.WithField("partition", envId). - WithField("call", "Start"). - Warn("cannot acquire run_start_time_ms") - } var ( runNumberu64 uint64 @@ -1478,12 +1471,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) { timeout := callable.AcquireTimeout(ODC_START_TIMEOUT, varStack, "Start", envId) arguments := make(map[string]string) - arguments["run_number"] = rn arguments["runNumber"] = rn - arguments["run_start_time_ms"] = runStartTimeMs arguments["cleanup"] = strconv.Itoa(cleanupCount) - if len(originalRunNumber) > 0 { - arguments["original_run_number"] = originalRunNumber + for _, key := range environment.StartActivityParameterKeys { + if value, ok := varStack[key]; ok { + arguments[key] = value + } } ctx, cancel := integration.NewContext(envId, varStack, timeout) @@ -1522,15 +1515,13 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) { Error("cannot acquire run number for ODC EOR") runNumberu64 = 0 } - runEndTimeMs, ok := varStack["run_end_time_ms"] - if !ok { - log.WithField("partition", envId). - WithField("call", "Stop"). - Warn("cannot acquire run_end_time_ms") - } arguments := make(map[string]string) - arguments["run_end_time_ms"] = runEndTimeMs + for _, key := range environment.StopActivityParameterKeys { + if value, ok := varStack[key]; ok { + arguments[key] = value + } + } timeout := callable.AcquireTimeout(ODC_STOP_TIMEOUT, varStack, "Stop", envId) @@ -1594,15 +1585,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) { Error("cannot acquire run number for ODC EOR") runNumberu64 = 0 } - runEndTimeMs, ok := varStack["run_end_time_ms"] - if !ok { - log.WithField("partition", envId). - WithField("call", "EnsureStop"). - Warn("cannot acquire run_end_time_ms") - } - arguments := make(map[string]string) - arguments["run_end_time_ms"] = runEndTimeMs + for _, key := range environment.StopActivityParameterKeys { + if value, ok := varStack[key]; ok { + arguments[key] = value + } + } err = handleStop(ctx, p.odcClient, arguments, paddingTimeout, envId, runNumberu64, call) if err != nil { diff --git a/docs/handbook/configuration.md b/docs/handbook/configuration.md index 9cf18ee5..6acb3370 100644 --- a/docs/handbook/configuration.md +++ b/docs/handbook/configuration.md @@ -424,7 +424,7 @@ Depending on the specification in the task template (`command.env`, `command.arg In addition to the above, which varies depending on the configuration of the environment itself as well as on the configuration of the system as a whole, some special values are pushed by AliECS itself during `START_ACTIVITY`: - * `runNumber` + * `run_number` * `fill_info_fill_number` * `fill_info_filling_scheme` * `fill_info_beam_type` @@ -432,22 +432,22 @@ In addition to the above, which varies depending on the configuration of the env * `fill_info_stable_beams_end_ms` * `run_type` * `run_start_time_ms` + * `run_end_time_ms` (as an empty value) * `lhc_period` - * `fillInfoFillNumber` - * `fillInfoFillingScheme` - * `fillInfoBeamType` - * `fillInfoStableBeamsStartMs` - * `fillInfoStableBeamsEndMs` - * `runType` - * `runStartTimeMs` - * `lhcPeriod` * `pdp_beam_type` * `pdp_override_run_start_time` * `original_run_number` +For AliECS-controlled tasks, the same values are additionally pushed with keys in camelCase format. + The following values are pushed by AliECS during `STOP_ACTIVITY`: * `run_end_time_ms` + * `fill_info_fill_number` + * `fill_info_filling_scheme` + * `fill_info_beam_type` + * `fill_info_stable_beam_start_ms` + * `fill_info_stable_beam_end_ms` FairMQ task implementors should expect that these values are written to the FairMQ properties map right before the `RUN` and `STOP` transitions via `SetProperty` calls.