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

GUI for Automated plotting #2414

Merged
merged 60 commits into from
Jul 25, 2024

Conversation

Preetam-Das26
Copy link
Contributor

Purpose of PR?:

Fixes #

Does this PR introduce a breaking change?

If the changes in this PR are manually verified, list down the scenarios covered::

Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Does this PR results in some Documentation changes?
If yes, include the list of Documentation changes

Checklist:

  • Bug fix. Fixes #
  • New feature (Non-API breaking changes that adds functionality)
  • PR Title follows the convention of <type>: <subject>
  • Commit has unit tests

ReimarBauer and others added 24 commits May 22, 2024 06:32
Occasionally the test runs on macos-13 are super slow and there is
generally a lot of variation in the time required to run the test suite
on those runners. I think they genuinely need more time sometimes, so
this increases the timeout to accommodate.
* Run flake8 for all .py files tracked in git

* Fix flake8 errors
this should keep it archived also when a server sets the threshold to a few years
* Add a codespell lint job

* Fix misspellings found by codespell
* updated data base migration to current release

* deprecation for manual migration added
`rtd.io` is on longer operational, according to [the project page](https://readthedocs.org/projects/mss/) the correct domain is either `rtfd.io` or the full `readthedocs.io`. Also switch to https.
* Fixed an issue with units being ignored in vertical axis
* Fixed an issue with *assuming* that vertical axis is in pressure if no
  standard name "air_pressure" was available
* Fixed an issue with extrapolating data
* Fixes an issue with interpolating in pressure instead of log-pressure
* Fixes an issue with ignoring jumps/extrapolation in data for missing
  longitudes (now it is consistent with vertical section driver)
* doc updated

* indenting level fixed

* add details about the wsgi modules
Copy link
Collaborator

@matrss matrss left a comment

Choose a reason for hiding this comment

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

It is unclear to me how this is supposed to be used.

I've tried loading the "mssautoplot.json" shared in Slack using the "cpath" button. There is no feedback on if that has worked or not, I would have expected some of the other widgets to be prefilled with content from that configuration.

When pressing the "Store plots directory" button after loading the configuration file, with or without first selecting some settings from the dropdowns, I get (an) "Invalid STYLE and/or URL requested" message(s) in the terminal and then the GUI just closes.

I also get those messages with python mslib/utils/mssautoplot.py --cpath mssautoplot.json as suggested by https://mss.readthedocs.io/en/stable/mssautoplot.html#examples, so maybe that is an issue on my end.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the file header from the template (adapt the copyright information therein): https://github.com/Open-MSS/MSS/blob/develop/new_file_template.py.

This isn't required for the other files, since they are tool-generated.

self.url.remove(i.text())
self.urlListWidget.takeItem(self.urlListWidget.row(i))

def layersWindow(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use snake_case for functions and methods as is idiomatic for python, unless something else is required by outside constraints (e.g. PyQt5 uses camelCase for its stuff, which is outside our control).

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should probably have a more descriptive name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Copy link
Member

Choose a reason for hiding this comment

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

@Preetam-Das26 this should get a better name

@Preetam-Das26
Copy link
Contributor Author

Preetam-Das26 commented Jul 4, 2024

I have not added the logging messages. I will do so in the next commit.
Please follow these steps:
1.Kindly fill the necessary parameters:
View
Cpath
Stime
Etime
Itime
Vtime
Interval
2. For login to the wms server:
Paste the wms server url provided in slack.
Next click on add and fill the username and password as mentioned in slack.
Again you have to click on add.
I think you are skipping this step.

Next click on store plots button.
Plots will be downloaded.

@matrss
Copy link
Collaborator

matrss commented Jul 5, 2024

I get an error when trying to add the WMS server URL:

Traceback (most recent call last):
  File "/home/icg149/Projects/MSS/mslib/utils/autoplot_gui.py", line 235, in addURL
    self.check_url_in_keyring(text)
  File "/home/icg149/Projects/MSS/mslib/utils/autoplot_gui.py", line 242, in check_url_in_keyring
    cred = keyring.get_credential(link, "")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/icg149/Projects/MSS/.pixi/envs/dev/lib/python3.11/site-packages/keyring/core.py", line 73, in get_credential
    return get_keyring().get_credential(service_name, username)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/icg149/Projects/MSS/.pixi/envs/dev/lib/python3.11/site-packages/keyring/backends/chainer.py", line 69, in get_credential
    credential = keyring.get_credential(service, username)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/icg149/Projects/MSS/.pixi/envs/dev/lib/python3.11/site-packages/keyring/backends/kwallet.py", line 125, in get_credential
    return super().get_credential(service, username)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/icg149/Projects/MSS/.pixi/envs/dev/lib/python3.11/site-packages/keyring/backend.py", line 143, in get_credential
    password = self.get_password(service, username)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/icg149/Projects/MSS/.pixi/envs/dev/lib/python3.11/site-packages/keyring/backends/kwallet.py", line 108, in get_password
    if not self.connected(service):
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/icg149/Projects/MSS/.pixi/envs/dev/lib/python3.11/site-packages/keyring/backends/kwallet.py", line 99, in connected
    raise InitError(f'Failed to open keyring: {e}.') from e
keyring.errors.InitError: Failed to open keyring: org.freedesktop.DBus.Error.ServiceUnknown: The name :1.19253 was not provided by any .service files.

We had this issue in the past already (#1815), you should be able to reuse the method from mslib.utils.auth instead of using keyring directly.

@swsrkty
Copy link
Collaborator

swsrkty commented Jul 5, 2024

When pressing the "Store plots directory" button after loading the configuration file, with or without first selecting some settings from the dropdowns, I get (an) "Invalid STYLE and/or URL requested" message(s) in the terminal and then the GUI just closes.
I also get those messages with python mslib/utils/mssautoplot.py --cpath mssautoplot.json as suggested by https://mss.readthedocs.io/en/stable/mssautoplot.html#examples, so maybe that is an issue on my end.

I'm able to get the plot from the GUI with the default configuration (by setting the cpath in the GUI and by leaving the other settings blank). The config shared by Preetam has a flight track file. Please try putting it in the root MSS directory if you haven't.

The error message "Invalid STYLE ....." is not correct as there's a correction to be made here which was pointed out by you sometime ago.

elif "404 Client Error" or "NOT FOUND for url" in e:
      print("Invalid STYLE and/or URL requested")

The 'elif' becomes true in all cases and thus the error message (#2295). I'll ask Preetam to push the corrected one with his code.

@ReimarBauer
Copy link
Member

the tests get triggered to show a problem https://github.com/Open-MSS/MSS/actions/runs/9810353386/job/27090313984?pr=2405#step:10:1129


[gw0] [100%] PASSED tests/_test_msui/test_mscolab.py::Test_Mscolab::test_profile_dialog Exception ignored in: <function WMSControlWidget.__del__ at 0x7f12d67293a0>
Traceback (most recent call last):
  File "/__w/MSS/MSS/mslib/msui/wms_control.py", line 544, in __del__
    self.service_cache()
  File "/__w/MSS/MSS/mslib/msui/wms_control.py", line 1438, in service_cache
    files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpg3phzpm3/msui/wms_cache/'
Exception ignored in: <function WMSControlWidget.__del__ at 0x7f12d67293a0>
Traceback (most recent call last):
  File "/__w/MSS/MSS/mslib/msui/wms_control.py", line 544, in __del__
    self.service_cache()
  File "/__w/MSS/MSS/mslib/msui/wms_control.py", line 1438, in service_cache
    files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpg3phzpm3/msui/wms_cache/'
Exception ignored in: <function WMSControlWidget.__del__ at 0x7f12d67293a0>
Traceback (most recent call last):
  File "/__w/MSS/MSS/mslib/msui/wms_control.py", line 544, in __del__
    self.service_cache()
  File "/__w/MSS/MSS/mslib/msui/wms_control.py", line 1438, in service_cache
    files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpg3phzpm3/msui/wms_cache/'

https://github.com/Open-MSS/MSS/actions/runs/9810353386/job/27090313984?pr=2405#step:10:1129

"""

mslib.utils.autoplot_gui
~~~~~~~~~~~~~~~~
Copy link
Member

@ReimarBauer ReimarBauer Jul 18, 2024

Choose a reason for hiding this comment

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

maybe font, but this needs samle length as the word in the line before

the name was changed, autoplot_dockwidget

fileName, _ = QFileDialog.getOpenFileName(
self, "Select .json Config File", const.MSUI_CONFIG_PATH, "JSON Files (*.json)", options=options)

if fileName:
Copy link
Member

Choose a reason for hiding this comment

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

is not None: ?

@@ -74,18 +74,96 @@ class MSUIDefaultConfig:

# Predefined map regions to be listed in the corresponding topview combobox
predefined_map_sections = {
"01 Europe (cyl)": {"CRS": "EPSG:4326",
Copy link
Member

Choose a reason for hiding this comment

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

This is the reason the test fails
test_kwargs_update_does_not_harm

@@ -74,18 +74,96 @@ class MSUIDefaultConfig:

# Predefined map regions to be listed in the corresponding topview combobox
predefined_map_sections = {
"01 Europe (cyl)": {"CRS": "EPSG:4326",
Copy link
Member

Choose a reason for hiding this comment

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

The position has changed
"07 Europe (cyl)":

Copy link
Member

Choose a reason for hiding this comment

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

changing that number also affects the tutorials https://github.com/Open-MSS/MSS/blob/develop/tutorials/tutorial_hexagoncontrol.py#L46

They look for the first element on the widget

Copy link
Member

@ReimarBauer ReimarBauer left a comment

Choose a reason for hiding this comment

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

see tutorials

@@ -46,7 +46,7 @@ def automate_kml():


def _switch_to_europe_map():
find_and_click_picture('topviewwindow-01-europe-cyl.png', "Map change dropdown could not be located on the screen.")
find_and_click_picture('topviewwindow-07-europe-cyl.png', "Map change dropdown could not be located on the screen.")
Copy link
Member

@ReimarBauer ReimarBauer Jul 23, 2024

Choose a reason for hiding this comment

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

this won't work

The image available is
topviewwindow-00-global-cyl.png

it can only find the first on screen visible value on a pulldown.

image

this can be verified by

$ export MSUI_CONFIG_PATH=/tmp/msui_tutorials
$ export XDG_CACHE_HOME=$(mktemp -d)
$ python
>>> from mslib.msui.msui import main
>>> main(tutorial_mode=True)
CTRL+H
CTRL+UP
CTRL+F
CTRL+Q
$ ls /tmp/msui-tutorials/tutorial_images/*00*.png 

topviewwindow-00-global-cyl

@Preetam-Das26 Preetam-Das26 marked this pull request as ready for review July 24, 2024 19:36
@swsrkty swsrkty merged commit a6c8e09 into Open-MSS:GSOC2024-PreetamSundarDas Jul 25, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants