Skip to content

Commit cb6feb0

Browse files
committed
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.
1 parent 87f0609 commit cb6feb0

File tree

4 files changed

+57
-54
lines changed

4 files changed

+57
-54
lines changed

core/environment/transition_startactivity.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ import (
3838
"github.com/iancoleman/strcase"
3939
)
4040

41+
var StartActivityParameterKeys = []string{
42+
"fill_info_fill_number",
43+
"fill_info_filling_scheme",
44+
"fill_info_beam_type",
45+
"fill_info_stable_beams_start_ms",
46+
"fill_info_stable_beams_end_ms",
47+
"run_number",
48+
"run_type",
49+
"run_start_time_ms",
50+
"run_end_time_ms", // included to ensure that a cleared SOEOR timestamp is propagated to all tasks during START-STOP-START
51+
"lhc_period",
52+
"pdp_beam_type",
53+
"pdp_override_run_start_time",
54+
"original_run_number",
55+
}
56+
4157
func NewStartActivityTransition(taskman *task.Manager) Transition {
4258
return &StartActivityTransition{
4359
baseTransition: baseTransition{
@@ -81,20 +97,7 @@ func (t StartActivityTransition) do(env *Environment) (err error) {
8197
// Get a handle to the consolidated var stack of the root role of the env's workflow
8298
if wf := env.Workflow(); wf != nil {
8399
if cvs, cvsErr := wf.ConsolidatedVarStack(); cvsErr == nil {
84-
for _, key := range []string{
85-
"fill_info_fill_number",
86-
"fill_info_filling_scheme",
87-
"fill_info_beam_type",
88-
"fill_info_stable_beam_start_ms",
89-
"fill_info_stable_beam_end_ms",
90-
"run_type",
91-
"run_start_time_ms",
92-
"run_end_time_ms", // included to ensure that a cleared SOEOR timestamp is propagated to all tasks during START-STOP-START
93-
"lhc_period",
94-
"pdp_beam_type",
95-
"pdp_override_run_start_time",
96-
"original_run_number",
97-
} {
100+
for _, key := range StartActivityParameterKeys {
98101
if value, ok := cvs[key]; ok {
99102
// we push the above parameters with both camelCase and snake_case identifiers for convenience
100103
args[strcase.ToLowerCamel(key)] = value

core/environment/transition_stopactivity.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ import (
3636
"github.com/iancoleman/strcase"
3737
)
3838

39+
var StopActivityParameterKeys = []string{
40+
"fill_info_fill_number",
41+
"fill_info_filling_scheme",
42+
"fill_info_beam_type",
43+
"fill_info_stable_beams_start_ms",
44+
"fill_info_stable_beams_end_ms",
45+
"run_end_time_ms",
46+
}
47+
3948
func NewStopActivityTransition(taskman *task.Manager) Transition {
4049
return &StopActivityTransition{
4150
baseTransition: baseTransition{
@@ -64,11 +73,14 @@ func (t StopActivityTransition) do(env *Environment) (err error) {
6473
// Get a handle to the consolidated var stack of the root role of the env's workflow
6574
if wf := env.Workflow(); wf != nil {
6675
if cvs, cvsErr := wf.ConsolidatedVarStack(); cvsErr == nil {
67-
68-
// Propagate run end time to all tasks
69-
if value, ok := cvs["run_end_time_ms"]; ok {
70-
args[strcase.ToLowerCamel("run_end_time_ms")] = value
71-
args["run_end_time_ms"] = value
76+
// in principle, only stable beams end should change among fill info vars in a typical scenario,
77+
// but just in case of more creative uses, we push all of them again.
78+
for _, key := range StopActivityParameterKeys {
79+
if value, ok := cvs[key]; ok {
80+
// we push the above parameters with both camelCase and snake_case identifiers for convenience
81+
args[strcase.ToLowerCamel(key)] = value
82+
args[key] = value
83+
}
7284
}
7385
}
7486
}

core/integration/odc/plugin.go

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,19 +1439,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
14391439
WithField("call", "Start").
14401440
Warn("cannot acquire run number for ODC")
14411441
}
1442-
originalRunNumber, _ := varStack["original_run_number"]
14431442
cleanupCountS, ok := varStack["__fmq_cleanup_count"]
14441443
if !ok {
14451444
log.WithField("partition", envId).
14461445
WithField("call", "Start").
14471446
Warn("cannot acquire FairMQ devices cleanup count for ODC")
14481447
}
1449-
runStartTimeMs, ok := varStack["run_start_time_ms"]
1450-
if !ok {
1451-
log.WithField("partition", envId).
1452-
WithField("call", "Start").
1453-
Warn("cannot acquire run_start_time_ms")
1454-
}
14551448

14561449
var (
14571450
runNumberu64 uint64
@@ -1478,12 +1471,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
14781471
timeout := callable.AcquireTimeout(ODC_START_TIMEOUT, varStack, "Start", envId)
14791472

14801473
arguments := make(map[string]string)
1481-
arguments["run_number"] = rn
14821474
arguments["runNumber"] = rn
1483-
arguments["run_start_time_ms"] = runStartTimeMs
14841475
arguments["cleanup"] = strconv.Itoa(cleanupCount)
1485-
if len(originalRunNumber) > 0 {
1486-
arguments["original_run_number"] = originalRunNumber
1476+
for _, key := range environment.StartActivityParameterKeys {
1477+
if value, ok := varStack[key]; ok {
1478+
arguments[key] = value
1479+
}
14871480
}
14881481

14891482
ctx, cancel := integration.NewContext(envId, varStack, timeout)
@@ -1522,15 +1515,13 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
15221515
Error("cannot acquire run number for ODC EOR")
15231516
runNumberu64 = 0
15241517
}
1525-
runEndTimeMs, ok := varStack["run_end_time_ms"]
1526-
if !ok {
1527-
log.WithField("partition", envId).
1528-
WithField("call", "Stop").
1529-
Warn("cannot acquire run_end_time_ms")
1530-
}
15311518

15321519
arguments := make(map[string]string)
1533-
arguments["run_end_time_ms"] = runEndTimeMs
1520+
for _, key := range environment.StopActivityParameterKeys {
1521+
if value, ok := varStack[key]; ok {
1522+
arguments[key] = value
1523+
}
1524+
}
15341525

15351526
timeout := callable.AcquireTimeout(ODC_STOP_TIMEOUT, varStack, "Stop", envId)
15361527

@@ -1594,15 +1585,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
15941585
Error("cannot acquire run number for ODC EOR")
15951586
runNumberu64 = 0
15961587
}
1597-
runEndTimeMs, ok := varStack["run_end_time_ms"]
1598-
if !ok {
1599-
log.WithField("partition", envId).
1600-
WithField("call", "EnsureStop").
1601-
Warn("cannot acquire run_end_time_ms")
1602-
}
1603-
16041588
arguments := make(map[string]string)
1605-
arguments["run_end_time_ms"] = runEndTimeMs
1589+
for _, key := range environment.StopActivityParameterKeys {
1590+
if value, ok := varStack[key]; ok {
1591+
arguments[key] = value
1592+
}
1593+
}
16061594

16071595
err = handleStop(ctx, p.odcClient, arguments, paddingTimeout, envId, runNumberu64, call)
16081596
if err != nil {

docs/handbook/configuration.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,30 +424,30 @@ Depending on the specification in the task template (`command.env`, `command.arg
424424

425425
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`:
426426

427-
* `runNumber`
427+
* `run_number`
428428
* `fill_info_fill_number`
429429
* `fill_info_filling_scheme`
430430
* `fill_info_beam_type`
431431
* `fill_info_stable_beam_start_ms`
432432
* `fill_info_stable_beam_end_ms`
433433
* `run_type`
434434
* `run_start_time_ms`
435+
* `run_end_time_ms` (as an empty value)
435436
* `lhc_period`
436-
* `fillInfoFillNumber`
437-
* `fillInfoFillingScheme`
438-
* `fillInfoBeamType`
439-
* `fillInfoStableBeamStartMs`
440-
* `fillInfoStableBeamEndMs`
441-
* `runType`
442-
* `runStartTimeMs`
443-
* `lhcPeriod`
444437
* `pdp_beam_type`
445438
* `pdp_override_run_start_time`
446439
* `original_run_number`
447440

441+
For AliECS-controlled tasks, the same values are additionally pushed with keys in camelCase format.
442+
448443
The following values are pushed by AliECS during `STOP_ACTIVITY`:
449444

450445
* `run_end_time_ms`
446+
* `fill_info_fill_number`
447+
* `fill_info_filling_scheme`
448+
* `fill_info_beam_type`
449+
* `fill_info_stable_beam_start_ms`
450+
* `fill_info_stable_beam_end_ms`
451451

452452
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.
453453

0 commit comments

Comments
 (0)