Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
9efd122d
Commit
9efd122d
authored
Jun 16, 2020
by
Samuel GAIST
Browse files
[widgets][experimenteditor] Refactor DatasetModel handling
parent
cf44d58c
Changes
2
Hide whitespace changes
Inline
Side-by-side
beat/editor/test/test_experimenteditor.py
View file @
9efd122d
...
@@ -48,7 +48,6 @@ from ..widgets.experimenteditor import AlgorithmParametersEditor
...
@@ -48,7 +48,6 @@ from ..widgets.experimenteditor import AlgorithmParametersEditor
from
..widgets.experimenteditor
import
AnalyzerBlockEditor
from
..widgets.experimenteditor
import
AnalyzerBlockEditor
from
..widgets.experimenteditor
import
BlockEditor
from
..widgets.experimenteditor
import
BlockEditor
from
..widgets.experimenteditor
import
DatasetEditor
from
..widgets.experimenteditor
import
DatasetEditor
from
..widgets.experimenteditor
import
DatasetModel
from
..widgets.experimenteditor
import
EnvironmentModel
from
..widgets.experimenteditor
import
EnvironmentModel
from
..widgets.experimenteditor
import
ExecutionPropertiesEditor
from
..widgets.experimenteditor
import
ExecutionPropertiesEditor
from
..widgets.experimenteditor
import
ExperimentEditor
from
..widgets.experimenteditor
import
ExperimentEditor
...
@@ -379,15 +378,8 @@ class TestDatasetEditor:
...
@@ -379,15 +378,8 @@ class TestDatasetEditor:
return
datasets
[
dataset
]
return
datasets
[
dataset
]
@
pytest
.
fixture
()
@
pytest
.
fixture
()
def
dataset_model
(
self
,
test_prefix
):
def
editor
(
self
,
qtbot
,
test_prefix
,
datasets
):
dataset_model
=
DatasetModel
()
dataset_model
.
setPrefixPath
(
test_prefix
)
return
dataset_model
@
pytest
.
fixture
()
def
editor
(
self
,
qtbot
,
test_prefix
,
datasets
,
dataset_model
):
editor
=
DatasetEditor
(
"test_block"
,
test_prefix
)
editor
=
DatasetEditor
(
"test_block"
,
test_prefix
)
editor
.
setDatasetModel
(
dataset_model
)
qtbot
.
addWidget
(
editor
)
qtbot
.
addWidget
(
editor
)
return
editor
return
editor
...
...
beat/editor/widgets/experimenteditor.py
View file @
9efd122d
...
@@ -331,12 +331,17 @@ class IOMapperDialog(QDialog):
...
@@ -331,12 +331,17 @@ class IOMapperDialog(QDialog):
class
DatasetEditor
(
AbstractBaseEditor
):
class
DatasetEditor
(
AbstractBaseEditor
):
"""Widget allowing the setup of the various datasets used"""
"""Widget allowing the setup of the various datasets used"""
datasetChanged
=
pyqtSignal
(
str
)
def
__init__
(
self
,
block_name
,
prefix_path
,
parent
=
None
):
def
__init__
(
self
,
block_name
,
prefix_path
,
parent
=
None
):
super
().
__init__
(
prefix_path
,
parent
)
super
().
__init__
(
prefix_path
,
parent
)
self
.
json_object
=
{}
self
.
json_object
=
{}
self
.
block_name
=
block_name
self
.
block_name
=
block_name
self
.
dataset_model
=
DatasetModel
()
self
.
dataset_model
.
setPrefixPath
(
prefix_path
)
self
.
dataset_combobox
=
QComboBox
()
self
.
dataset_combobox
=
QComboBox
()
self
.
dataset_combobox
.
setModel
(
self
.
dataset_model
)
self
.
reset_button
=
QPushButton
(
self
.
reset_button
=
QPushButton
(
self
.
style
().
standardIcon
(
QStyle
.
SP_DialogResetButton
),
""
self
.
style
().
standardIcon
(
QStyle
.
SP_DialogResetButton
),
""
)
)
...
@@ -350,6 +355,7 @@ class DatasetEditor(AbstractBaseEditor):
...
@@ -350,6 +355,7 @@ class DatasetEditor(AbstractBaseEditor):
layout
.
addRow
(
self
.
block_name
,
row_layout
)
layout
.
addRow
(
self
.
block_name
,
row_layout
)
self
.
dataset_combobox
.
currentTextChanged
.
connect
(
self
.
dataChanged
)
self
.
dataset_combobox
.
currentTextChanged
.
connect
(
self
.
dataChanged
)
self
.
dataset_combobox
.
currentTextChanged
.
connect
(
self
.
datasetChanged
)
self
.
reset_button
.
clicked
.
connect
(
self
.
reset
)
self
.
reset_button
.
clicked
.
connect
(
self
.
reset
)
def
reset
(
self
):
def
reset
(
self
):
...
@@ -363,8 +369,20 @@ class DatasetEditor(AbstractBaseEditor):
...
@@ -363,8 +369,20 @@ class DatasetEditor(AbstractBaseEditor):
if
self
.
dataset_combobox
.
currentText
()
!=
dataset_name
:
if
self
.
dataset_combobox
.
currentText
()
!=
dataset_name
:
self
.
dataset_combobox
.
setCurrentIndex
(
-
1
)
self
.
dataset_combobox
.
setCurrentIndex
(
-
1
)
def
setDatasetModel
(
self
,
dataset_model
):
def
loadToolchainData
(
self
,
toolchain
):
self
.
dataset_combobox
.
setModel
(
dataset_model
)
asset
=
AssetType
.
TOOLCHAIN
.
klass
(
self
.
prefix_path
,
toolchain
)
outputs
=
[]
if
asset
.
valid
:
outputs
=
asset
.
datasets
[
self
.
block_name
][
"outputs"
]
current_dataset
=
self
.
dataset_combobox
.
currentText
()
# Avoid emitting signals while updating the filter as the current
# entry will be invalidated.
self
.
dataset_combobox
.
blockSignals
(
True
)
self
.
dataset_model
.
setupOuputFilter
(
outputs
)
self
.
dataset_combobox
.
setCurrentText
(
current_dataset
)
self
.
dataset_combobox
.
blockSignals
(
False
)
def
currentSet
(
self
):
def
currentSet
(
self
):
_
,
_
,
_
,
set_
=
self
.
dataset_combobox
.
currentText
().
split
(
"/"
)
_
,
_
,
_
,
set_
=
self
.
dataset_combobox
.
currentText
().
split
(
"/"
)
...
@@ -1096,6 +1114,10 @@ class GlobalParametersEditor(AbstractBaseEditor):
...
@@ -1096,6 +1114,10 @@ class GlobalParametersEditor(AbstractBaseEditor):
@
frozen
@
frozen
class
ExperimentEditor
(
AbstractAssetEditor
):
class
ExperimentEditor
(
AbstractAssetEditor
):
"""Editor for experiment configuration"""
blockChanged
=
pyqtSignal
(
str
,
dict
)
def
__init__
(
self
,
parent
=
None
):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
AssetType
.
EXPERIMENT
,
parent
)
super
().
__init__
(
AssetType
.
EXPERIMENT
,
parent
)
self
.
setObjectName
(
self
.
__class__
.
__name__
)
self
.
setObjectName
(
self
.
__class__
.
__name__
)
...
@@ -1103,8 +1125,6 @@ class ExperimentEditor(AbstractAssetEditor):
...
@@ -1103,8 +1125,6 @@ class ExperimentEditor(AbstractAssetEditor):
self
.
processing_env_model
=
EnvironmentModel
()
self
.
processing_env_model
=
EnvironmentModel
()
self
.
dataset_model
=
DatasetModel
()
self
.
algorithm_model
=
AssetModel
()
self
.
algorithm_model
=
AssetModel
()
self
.
algorithm_model
.
setLatestOnlyEnabled
(
False
)
self
.
algorithm_model
.
setLatestOnlyEnabled
(
False
)
self
.
algorithm_model
.
asset_type
=
AssetType
.
ALGORITHM
self
.
algorithm_model
.
asset_type
=
AssetType
.
ALGORITHM
...
@@ -1144,7 +1164,6 @@ class ExperimentEditor(AbstractAssetEditor):
...
@@ -1144,7 +1164,6 @@ class ExperimentEditor(AbstractAssetEditor):
def
__update
(
self
):
def
__update
(
self
):
for
object_
in
[
for
object_
in
[
self
.
algorithm_model
,
self
.
algorithm_model
,
self
.
dataset_model
,
self
.
datasets_widget
,
self
.
datasets_widget
,
self
.
blocks_widget
,
self
.
blocks_widget
,
self
.
loops_widget
,
self
.
loops_widget
,
...
@@ -1173,7 +1192,7 @@ class ExperimentEditor(AbstractAssetEditor):
...
@@ -1173,7 +1192,7 @@ class ExperimentEditor(AbstractAssetEditor):
# Here we use the fact that Python is weakly typed and reload
# Here we use the fact that Python is weakly typed and reload
# the dataset model as well
# the dataset model as well
return
[
self
.
algorithm_model
,
self
.
dataset_model
]
return
[
self
.
algorithm_model
]
def
_createNewAsset
(
self
,
creation_type
,
asset_info
):
def
_createNewAsset
(
self
,
creation_type
,
asset_info
):
"""Re-implement"""
"""Re-implement"""
...
@@ -1308,7 +1327,6 @@ class ExperimentEditor(AbstractAssetEditor):
...
@@ -1308,7 +1327,6 @@ class ExperimentEditor(AbstractAssetEditor):
if
datasets
:
if
datasets
:
for
name
,
dataset
in
datasets
.
items
():
for
name
,
dataset
in
datasets
.
items
():
editor
=
DatasetEditor
(
name
,
self
.
prefix_path
)
editor
=
DatasetEditor
(
name
,
self
.
prefix_path
)
editor
.
setDatasetModel
(
self
.
dataset_model
)
editor
.
load
(
dataset
)
editor
.
load
(
dataset
)
self
.
datasets_widget
.
addWidget
(
editor
)
self
.
datasets_widget
.
addWidget
(
editor
)
...
@@ -1404,3 +1422,7 @@ class ExperimentEditor(AbstractAssetEditor):
...
@@ -1404,3 +1422,7 @@ class ExperimentEditor(AbstractAssetEditor):
data
[
"loops"
]
=
loops
data
[
"loops"
]
=
loops
return
data
return
data
def
loadToolchainData
(
self
,
toolchain
):
for
widget
in
self
.
datasets_widget
.
widget_list
:
widget
.
loadToolchainData
(
toolchain
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment