Commit 7ffaec4f authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[widgets][experimenteditor] Renamed prefix modeling classes

The names are now less confusing with regard to their usage.
parent d0adcf6c
...@@ -60,8 +60,8 @@ from ..widgets.experimenteditor import EnvironmentModel ...@@ -60,8 +60,8 @@ from ..widgets.experimenteditor import EnvironmentModel
from ..widgets.experimenteditor import ExperimentEditor from ..widgets.experimenteditor import ExperimentEditor
from ..widgets.experimenteditor import typed_user_property from ..widgets.experimenteditor import typed_user_property
from ..widgets.experimenteditor import PrefixModel from ..widgets.experimenteditor import ExperimentResources
from ..widgets.experimenteditor import AlgorithmModel from ..widgets.experimenteditor import AlgorithmResourceModel
from .conftest import prefix from .conftest import prefix
from .conftest import sync_prefix from .conftest import sync_prefix
...@@ -157,11 +157,11 @@ def choice_parameter_name(request): ...@@ -157,11 +157,11 @@ def choice_parameter_name(request):
# Tests # Tests
class TestPrefixModel: class TestExperimentResources:
"""Test that the prefix modelisation generates the expected data""" """Test that the prefix modelisation generates the expected data"""
def test_model(self, beat_context): def test_model(self, beat_context):
model = PrefixModel(beat_context) model = ExperimentResources(beat_context)
model = QSqlTableModel() model = QSqlTableModel()
model.setTable("algorithms") model.setTable("algorithms")
...@@ -177,15 +177,15 @@ class TestPrefixModel: ...@@ -177,15 +177,15 @@ class TestPrefixModel:
assert analyzer_count < total assert analyzer_count < total
class TestAlgorithmModel: class TestAlgorithmResourceModel:
"""Test the model used to generate suitable algorithm selections""" """Test the model used to generate suitable algorithm selections"""
@pytest.fixture @pytest.fixture
def prefix_model(self, beat_context): def prefix_model(self, beat_context):
return PrefixModel(beat_context) return ExperimentResources(beat_context)
def test_default(self, prefix_model): def test_default(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
query = QSqlQuery() query = QSqlQuery()
assert query.exec_( assert query.exec_(
...@@ -197,7 +197,7 @@ class TestAlgorithmModel: ...@@ -197,7 +197,7 @@ class TestAlgorithmModel:
assert algorithm_model.rowCount() == query.value("cnt") assert algorithm_model.rowCount() == query.value("cnt")
def test_analyzers(self, prefix_model): def test_analyzers(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
algorithm_model.setAnalyzerEnabled(True) algorithm_model.setAnalyzerEnabled(True)
query = QSqlQuery() query = QSqlQuery()
...@@ -210,7 +210,7 @@ class TestAlgorithmModel: ...@@ -210,7 +210,7 @@ class TestAlgorithmModel:
assert algorithm_model.rowCount() == query.value("cnt") assert algorithm_model.rowCount() == query.value("cnt")
def test_types(self, prefix_model): def test_types(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
algorithm_model.setTypes( algorithm_model.setTypes(
[Algorithm.LEGACY, Algorithm.SEQUENTIAL, Algorithm.AUTONOMOUS] [Algorithm.LEGACY, Algorithm.SEQUENTIAL, Algorithm.AUTONOMOUS]
) )
...@@ -225,7 +225,7 @@ class TestAlgorithmModel: ...@@ -225,7 +225,7 @@ class TestAlgorithmModel:
assert algorithm_model.rowCount() == query.value("cnt") assert algorithm_model.rowCount() == query.value("cnt")
def test_output_count(self, prefix_model): def test_output_count(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
algorithm_model.setOutputCount(2) algorithm_model.setOutputCount(2)
query = QSqlQuery() query = QSqlQuery()
...@@ -238,7 +238,7 @@ class TestAlgorithmModel: ...@@ -238,7 +238,7 @@ class TestAlgorithmModel:
assert algorithm_model.rowCount() == query.value("cnt") assert algorithm_model.rowCount() == query.value("cnt")
def test_input_count(self, prefix_model): def test_input_count(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
algorithm_model.setInputCount(2) algorithm_model.setInputCount(2)
query = QSqlQuery() query = QSqlQuery()
...@@ -251,7 +251,7 @@ class TestAlgorithmModel: ...@@ -251,7 +251,7 @@ class TestAlgorithmModel:
assert algorithm_model.rowCount() == query.value("cnt") assert algorithm_model.rowCount() == query.value("cnt")
def test_input_output_count(self, prefix_model): def test_input_output_count(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
algorithm_model.setInputCount(1) algorithm_model.setInputCount(1)
algorithm_model.setOutputCount(1) algorithm_model.setOutputCount(1)
...@@ -265,7 +265,7 @@ class TestAlgorithmModel: ...@@ -265,7 +265,7 @@ class TestAlgorithmModel:
assert algorithm_model.rowCount() == query.value("cnt") assert algorithm_model.rowCount() == query.value("cnt")
def test_input_output_count_and_types(self, prefix_model): def test_input_output_count_and_types(self, prefix_model):
algorithm_model = AlgorithmModel() algorithm_model = AlgorithmResourceModel()
algorithm_model.setInputCount(1) algorithm_model.setInputCount(1)
algorithm_model.setOutputCount(1) algorithm_model.setOutputCount(1)
algorithm_model.setTypes([Algorithm.SEQUENTIAL]) algorithm_model.setTypes([Algorithm.SEQUENTIAL])
...@@ -714,11 +714,11 @@ class TestExecutionPropertiesEditor(PropertiesEditorTestMixin, ParameterTestMixi ...@@ -714,11 +714,11 @@ class TestExecutionPropertiesEditor(PropertiesEditorTestMixin, ParameterTestMixi
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def prefix_model(self, beat_context): def prefix_model(self, beat_context):
return PrefixModel(beat_context) return ExperimentResources(beat_context)
@pytest.fixture() @pytest.fixture()
def algorithm_model(self): def algorithm_model(self):
return AlgorithmModel() return AlgorithmResourceModel()
@pytest.fixture() @pytest.fixture()
def properties_editor(self, beat_context, test_prefix, algorithm_model): def properties_editor(self, beat_context, test_prefix, algorithm_model):
...@@ -726,7 +726,7 @@ class TestExecutionPropertiesEditor(PropertiesEditorTestMixin, ParameterTestMixi ...@@ -726,7 +726,7 @@ class TestExecutionPropertiesEditor(PropertiesEditorTestMixin, ParameterTestMixi
environment_model.setContext(beat_context) environment_model.setContext(beat_context)
editor = self.editor_klass(test_prefix) editor = self.editor_klass(test_prefix)
editor.setAlgorithmModel(algorithm_model) editor.setAlgorithmResourceModel(algorithm_model)
editor.setEnvironmentModel(environment_model) editor.setEnvironmentModel(environment_model)
editor.setQueueModel(QStringListModel(["Test"])) editor.setQueueModel(QStringListModel(["Test"]))
return editor return editor
......
...@@ -224,7 +224,7 @@ class DatasetModel(QStringListModel): ...@@ -224,7 +224,7 @@ class DatasetModel(QStringListModel):
# Prefix modelization # Prefix modelization
class PrefixModel: class ExperimentResources:
def __init__(self, context=None): def __init__(self, context=None):
self.context = context self.context = context
...@@ -295,7 +295,7 @@ class PrefixModel: ...@@ -295,7 +295,7 @@ class PrefixModel:
) )
class AlgorithmModel(QSqlTableModel): class AlgorithmResourceModel(QSqlTableModel):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent=parent) super().__init__(parent=parent)
...@@ -794,7 +794,7 @@ class ExecutionPropertiesEditor(AbstractBaseEditor): ...@@ -794,7 +794,7 @@ class ExecutionPropertiesEditor(AbstractBaseEditor):
algorithm = pyqtProperty(str, fget=algorithm, notify=algorithmChanged) algorithm = pyqtProperty(str, fget=algorithm, notify=algorithmChanged)
def setAlgorithmModel(self, model): def setAlgorithmResourceModel(self, model):
self.algorithm_model = model self.algorithm_model = model
self.algorithm_combobox.setModel(self.algorithm_model) self.algorithm_combobox.setModel(self.algorithm_model)
...@@ -885,7 +885,7 @@ class AbstractBlockEditor(AbstractBaseEditor): ...@@ -885,7 +885,7 @@ class AbstractBlockEditor(AbstractBaseEditor):
self.block_name = block_name self.block_name = block_name
def setAlgorithmModel(self, model): def setAlgorithmResourceModel(self, model):
"""Set algorithm model""" """Set algorithm model"""
raise NotImplementedError raise NotImplementedError
...@@ -905,14 +905,14 @@ class BlockEditor(AbstractBlockEditor): ...@@ -905,14 +905,14 @@ class BlockEditor(AbstractBlockEditor):
def __init__(self, block_name, prefix_path, parent=None): def __init__(self, block_name, prefix_path, parent=None):
super().__init__(block_name, prefix_path, parent) super().__init__(block_name, prefix_path, parent)
self.algorithm_model = AlgorithmModel() self.algorithm_model = AlgorithmResourceModel()
self.algorithm_model.setAnalyzerEnabled(False) self.algorithm_model.setAnalyzerEnabled(False)
self.algorithm_model.setTypes( self.algorithm_model.setTypes(
[Algorithm.LEGACY, Algorithm.SEQUENTIAL, Algorithm.AUTONOMOUS] [Algorithm.LEGACY, Algorithm.SEQUENTIAL, Algorithm.AUTONOMOUS]
) )
self.properties_editor = ExecutionPropertiesEditor(prefix_path) self.properties_editor = ExecutionPropertiesEditor(prefix_path)
self.properties_editor.setAlgorithmModel(self.algorithm_model) self.properties_editor.setAlgorithmResourceModel(self.algorithm_model)
layout = QVBoxLayout(self) layout = QVBoxLayout(self)
layout.addWidget(QLabel(self.block_name)) layout.addWidget(QLabel(self.block_name))
...@@ -953,22 +953,22 @@ class LoopBlockEditor(AbstractBlockEditor): ...@@ -953,22 +953,22 @@ class LoopBlockEditor(AbstractBlockEditor):
def __init__(self, block_name, prefix_path, parent=None): def __init__(self, block_name, prefix_path, parent=None):
super().__init__(block_name, prefix_path, parent) super().__init__(block_name, prefix_path, parent)
self.processor_model = AlgorithmModel() self.processor_model = AlgorithmResourceModel()
self.processor_model.setAnalyzerEnabled(False) self.processor_model.setAnalyzerEnabled(False)
self.processor_model.setTypes( self.processor_model.setTypes(
[Algorithm.AUTONOMOUS_LOOP_PROCESSOR, Algorithm.SEQUENTIAL_LOOP_PROCESSOR] [Algorithm.AUTONOMOUS_LOOP_PROCESSOR, Algorithm.SEQUENTIAL_LOOP_PROCESSOR]
) )
self.evaluator_model = AlgorithmModel() self.evaluator_model = AlgorithmResourceModel()
self.evaluator_model.setAnalyzerEnabled(False) self.evaluator_model.setAnalyzerEnabled(False)
self.evaluator_model.setTypes( self.evaluator_model.setTypes(
[Algorithm.AUTONOMOUS_LOOP_EVALUATOR, Algorithm.SEQUENTIAL_LOOP_EVALUATOR] [Algorithm.AUTONOMOUS_LOOP_EVALUATOR, Algorithm.SEQUENTIAL_LOOP_EVALUATOR]
) )
self.processor_properties_editor = ExecutionPropertiesEditor(prefix_path) self.processor_properties_editor = ExecutionPropertiesEditor(prefix_path)
self.processor_properties_editor.setAlgorithmModel(self.processor_model) self.processor_properties_editor.setAlgorithmResourceModel(self.processor_model)
self.evaluator_properties_editor = ExecutionPropertiesEditor(prefix_path) self.evaluator_properties_editor = ExecutionPropertiesEditor(prefix_path)
self.evaluator_properties_editor.setAlgorithmModel(self.evaluator_model) self.evaluator_properties_editor.setAlgorithmResourceModel(self.evaluator_model)
self.evaluator_properties_editor.setQueueEnabled(False) self.evaluator_properties_editor.setQueueEnabled(False)
processor_groupbox = QGroupBox(self.tr("Processor")) processor_groupbox = QGroupBox(self.tr("Processor"))
...@@ -1193,7 +1193,7 @@ class ExperimentEditor(AbstractAssetEditor): ...@@ -1193,7 +1193,7 @@ class ExperimentEditor(AbstractAssetEditor):
self.setObjectName(self.__class__.__name__) self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Experiment")) self.set_title(self.tr("Experiment"))
self.prefix_model = PrefixModel() self.prefix_model = ExperimentResources()
self.processing_env_model = EnvironmentModel() self.processing_env_model = EnvironmentModel()
self.queue_model = QStringListModel() self.queue_model = QStringListModel()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment