Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust determination of when a workflow settings can be imported. #113

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions src/mapclient/view/workflow/importconfigdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ def __init__(self, import_source, graphics_scene, parent=None):
self._undo_stack = self._graphics_scene.getUndoStack()

self._step_map = None
if self._check_compatibility():
self._setup_step_map()
self._setup_grid_layout()
else:
self._ui.pushButtonImport.setEnabled(False)
self._setup_step_map()
self._setup_grid_layout()

self._make_connections()

Expand Down Expand Up @@ -93,14 +90,14 @@ def _create_step_map(self, node_count, import_steps, workflow_steps):
# If the lists of step names match, assign a one-to-one mapping of step indices.
self._step_map["Selected"] = import_steps["ID"]

def _check_compatibility(self):
def is_compatible(self):
import_proj = self._import_settings()
# Check for version compatibility.
import_version = version.parse(import_proj.value('version'))
application_version = version.parse(VERSION_STRING)
if not _compatible_versions(import_version, application_version):
QtWidgets.QMessageBox.warning(self, 'Different Workflow Versions', f'The version of the imported workflow ({import_version})'
f' is not compatible with this version of the MAP Client ({application_version}).')
f' is not compatible with this version of the MAP Client ({application_version}).')
return False

return True
Expand Down Expand Up @@ -183,15 +180,12 @@ def _import_clicked(self):
"The selected configurations have been successfully imported.")


def _matches_major_minor_version(test_version, target_version):
return test_version.major == target_version.major and test_version.minor == target_version.minor


def _compatible_versions(import_settings_version, application_version):
if _matches_major_minor_version(import_settings_version, version.Version("0.20.0")) and import_settings_version <= application_version:
return True
if import_settings_version < version.Version("0.19.0"):
return False

if _matches_major_minor_version(import_settings_version, version.Version("0.19.0")) and import_settings_version <= application_version:
return True
significant_import_settings_version = version.Version(f"{import_settings_version.major}.{import_settings_version.minor}")
if significant_import_settings_version > application_version:
return False

return False
return True
5 changes: 3 additions & 2 deletions src/mapclient/view/workflow/workflowwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@ def import_cfg(self):

if len(import_source) > 0:
dlg = ImportConfigDialog(import_source, self._graphicsScene, self)
dlg.setModal(True)
dlg.exec_()
if dlg.is_compatible():
dlg.setModal(True)
dlg.exec()

def export_cfg(self):
self.save()
Expand Down