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

Update _widget_reader.py #108

Merged
merged 13 commits into from
Nov 30, 2023
Merged

Update _widget_reader.py #108

merged 13 commits into from
Nov 30, 2023

Conversation

TomasPetro
Copy link
Contributor

I've edited it and it should work (I've tested saving the data and then loading it from File->OpenFile). I did this for YtReader and TimeSeriesReader. But the validate_data_model function does not return the model only the JSON. I don't know if it bothers or not but I had a problem converting the returned model to JSON. Besides, there is a hardcoded $schema$ because without it I couldn't load JSON files and I didn't know where I could get it into the function.

@chrishavlin
Copy link
Collaborator

Thanks, @TomasPetro ! I should have time to look this over later in the week.

@chrishavlin chrishavlin linked an issue Nov 7, 2023 that may be closed by this pull request
@chrishavlin chrishavlin added this to the v0.3.0 milestone Nov 7, 2023
@chrishavlin chrishavlin added the enhancement New feature or request label Nov 7, 2023
Copy link
Collaborator

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

I was trying to figure out why the tests are stalling -- it's cause you added the QApplication instances. Napari handles all the main QT context, these need to be removed.

src/yt_napari/_widget_reader.py Outdated Show resolved Hide resolved
src/yt_napari/_widget_reader.py Outdated Show resolved Hide resolved
src/yt_napari/_widget_reader.py Outdated Show resolved Hide resolved
src/yt_napari/_widget_reader.py Outdated Show resolved Hide resolved
@chrishavlin
Copy link
Collaborator

also, if you type pre-commit.ci autofix on it's own in a comment then the pre-commit bot will try to fix the failing style checks.

TomasPetro and others added 4 commits November 7, 2023 22:35
remove Qapplucation

Co-authored-by: Chris Havlin <[email protected]>
remove Qapplication

Co-authored-by: Chris Havlin <[email protected]>
remove app.exec()

Co-authored-by: Chris Havlin <[email protected]>
remove app.exec()

Co-authored-by: Chris Havlin <[email protected]>
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8f3214f) 99.42% compared to head (fd614a9) 99.68%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   99.42%   99.68%   +0.25%     
==========================================
  Files          31       31              
  Lines        2431     2506      +75     
==========================================
+ Hits         2417     2498      +81     
+ Misses         14        8       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pre-commit.ci autofix
@TomasPetro
Copy link
Contributor Author

I looked at those comments and yes they were unnecessary features. I don't know why I put them there. I deleted them and tried them on my pc and everything went as before.

Copy link
Collaborator

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

Thanks for the nice work, @TomasPetro !

I left some comments with some small changes to how you're setting the "$schema" entry.

You'll also need to fix the failing style checks and add a new test.

style checks: you can read the full log here https://results.pre-commit.ci/run/github/448138442/1699393334.AOajljEzRPyJ5O8Rgft3mQ and manually fix the failures, or you can also type pre-commit.ci autofix on its own in a comment and the bot will try to fix it for you (you'd then want to pull the changes locally).

new test: I did checkout your branch locally to make sure it works (and it does!) but when adding new features we also need to add to the automated test suite. So this PR will need a new test in src/yt_napari/_tests/test_widget_reader.py. Adding tests for widget features can be a little tricky -- but you should be able to follow how the other tests are written to write a new one. In this case, I think the easiest route would be to monkeypatch the QFileDialog exec_() and selectedFiles() functions (see this link for how to monkeypatch with pytest).

src/yt_napari/_widget_reader.py Outdated Show resolved Hide resolved
src/yt_napari/_widget_reader.py Outdated Show resolved Hide resolved
@TomasPetro
Copy link
Contributor Author

@chrishavlin
So I installed tox but I'm currently having trouble running it. Tried to run it in different folders but it keeps throwing an error. Mostly similar. Are there other ways to run the tests or am I getting an error somewhere when running it?
image

@chrishavlin
Copy link
Collaborator

chrishavlin commented Nov 16, 2023

Oh, sorry, I must have some docs out of date. I don't really use tox anymore with yt-napari -- I just run pytest -v . to run the tests in my current environment and then rely on the github CI to make sure it passes with other systems and python versions.

Edit: Sorry, mixing up my repos. So yt-napari does still use tox. But I do still tend to just run pytest locally.

Second Edit: There is a typo in the yt-napari docs. You start tox with just tox, no need to specify a path.

@TomasPetro
Copy link
Contributor Author

Previously I tried pytest but i got there problem with qtbot. And even in those tests I didn't touch. In total I get 12 such errors. Do you know of any solution to this problem ?
image

@chrishavlin
Copy link
Collaborator

you'll need the pytest-qt plugin as well, pip install pytest-qt

@TomasPetro
Copy link
Contributor Author

Hi.
I'm currently working on tests but I've been troubleshooting the QfileDialog window that pops up when I save a json file for a few days.
I've tried qtbot etc but it didn't help and I still need to manually type the filename and then save. Do you know of any suitable implementation I could try ?
image

@chrishavlin
Copy link
Collaborator

I think the easiest approach will be to monkeypatch within pytest it so that you don't have to deal with the popup, see my comment up higher:

In this case, I think the easiest route would be to monkeypatch the QFileDialog exec_() and selectedFiles() functions (see this link for how to monkeypatch with pytest).

So you should be able to write a test that provides string inputs to provide a temporary filename and avoid the pop-up entirely.

@TomasPetro
Copy link
Contributor Author

pre-commit.ci autofix

@TomasPetro
Copy link
Contributor Author

Hi, so I wrote the tests. Will you take a look at it ? Currently it doesn't pass only codecs/patches but I didn't do anything with those functions on those lines.

@chrishavlin
Copy link
Collaborator

Great! Thanks @TomasPetro ! I should be able to look later today or tomorrow.

Copy link
Collaborator

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @TomasPetro ! I'll push up some changes to fix the coverage issues (as well as another couple small changes to the tests) and then this should be ready to merge.

@chrishavlin
Copy link
Collaborator

ok, that's annoying... patch coverage is still failing. I'll push up one more change and just tell coverage to skip those lines (they're unrelated to this PR, not sure why they're getting picked up).

@chrishavlin
Copy link
Collaborator

Thanks for the work on this, @TomasPetro !

@chrishavlin chrishavlin merged commit 9885ef5 into data-exp-lab:main Nov 30, 2023
15 checks passed
@TomasPetro
Copy link
Contributor Author

Nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

save json
2 participants