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

ENH: Add conditional to adapt behaviour depending on astropy version and warn user #73

Merged
merged 19 commits into from
Nov 3, 2021

Conversation

vandalt
Copy link
Contributor

@vandalt vandalt commented Nov 3, 2021

This is a follow-up for #60 by @neutrinoceros. As discussed there, I added a warning that commentary cards are removed. I also changed working version to 5.0rc1, the first release candidate with the upstream fix included. I also added tests to 1) check that the card is included in 5.0 and 2) Check that the warning is issued before 5.0.

@codecov
Copy link

codecov bot commented Nov 3, 2021

Codecov Report

Merging #73 (1e6d30c) into master (ccd3c68) will increase coverage by 0.32%.
The diff coverage is 97.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
+ Coverage   47.88%   48.21%   +0.32%     
==========================================
  Files          19       19              
  Lines        3621     3646      +25     
==========================================
+ Hits         1734     1758      +24     
- Misses       1887     1888       +1     
Flag Coverage Δ
unittests 48.21% <97.14%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
amical/tests/test_extraction.py 97.43% <96.15%> (-2.57%) ⬇️
amical/mf_pipeline/bispect.py 76.28% <100.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccd3c68...1e6d30c. Read the comment docs.

Copy link
Collaborator

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for continuing this work !
I made a couple suggestions to improve the tests, but in general I'm in favour of this simply superseding my own PR, so I'll close #60

amical/tests/test_extraction.py Outdated Show resolved Hide resolved
amical/tests/test_extraction.py Outdated Show resolved Hide resolved
amical/tests/test_extraction.py Outdated Show resolved Hide resolved
amical/mf_pipeline/bispect.py Outdated Show resolved Hide resolved
@neutrinoceros neutrinoceros linked an issue Nov 3, 2021 that may be closed by this pull request
@neutrinoceros neutrinoceros changed the title Add conditional to adapt behaviour depending on astropy version and warn user ENH: Add conditional to adapt behaviour depending on astropy version and warn user Nov 3, 2021
@neutrinoceros
Copy link
Collaborator

Another important thing is that we should test this properly using the pre release. I'll open a PR to do just that

@vandalt
Copy link
Contributor Author

vandalt commented Nov 3, 2021

Thanks @neutrinoceros ! For the first suggestion, I kept the two tests for now. I'm not opposed to removing the "drops" one. I have little experience with unit tests, so I'd let you decide what to do here. My initial idea was to test the behaviour because there is a warning related to it, so if the behaviour is fixed, a failing test would flag that the warning needs to be removed.

@neutrinoceros
Copy link
Collaborator

My initial idea was to test the behaviour because there is a warning related to it, so if the behaviour is fixed, a failing test would flag that the warning needs to be removed.

It's a good idea. In general, it's good to test failing cases, not just successes. Another rule of thumb is to avoid testing implementation details instead of behaviour, because it tends to rigidify the design, and it's a burden to maintain.

So ideally here we should have:

@neutrinoceros
Copy link
Collaborator

we're getting there, thank you for your patience @vandalt !

@vandalt
Copy link
Contributor Author

vandalt commented Nov 3, 2021

Thanks for your detailed comments @neutrinoceros ! I think I addressed all of them, but let me know if I forgot something or if there are others.

EDIT: Typo

Copy link
Collaborator

@neutrinoceros neutrinoceros left a comment

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 my final round of review. I apologies for misleading you into combining xfail and skipif, I realised while reading this that we should probably never have to use more than one.

amical/mf_pipeline/bispect.py Outdated Show resolved Hide resolved
amical/tests/test_extraction.py Outdated Show resolved Hide resolved
amical/tests/test_extraction.py Show resolved Hide resolved
amical/tests/test_extraction.py Outdated Show resolved Hide resolved
amical/tests/test_extraction.py Outdated Show resolved Hide resolved
amical/tests/test_extraction.py Outdated Show resolved Hide resolved
@neutrinoceros
Copy link
Collaborator

It'd be useful to run the "bleeding edge" job I just merged into master here, to check that your tests behave correctly with astropy's dev version.
Basically you'd need to rebase against the current state of the master branch and run the job manually on your fork. If you need help for that don't hesitate to ask

@vandalt
Copy link
Contributor Author

vandalt commented Nov 3, 2021

I rebased on master and also rebased the master of my fork on master. I'm not sure how to run the "bleeding edge" CI though. I did run pytest in a virtualenv with the 5.0rc1 version of astropy and all tests passed.

@neutrinoceros
Copy link
Collaborator

On your fork, go to the "Actions" section, select the job as shown, and click the "run workflow" you can see on the right (select the branch attached to this PR)
Screenshot 2021-11-03 at 16 19 14

@vandalt
Copy link
Contributor Author

vandalt commented Nov 3, 2021

Thanks, I had just figured out how to launch it, so it's running. However, all previous CI runs on my fork failed with the following error in the "Upload coverage to codecov" section:

{'detail': ErrorDetail(string='Could not find a repository, try using repo upload token', code='not_found')}

Does it mean I need to setup codecov on the fork ?

@neutrinoceros
Copy link
Collaborator

No you don't. Actually you could deactivate actions on your fork in general, it's not necessary.

@neutrinoceros
Copy link
Collaborator

so the job is here https://github.com/vandalt/AMICAL/runs/4094406054?check_suite_focus=true
it WILL fail because of Codecov, I just want to make sure it doesn't fail for a different reason

@vandalt
Copy link
Contributor Author

vandalt commented Nov 3, 2021

Indeed it did, but the tests worked as expected I think.
image
Or at least it gives the same result as my local virtualenv with astropy 5.

@neutrinoceros
Copy link
Collaborator

I confirm that the results are consistent with running locally with the release candidate. Hurray !
Now for one ultimate, and probably quick, round

reason="Munch cannot handle commentary cards for Astropy < 5.0",
)
def test_commentary_infos_keep(commentary_infos):
assert "HISTORY" in commentary_infos.hdr
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not understand why Codecov reports this as not hit. It runs on my machine whatever version of astropy I use. Any clue ? (not needed to get this merged)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No sorry... Works on my machine as well, and I don't know much about Codecov

Copy link
Collaborator

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

Alright, thanks again for your patience, I think this is mergeable now. I'll give you the opportunity to respond to my last suggestions and after that I'll push the button :-)

amical/tests/test_extraction.py Outdated Show resolved Hide resolved
vandalt and others added 2 commits November 3, 2021 12:22
Co-authored-by: Clément Robert <cr52@protonmail.com>
@neutrinoceros neutrinoceros merged commit dca5e07 into SAIL-Labs:master Nov 3, 2021
@vandalt
Copy link
Contributor Author

vandalt commented Nov 3, 2021

Thanks for the help on this @neutrinoceros. Sorry I was away today, so your last suggestion was accepted via mobile and the commit message is not very informative.

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.

Astropy commentary cards not handled by munch
2 participants