v2.0.0
Loading...
Searching...
No Matches
ml_trainer.cpp
Go to the documentation of this file.
1//=============================================================================================================
28
29//=============================================================================================================
30// INCLUDES
31//=============================================================================================================
32
33#include "ml_trainer.h"
34
35#ifndef WASMBUILD // QProcess (used by PythonRunner) is not available in Qt WASM
36
37//=============================================================================================================
38// QT INCLUDES
39//=============================================================================================================
40
41#include <QDebug>
42
43//=============================================================================================================
44// USED NAMESPACES
45//=============================================================================================================
46
47using namespace MLLIB;
48using namespace UTILSLIB;
49
50//=============================================================================================================
51// DEFINE MEMBER METHODS
52//=============================================================================================================
53
55 : m_runner()
56{
57}
58
59//=============================================================================================================
60
62 : m_runner(config)
63{
64}
65
66//=============================================================================================================
67
69{
70 return m_runner;
71}
72
73//=============================================================================================================
74
75PythonRunnerResult MLTrainer::run(const QString& scriptPath,
76 const QStringList& args)
77{
78 if (!m_runner.isPythonAvailable()) {
79 PythonRunnerResult result;
80 result.stdErr = QStringLiteral("Python interpreter not found: ") + m_runner.config().pythonExe;
81 qWarning() << "[MLTrainer]" << result.stdErr;
82 return result;
83 }
84
85 qDebug() << "[MLTrainer] Running training script:" << scriptPath;
86
87 // If a venv is configured, use runInVenv (creates venv + installs deps automatically)
88 if (!m_runner.config().venvDir.isEmpty()) {
89 return m_runner.runInVenv(scriptPath, args);
90 }
91
92 return m_runner.run(scriptPath, args);
93}
94
95//=============================================================================================================
96
97QStringList MLTrainer::checkPrerequisites(const QStringList& packages) const
98{
99 QStringList missing;
100 for (const QString& pkg : packages) {
101 if (!m_runner.isPackageAvailable(pkg)) {
102 missing << pkg;
103 }
104 }
105 if (!missing.isEmpty()) {
106 qWarning() << "[MLTrainer] Missing Python packages:" << missing.join(QStringLiteral(", "));
107 }
108 return missing;
109}
110
111#endif // WASMBUILD
MLLIB::MLTrainer convenience wrapper that drives Python training scripts via UTILSLIB::PythonRunner.
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Tensors, model abstraction, ONNX Runtime inference and Python training drivers used across mne-cpp.
UTILSLIB::PythonRunner & runner()
QStringList checkPrerequisites(const QStringList &packages) const
UTILSLIB::PythonRunnerResult run(const QString &scriptPath, const QStringList &args={})
Script execution result container.
Script execution configuration.
Python script launcher with logging and progress support.