@@ -928,6 +928,8 @@ int runStateMachine(DataProcessorSpecs const& workflow,
928928 std::vector<ServicePreSchedule> preScheduleCallbacks;
929929 std::vector<ServicePostSchedule> postScheduleCallbacks;
930930
931+ bool guiDeployedOnce = false ;
932+
931933 while (true ) {
932934 // If control forced some transition on us, we push it to the queue.
933935 if (driverControl.forcedTransitions .empty () == false ) {
@@ -1025,6 +1027,10 @@ int runStateMachine(DataProcessorSpecs const& workflow,
10251027 break ;
10261028 case DriverState::MATERIALISE_WORKFLOW :
10271029 try {
1030+ auto workflowState = WorkflowHelpers::verifyWorkflow (workflow);
1031+ if (driverInfo.batch == true && workflowState == WorkflowParsingState::Empty) {
1032+ throw runtime_error (" Empty workflow provided while running in batch mode." );
1033+ }
10281034 DeviceSpecHelpers::dataProcessorSpecs2DeviceSpecs (workflow,
10291035 driverInfo.channelPolicies ,
10301036 driverInfo.completionPolicies ,
@@ -1063,6 +1069,13 @@ int runStateMachine(DataProcessorSpecs const& workflow,
10631069 } catch (std::runtime_error& e) {
10641070 std::cerr << " Invalid workflow: " << e.what () << std::endl;
10651071 return 1 ;
1072+ } catch (o2::framework::RuntimeErrorRef ref) {
1073+ auto & e = o2::framework::error_from_ref (ref);
1074+ #ifdef DPL_ENABLE_BACKTRACE
1075+ backtrace_symbols_fd (err.backtrace , err.maxBacktrace , STDERR_FILENO );
1076+ #endif
1077+ std::cerr << " Invalid workflow: " << e.what << std::endl;
1078+ return 1 ;
10661079 } catch (...) {
10671080 std::cerr << " Unknown error while materialising workflow" ;
10681081 return 1 ;
@@ -1107,6 +1120,7 @@ int runStateMachine(DataProcessorSpecs const& workflow,
11071120 guiContext.window = window;
11081121 gui_timer.data = &guiContext;
11091122 uv_timer_start (&gui_timer, gui_callback, 0 , 20 );
1123+ guiDeployedOnce = true ;
11101124 }
11111125 break ;
11121126 case DriverState::SCHEDULE : {
@@ -1185,10 +1199,14 @@ int runStateMachine(DataProcessorSpecs const& workflow,
11851199 driverInfo.states .push_back (DriverState::RUNNING );
11861200 driverInfo.states .push_back (DriverState::REDEPLOY_GUI );
11871201 driverInfo.states .push_back (DriverState::SCHEDULE );
1188- } else if (deviceSpecs.size () == 0 ) {
1202+ } else if (deviceSpecs.empty () && driverInfo. batch == true ) {
11891203 LOG (INFO ) << " No device resulting from the workflow. Quitting." ;
11901204 // If there are no deviceSpecs, we exit.
11911205 driverInfo.states .push_back (DriverState::EXIT );
1206+ } else if (deviceSpecs.empty () && driverInfo.batch == false && !guiDeployedOnce) {
1207+ // In case of an empty workflow, we need to deploy the GUI at least once.
1208+ driverInfo.states .push_back (DriverState::RUNNING );
1209+ driverInfo.states .push_back (DriverState::REDEPLOY_GUI );
11921210 } else {
11931211 driverInfo.states .push_back (DriverState::RUNNING );
11941212 }
0 commit comments