Graceful way to exit QC?

Dear all

I am trying to write a runProducer to feed data into QC. The producer should read a MC generated file and feed the info (MFT digits) into QC for each readout frame (ROF). In the run() function of the producer class I want to exit gracefully once the last ROF in the input file is reached.

What is the correct command and the associated header files?
That is, I need something like
if ( no more ROF) {
close QC nicely
}

the idea is to ‘pipe’ this producer to a qc task that gets each ROF and process it

thanks for any help!
greetings from Prague

guillermo

Dear Guillermo,
It rings a bell. I am pretty sure that there has been a recent development in the DPL related to this. Calling @eulisse and @pkonopka.
Cheers,
Barth

If it is a DPL DataProcessor you can do:

context.services().get<ControlService>().endOfStream()

to notify that a source will not produce any more data. Such a message will then percolate automatically and once all the devices reach that state the workflow will quit.

If data goes through Data Sampling, then I am not sure if that will work. What is a condition of propagating EndOfStream further? If all inputs of a DataProcessor receive an EndOfStream?

Dear all

thanks for your answers.
Giulio: I am not sure if I have a DPL: I have a DataProcesssorSpec where the AlgorithSpec uses adaptFromTask. In the task I have a init() and a run(). I want to use the command there. Is this a DPL?
Another question: in run() I have a ‘ProcessingContext& pc’ as argument. Is this what you mean for the command? that is, do I write: pc.services().get().endOfStream() ?

Piotr: for the first tests I do not plan to use data sampling, but later on one should be able to use it. What command would you suggest in this case to exit when I reach the end of file?

thanks
guillermo

Yes. All you say it’s correct.

@pkonopka yes. If all sources of a DataProcessor emit an endOfStream().

I haven’t tried myself the feature with “EndOfStream”, but it should indeed work, even with Data Sampling (unless it has to handle more than one data source, and at least one doesn’t send “EndOfStream”).
What I have to add is sending MonitorObjects one last time when “EndOfStream” reaches a QC task.

I have created a jira issue : https://alice.its.cern.ch/jira/browse/QC-260

Dear Guillermo,
I gave it a try, don’t expect it to work with EndOfStream. While Data Sampling forwards it just fine, the problem is that QC Tasks have also a fake timer input, which apparently doesn’t work well with the logic of handling EndsOfStream. This will require some more thought and fixes.

For now, you can use in your QC task this line to request a quit of the full topology:

    #include <Framework/ControlService>
    ...
    processingContext.services().get<ControlService>().readyToQuit(QuitRequest::All);

But you will have to detect that there is no more data yourself…

Hi

ok, for now I will try as suggested by Piotr.

thanks a lot for the help!

guillermo

With the latest O2/dev and latest QC/master QC Tasks and Checks should correctly react to an EndOfStream signal.

When all of the producers will have sent EndOfStream (usage example here), QC Task will finish its cycle, publishing it MonitorObjects for the last time. Then it will send it to CheckRunner with an EndOfStream, which will perform Checks and store the results for the last time, then quit if all devices in the topology are done.

Hi @pkonopka,

I have a question to this, just for clarification: If I now run a QC task that gets its input data from another device, then when all data was received the QC task should ultimately quit and the workflow should stop after finishing the last cycle and performing checks one last time, right?
Or do I need to include a quit request in my QC task myself?

Thanks a lot!
Best,
Thomas

All you have to do is this, only in your data producer device (actually all devices which send data to QC):

processingContext.services().get<ControlService>().endOfStream();
processingContext.services().get<ControlService>().readyToQuit(QuitRequest::Me);

The following devices will automatically quit when they will have processed all the data after receiving EndOfStream and propagate it further. You don’t have to request to quit in your QC Task. The framework will invoke TaskInterface::endOfCycle and then TaskInterface::endOfActivity.

You can see how it behaves with this command:

o2-qc-run-producer --rate 1.0 --message-amount 15 | o2-qc --config json://$QUALITYCONTROL_ROOT/etc/basic.json

Ok I think it is clear now.
Thanks a lot for your answer!

Cheers,
Thomas