Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push run information to tasks OCTRL-791 #489

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/environment/transition_startactivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/AliceO2Group/Control/common/logger/infologger"
"github.com/AliceO2Group/Control/core/controlcommands"
"github.com/AliceO2Group/Control/core/task"
"github.com/iancoleman/strcase"
)

func NewStartActivityTransition(taskman *task.Manager) Transition {
Expand Down Expand Up @@ -73,6 +74,22 @@ func (t StartActivityTransition) do(env *Environment) (err error) {
"cleanup": strconv.Itoa(cleanupCount),
}

// If bookkeeping is enabled and has fetched the LHC fill info, we can acquire it here
for _, key := range []string{
"fill_info_fill_number",
"fill_info_filling_scheme",
"fill_info_beam_type",
"fill_info_stable_beam_start_ms",
"fill_info_stable_beam_end_ms",
"run_type",
"run_start_time_ms",
"lhc_period",
} {
if value, ok := env.GlobalVars.Get(key); ok {
args[strcase.ToLowerCamel(key)] = value
}
}

taskmanMessage := task.NewTransitionTaskMessage(
env.Workflow().GetTasks(),
task.CONFIGURED.String(),
Expand Down
11 changes: 10 additions & 1 deletion core/environment/transition_stopactivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import (

"github.com/AliceO2Group/Control/common/event"
"github.com/AliceO2Group/Control/common/logger/infologger"
"github.com/AliceO2Group/Control/core/controlcommands"
"github.com/AliceO2Group/Control/core/task"
"github.com/AliceO2Group/Control/core/workflow"
"github.com/iancoleman/strcase"
)

func NewStopActivityTransition(taskman *task.Manager) Transition {
Expand All @@ -55,6 +57,13 @@ func (t StopActivityTransition) do(env *Environment) (err error) {
WithField("partition", env.Id().String()).
Info("stopping run")

args := controlcommands.PropertyMap{}

// Propagate run end time to all tasks
if value, ok := env.GlobalVars.Get("run_end_time_ms"); ok {
args[strcase.ToLowerCamel("run_end_time_ms")] = value
}

taskmanMessage := task.NewTransitionTaskMessage(
env.Workflow().GetTasks().Filtered(func(t *task.Task) bool {
if pr, ok := t.GetParentRole().(workflow.Role); ok {
Expand All @@ -65,7 +74,7 @@ func (t StopActivityTransition) do(env *Environment) (err error) {
task.RUNNING.String(),
task.STOP.String(),
task.CONFIGURED.String(),
nil,
args,
env.Id(),
)
t.taskman.MessageChannel <- taskmanMessage
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.9.8 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4Dvx
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
5 changes: 3 additions & 2 deletions occ/plugin/OccFMQCommon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ std::tuple<OccLite::nopb::TransitionResponse, ::grpc::Status> doTransition(fair:
try {
auto evt = fair::mq::PluginServices::ToDeviceStateTransition(event);

// Run number must be pushed immediately before RUN transition
if (evt == fair::mq::PluginServices::DeviceStateTransition::Run) {
// RUN and STOP support arguments, pushed as properties right before performing the transition
if (evt == fair::mq::PluginServices::DeviceStateTransition::Run ||
evt == fair::mq::PluginServices::DeviceStateTransition::Stop) {
try {
for (auto const& entry : arguments) {
m_pluginServices->SetProperty(entry.key, entry.value);
Expand Down