Learn Environment
Loading...
Searching...
No Matches
script_worker.hpp
Go to the documentation of this file.
1#ifndef SCRIPT_WORKER_HPP
2#define SCRIPT_WORKER_HPP
3
4#include <QObject>
5#include <QString>
6#include <QProcess>
7#include <QList>
8
10
11class ProcessRunner;
12
21class ScriptWorker : public QObject {
22 Q_OBJECT
23
24public:
33 ScriptWorker(const QString &notebookPath,
34 const QString &convertedScriptPath,
35 const QString &evalScriptPath,
36 bool parallelizedEvaluation,
37 int timeoutSeconds);
38
39public Q_SLOTS:
43 void startExecution();
44
48 void forceStop();
49
53 void executePythonScript(const QString &scriptPath, const QString &name);
54
55Q_SIGNALS:
59 void finished();
60
65 void failed(const QString &error);
66
67private:
71 void convertAndExecuteNotebook();
72
76 void executeConvertedScript();
77
81 void evaluateScriptInParallel();
82
86 void checkResult();
87
91 void checkAndEmitFinished();
92
98 QString formatMessage(const QString &msg, bool fromEval = false);
99
100 QString notebookPath;
101 QString convertedScriptPath;
102 QString evalScriptPath;
103 bool parallelizedEvaluationRequired;
104 int timeoutSeconds;
105
106 bool mainScriptFinished;
107 bool evalScriptFinished;
108
109 QList<ProcessRunner*> processRunners;
110 NotebookConverter converter;
111
112 QString errorOutput;
113 QString evaluationOutput;
114};
115
116#endif // SCRIPT_WORKER_HPP
A class for converting Jupyter notebooks to Python scripts and processing task pools.
Definition notebook_converter.hpp:23
Manages the execution of an external process with a timeout.
Definition process_runner.hpp:15
Manages the execution of scripts for tasks.
Definition script_worker.hpp:21
ScriptWorker(const QString &notebookPath, const QString &convertedScriptPath, const QString &evalScriptPath, bool parallelizedEvaluation, int timeoutSeconds)
Constructs a ScriptWorker object.
Definition script_worker.cpp:25
void startExecution()
Starts the execution of the scripts.
Definition script_worker.cpp:39
void failed(const QString &error)
Signal emitted when the script execution fails.
void forceStop()
Forces the stop of all running scripts.
Definition script_worker.cpp:206
void finished()
Signal emitted when the script execution finishes.
void executePythonScript(const QString &scriptPath, const QString &name)
Executes a given Python script.
Definition script_worker.cpp:172