Skip to content

Commit bc1d521

Browse files
authored
[QC-310] Dump a property qcConfiguration for the QC devices (#7942)
* [QC-310] Dump a property qcConfiguration for the QC devices Introduce a new label `qc-reconfigurable`. Dump a property in the qc tasks pointing to the file in consul to reconfigure the tasks. * format * Fix the formatting * apply pr comments
1 parent 95fe5b7 commit bc1d521

3 files changed

Lines changed: 44 additions & 10 deletions

File tree

Framework/Core/include/Framework/O2ControlLabels.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const extern DataProcessorLabel uniqueProxyLabel;
3131
// Thus, AliECS will not perform host and port allocation automatically. It takes priority over `uniqueProxyLabel`.
3232
const extern DataProcessorLabel preserveRawChannelsLabel;
3333

34+
// This label makes AliECS templates add the property `qcConfiguration` to the tasks, allowing them
35+
// to reconfigure in init with a freshly templated config.
36+
const extern DataProcessorLabel qcReconfigurable;
37+
3438
} // namespace ecs
3539
} // namespace o2::framework
3640

Framework/Core/src/O2ControlHelpers.cxx

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,41 @@ std::vector<RawChannel> extractRawChannels(const DeviceSpec& spec, const DeviceE
185185
return rawChannels;
186186
}
187187

188+
bool isUniqueProxy(const DeviceSpec& spec)
189+
{
190+
return std::find(spec.labels.begin(), spec.labels.end(), ecs::uniqueProxyLabel) != spec.labels.end();
191+
}
192+
193+
bool shouldPreserveRawChannels(const DeviceSpec& spec)
194+
{
195+
return std::find(spec.labels.begin(), spec.labels.end(), ecs::preserveRawChannelsLabel) != spec.labels.end();
196+
}
197+
198+
bool isQcReconfigurable(const DeviceSpec& spec)
199+
{
200+
return std::find(spec.labels.begin(), spec.labels.end(), ecs::qcReconfigurable) != spec.labels.end();
201+
}
202+
203+
void dumpProperties(std::ostream& dumpOut, const DeviceExecution& execution, const DeviceSpec& spec, const std::string& indLevel)
204+
{
205+
// get the argument `--config`
206+
std::string configPath;
207+
auto it = std::find_if(execution.args.begin(), execution.args.end(), [](char* v) { return v != nullptr && strcmp(v, "--config") == 0; });
208+
209+
// get the next argument and find `/o2/components/` in it, then take what comes after in the string.
210+
if (it != execution.args.end()) {
211+
std::string configParam = *(++it);
212+
std::string prefix = "/o2/components/"; // keep only the path to the config file, i.e. stuff after "/o2/components/"
213+
size_t pos = configParam.find(prefix);
214+
if (pos != std::string::npos) {
215+
configPath = configParam.substr(pos + prefix.length());
216+
}
217+
}
218+
219+
dumpOut << indLevel << "properties:\n";
220+
dumpOut << indLevel << indScheme << "qcConfiguration: " << configPath << "\n";
221+
}
222+
188223
void dumpCommand(std::ostream& dumpOut, const DeviceExecution& execution, std::string indLevel)
189224
{
190225
dumpOut << indLevel << "shell: true\n";
@@ -260,16 +295,6 @@ std::string findBinder(const std::vector<DeviceSpec>& specs, const std::string&
260295
throw std::runtime_error("Could not find a device which binds the '" + channel + "' channel.");
261296
}
262297

263-
bool isUniqueProxy(const DeviceSpec& spec)
264-
{
265-
return std::find(spec.labels.begin(), spec.labels.end(), ecs::uniqueProxyLabel) != spec.labels.end();
266-
}
267-
268-
bool shouldPreserveRawChannels(const DeviceSpec& spec)
269-
{
270-
return std::find(spec.labels.begin(), spec.labels.end(), ecs::preserveRawChannelsLabel) != spec.labels.end();
271-
}
272-
273298
void dumpRole(std::ostream& dumpOut, const std::string& taskName, const DeviceSpec& spec, const std::vector<DeviceSpec>& allSpecs, const DeviceExecution& execution, const std::string indLevel)
274299
{
275300
dumpOut << indLevel << "- name: \"" << spec.id << "\"\n";
@@ -374,6 +399,10 @@ void dumpTask(std::ostream& dumpOut, const DeviceSpec& spec, const DeviceExecuti
374399
}
375400
}
376401

402+
if (implementation::isQcReconfigurable(spec)) {
403+
implementation::dumpProperties(dumpOut, execution, spec, indLevel);
404+
}
405+
377406
dumpOut << indLevel << "command:\n";
378407
implementation::dumpCommand(dumpOut, execution, indLevel + indScheme);
379408
}

Framework/Core/src/O2ControlLabels.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ namespace o2::framework::ecs
1616

1717
const DataProcessorLabel uniqueProxyLabel = {"ecs-unique-proxy"};
1818
const DataProcessorLabel preserveRawChannelsLabel = {"ecs-preserve-raw-channels"};
19+
const DataProcessorLabel qcReconfigurable = {"qc-reconfigurable"};
1920
}

0 commit comments

Comments
 (0)