Skip to content

Upgrade rose edit to Python 3 #2808

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

Open
wants to merge 50 commits into
base: master
Choose a base branch
from

Conversation

astroDimitrios
Copy link
Contributor

@astroDimitrios astroDimitrios commented Sep 10, 2024

As discussed this change updates rose config-edit (or just rose edit) to Python 3 / Gtk3.

  • First commit having run 2to3 and Pygobject over the old code 6a49dd7
  • Same for the gtk dir 8bccdcf
  • Splash screen updates 20ade08
  • Popup fixes in the MenuWidget 807bc56
  • Fix macro menus ed0780e

All seems to function par some cosmetic bugs which are outlined in the Issues on my fork.

@oliver-sanders oliver-sanders added this to the 2.4.0 milestone Sep 11, 2024
@astroDimitrios astroDimitrios marked this pull request as ready for review October 29, 2024 15:58
@oliver-sanders oliver-sanders self-requested a review October 31, 2024 11:06
@oliver-sanders

This comment was marked as outdated.

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made a first pass over the code, looking good.

There's 186 commits here! We could do with squashing these down a bit to make it a bit more manageable.

@astroDimitrios astroDimitrios force-pushed the feature/rose-config-py3 branch 3 times, most recently from 5684ff9 to 4cf6267 Compare November 27, 2024 13:11
@J-J-Abram J-J-Abram force-pushed the feature/rose-config-py3 branch from d7fb376 to 07cd350 Compare November 27, 2024 15:36
@astroDimitrios astroDimitrios force-pushed the feature/rose-config-py3 branch 4 times, most recently from c5a6ee7 to edd7db0 Compare November 27, 2024 17:54
@oliver-sanders oliver-sanders modified the milestones: 2.4.0, 2.5.0 Dec 3, 2024
@astroDimitrios astroDimitrios force-pushed the feature/rose-config-py3 branch from 8d1aef1 to f345292 Compare December 10, 2024 14:15
@oliver-sanders
Copy link
Member

There are some flaky tests lurking in the battery at the moment (nothing to do with this PR), the following Mac OS failures can be ignored:

  • 02-360day-cycling
  • 13-app-arch-cmd-out
  • 30-app-arch-opt-source

oliver-sanders

This comment was marked as outdated.

@astroDimitrios

This comment was marked as outdated.

@wxtim

This comment was marked as outdated.

@wxtim

This comment was marked as outdated.

@astroDimitrios astroDimitrios force-pushed the feature/rose-config-py3 branch 3 times, most recently from 44e54eb to 3704bd5 Compare January 16, 2025 13:43
Gtk.ResponseType.ACCEPT,
)
self.window = Gtk.Dialog(buttons=buttons)
self.set_transient_for(parent_window)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relates to bug 15:

Rose 2019 code

Suggested change
self.set_transient_for(parent_window)
self.window.set_transient_for(parent_window)

Comment on lines +115 to +117
column.pack_start(cell, True, True, 0)
else:
column.pack_start(cell, False, True, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that pack_start only takes 3 vars (including self.)

These extra variables arent in the old code and don't look like they match the reference material

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For long term reference, @astroDimitrios explained to me that pack_start can have 2 or 4 (non self) args depending on which widget the message is attached to. 😢

@astroDimitrios astroDimitrios force-pushed the feature/rose-config-py3 branch from ee95f20 to 6734a5e Compare April 2, 2025 13:17
@astroDimitrios

This comment was marked as outdated.

@@ -99,12 +99,17 @@ rosa = []
# Tornado 6.
# tornado
# ]
rose-edit = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(needs to match the metomi-rose[edit] below)

Suggested change
rose-edit = [
edit = [

@@ -99,12 +99,17 @@ rosa = []
# Tornado 6.
# tornado
# ]
rose-edit = [
"pygobject>=3.50.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This totally failed to pip install for me, but it worked when I conda installed pygobject.

Failure with pip:

Dependency 'gobject-introspection-1.0' is required but not found.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is to be expected.

It's the same as trying to pip install pygraphviz if you don't have graphviz itself installed. If you are installing from pip, then you need to satisfy the system dependencies yourself, otherwise pip-installation will likely fail.

@wxtim wxtim mentioned this pull request Apr 9, 2025
@wxtim
Copy link
Contributor

wxtim commented Apr 9, 2025

I've been through all the issues previously raised, and only 12, 15 are problems.

18 is the same as was too, but I think that the stash panel is out of scope of this PR.

I've created an issue where we can dump follow on, so that only essential for merge stuff goes in this PR:
#2884

I have not (yet) manually retested stuff.

Comment on lines +22 to +26
- pygobject >=3.50.0
- gtk3 >=3.24.43
- libgirepository >=1.84.0
- gobject-introspection >=1.84.0
- cairo >=1.18.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if all of these dependencies need to be listed here.

The pygobject feedstock on conda-forge has the following dependencies:

So libgirepository and cairo are dependencies of pygobject. Unless we need to specify a minimum version (for compatibility reasons), we can remove these as explicit dependencies of metomi-rose.


Is gobject-introspection necessary? Tim seems to be running fine without it, I think I got myself setup without installing this too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

  - pygobject >=3.50.0
  - gtk3 >=3.24.43

Dropping these dependencies:

  • libgirepository (transitive dependency)
  • cairo (transitive dependency)
  • gobject-introspection (developer tool?)

@wxtim
Copy link
Contributor

wxtim commented Apr 9, 2025

Re-review

Bugs

19. Array pulled to the right

When accessing 01-types/namelist/many_types/my_repeat_real_array (Applies to other arrays, but easiest to reproduce with this one because it's long to start with: Adding items to the array causes the array to stop wrapping at the edge of the screen, and to pull the view to the right, and keep pulling it to the right if you scroll left.

20. Enable/Ignore section

Enabling or ignoring a section which is already enabled or ignored causes traceback.

21. Create New Config

Right click on "suite info > create > create new configuration": Any input into the "new config name box gives:

AttributeError: 'Button' object has no attribute 'style'
Traceback (most recent call last):
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/gtk/dialog.py", line 628, in _name_checker
    good_colour = ok_button.style.text[Gtk.StateType.NORMAL]
                  ^^^^^^^^^^^^^^^

22. MacroChangesDialog._set_markup()

Priority - bad - I had to use ctrl-z to escape.

Error message "tasks 5 positional arguments but 6 were given - to access error navigate to `14-compulsory > right click compulsory_section > Auto-fix configuration.

23. Stash Widget: Menu Items

Using the UM with centralized metadata.

Pick any stash panel and right click on an item, click on remove:

  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/panelwidget/summary_data.py", line 639, in <lambda>
    "activate", lambda i: self.copy_section(this_section)
                          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/panelwidget/summary_data.py", line 846, in copy_section
    new_section = self.sub_ops.clone_section(section)
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/ops/group.py", line 546, in clone_section
    return self._clone_section_func(self.config_name, clone_section_name)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/ops/group.py", line 370, in copy_section
    new_namespace = self.sect_ops.add_section(
        config_name, new_section, skip_update=skip_update
    )
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/ops/section.py", line 122, in add_section
    self.trigger_reload_tree(ns)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/main.py", line 1259, in reload_namespace_tree
    self.nav_controller.reload_namespace_tree(*args, **kwargs)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/nav_controller.py", line 113, in reload_namespace_tree
    self.tree_trigger_update(
    ~~~~~~~~~~~~~~~~~~~~~~~~^
        only_this_config=only_this_config,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        only_this_namespace=only_this_namespace,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/main.py", line 1263, in tree_trigger_update
    self.updater.tree_trigger_update(*args, **kwargs)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/updater.py", line 148, in tree_trigger_update
    self.update_ns_sub_data(only_this_namespace)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/updater.py", line 303, in update_ns_sub_data
    page.update_sub_data()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/page.py", line 633, in update_sub_data
    self.sub_data_panel.update(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        self.sub_data["sections"], self.sub_data["variables"]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/panelwidget/summary_data.py", line 293, in update
    should_redraw = self.update_tree_model()
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/panelwidget/summary_data.py", line 211, in update_tree_model
    data_rows, column_names = self.get_model_data()
                              ~~~~~~~~~~~~~~~~~~~^^
  File "/home/users/tim.pillinger/repos/rose/metomi/rose/config_editor/plugin/um/widget/stash.py", line 214, in get_model_data
    sub_sect_names.sort(key=lambda x: section_sort_keys.get(x))
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'NoneType' and 'list'

if col_index == 0:
cell.set_property("visible", (len(model.get_path(r_iter)) == 1))

def _handle_treeview_activation(self, view, path, column):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column var used for?

text = self.MODE_TEXT[macro_mode]
return '<span foreground="{0}">{1}</span>'.format(colour, text)

def _set_markup(self, column, cell, model, r_iter, col_index):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column var used for?

tip.set_text(view.get_model().get_value(row_iter, col_index))
return True

def _set_type_markup(self, column, cell, model, r_iter, col_index):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column var used for?

dialog.destroy()
return None

def launch_prefs(self, somewidget=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this var do: somewidget=None?

if _path:
table.add_row(_path)

button.connect("clicked", lambda b: add_path())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
button.connect("clicked", lambda b: add_path())
button.connect("clicked", lambda _: add_path())

import metomi.rose.config
import metomi.rose.gtk.dialog
import metomi.rose.gtk.util
import metomi.rose.resource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used?

Comment on lines +21 to +35
import os
import re
import webbrowser

import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

import metomi.rose.config
import metomi.rose.gtk.dialog
import metomi.rose.gtk.util
import metomi.rose.resource

from functools import cmp_to_key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import os
import re
import webbrowser
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
import metomi.rose.config
import metomi.rose.gtk.dialog
import metomi.rose.gtk.util
import metomi.rose.resource
from functools import cmp_to_key
import gi
import os
import re
import webbrowser
from functools import cmp_to_key
import metomi.rose.config
import metomi.rose.gtk.dialog
import metomi.rose.gtk.util
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa:E402

Copy link
Contributor

@wxtim wxtim Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file actually get called anywhere? Analogy with other .*Widget classes would make me expect to find them in metomi/rose/config_editor/valuewidget/__init__.py.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file actually get called anywhere? Analogy with other .*Widget classes would make me expect to find them in metomi/rose/config_editor/valuewidget/init.py.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file actually get called anywhere? Analogy with other .*Widget classes would make me expect to find them in metomi/rose/config_editor/valuewidget/init.py.

# determine widget by presence of environment variables
if contains_env and (not m_type or m_type in NON_TEXT_TYPES or is_list):
# it is not safe to display the widget as intended due to an env var
if "\n" in value:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if "\n" in value:
if r"\n" in value:

@wxtim
Copy link
Contributor

wxtim commented Apr 11, 2025

Manual Testing

I've managed to achieve just under 78% coverage, though I think that there are sig chunks of code which are unreachable, or not covered by the demo, notably the stash panel.

I'm also not convinced that the Stash Widget is working at all.

@wxtim
Copy link
Contributor

wxtim commented Apr 14, 2025

Bug Summary

Note

Updated 2025-04-14
I've poured all previous outstanding bugs into this comment, and have checked the earlier bug list comments.

12. double_quoted_string_with_backslash

Severity: Should fix: Will be very annoying to anyone who has a backslash in a string.

Unclear from the docs whether this is a bug, but it certainly doesn't happen in the old version:

Try to change my_quoted to

Nothing
Something
Something with \n, \" or \\ in.
Traceback `IndexError`

@astroDimitrios Said

Needs fixing when entering a \ the focus jumps, this might be similar to the focus jumping bug when entering a char into an int field for example. In the commit 3f900b1 Fixes repeat real array bug where numbers were turned into strings / Fix validation errors causing focus jumping - removes quotation mark hot fix I changed the logic so that widget.needs_type_error_refresh() was called instead of completely re-drawing a new widget. That might also be the fix for this issue.

15. Metadata (menu) => upgrade => Traceback

Priority: Must Fix - shows traceback.

Traceback ![traceback](https://private-user-images.githubusercontent.com/26465611/403915044-bf586e79-80ff-478e-828d-67e0b28f670c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDQ2Mzg5NjIsIm5iZiI6MTc0NDYzODY2MiwicGF0aCI6Ii8yNjQ2NTYxMS80MDM5MTUwNDQtYmY1ODZlNzktODBmZi00NzhlLTgyOGQtNjdlMGIyOGY2NzBjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA0MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNDE0VDEzNTEwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2MDFhODg3MjBjZTA1Nzc4MGQ0NTI1YmI2MDMzYzQ1ZGU5MTlkNTI2YzI4YWEwMTNkMDkzNDQ4MjQ5OGMxN2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.yWd-bIX_zyi57zuYZZnxHGftmF4OGpmaLsi5oPaBLkg)

@astroDimitrios Said

is Menu related - this is broken in Old Rose with the test metadata as well. I have taken Tims suggestions from above but not committed them to the branch because you hit the path error he mentioned and it's not clear what has changed here from the usage of TreeView. You also hit a runtime error when trying to apply the upgrade (old rose breaks here with a better error message)

19. Array pulled to the right

Priority: Should fix - unbearably annoying if array > screen width.

When accessing 01-types/namelist/many_types/my_repeat_real_array (Applies to other arrays, but easiest to reproduce with this one because it's long to start with: Adding items to the array causes the array to stop wrapping at the edge of the screen, and to pull the view to the right, and keep pulling it to the right if you scroll left.

20. Enable/Ignore section

Priority: Should fix - causes traceback, but livable with because it only causes traceback if the user asks for something which doesn't make sense.

Enabling or ignoring a section in the Left hand tree view which is already enabled or ignored causes traceback.

21. Create New Config

Priority: Must fix: Traceback (Unclear how much this is used?)

Right click on "suite info > create > create new configuration": Any input into the "new config name box gives:

Traceback ``` AttributeError: 'Button' object has no attribute 'style' Traceback (most recent call last): File "/home/users/tim.pillinger/repos/rose/metomi/rose/gtk/dialog.py", line 628, in _name_checker good_colour = ok_button.style.text[Gtk.StateType.NORMAL] ^^^^^^^^^^^^^^^ ```

@oliver-sanders
Copy link
Member

oliver-sanders commented Apr 15, 2025

Thanks for the summary @wxtim. Looks like we have two show stoppers (15 & 21), a few major issues (but better than no GUI at all), and maybe some minor stuff.

  1. Metadata (menu) => upgrade => Traceback

@astroDimitrios commented that there seems to be an issue with the example in demo-metadata (or at least it causes a traceback with the old GUI too apparently), so isn't useful for comparison.

Here's an example (stolen from the tutorial) which does work with the old GUI (but sadly crashes on this branch):

meta=rose-demo-upgrade/garden0.1

[env]
FOREST=true

[namelist:features]
rose_bushes=2

@wxtim

This comment was marked as resolved.

@oliver-sanders
Copy link
Member

@wxtim, that issue has already been resolved in Rose 2 - #2737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants