Skip to content

Conversation

@geoffwoollard
Copy link
Contributor

Some notes on what I did that deserve a closer look

  1. Badges in README.md. What am I supposed to use for the links at the top of https://raw.githubusercontent.com/compSPI/reduceSPI/master/README.md

  2. reduceSPI just has tests in tests/test_*.py. However ioSPI has tests/test_*.py and also tests/test_iotools/test_*.py. What should be in ioSPI/ci_codecov/pytest.ini to handle the extra folder? geoffwoollard@b668095

  3. I took the isort and black transformers out of .deepsource.toml geoffwoollard@d99cc15

  4. .codecov.yml has an extra part to ignore folders that are absent in reduceSPI. I removed coverage folder because its empty in ioSPI and absent in reduceSPI. geoffwoollard@1980c1e

  5. .github/workflows/build.yml is quite a bit different. Note that the flags for black are absent. geoffwoollard@6311a51#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721L51 These were important to have the linting and testing pass.

  6. Aside: there's a folder iospi/iotools and also ioSPI/iotools/. They have different .py files in them. Is it supposed to be like that?

@geoffwoollard
Copy link
Contributor Author

geoffwoollard commented Oct 5, 2021

I'm struggling to satisfy isort/flake8/black at the same time. what is the workflow? I'm isorting, but then flake8 has an issue

(ioSPI) dhcp-128-189-219-129:ioSPI gw$ isort /Users/gw/repos/ioSPI/tests/test_fourier.py
(ioSPI) dhcp-128-189-219-129:ioSPI gw$ git status
On branch ci_codecov
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   tests/test_fourier.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   tests/test_fourier.py

(ioSPI) dhcp-128-189-219-129:ioSPI gw$ git commit tests/test_fourier.py -m 'isorted'
Check for byte-order marker..............................................Passed
Check for case conflicts.................................................Passed
Check for merge conflicts................................................Passed
Check Yaml...........................................(no files to check)Skipped
Mixed line ending........................................................Passed
Don't commit to branch...................................................Passed
Check for added large files..............................................Passed
Trim Trailing Whitespace.................................................Passed
black....................................................................Passed
isort....................................................................Passed
blacken-docs.............................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/test_fourier.py:1:1: D100 Missing docstring in public module
tests/test_fourier.py:3:1: I202 Additional newline in a group of imports. 'from ioSPI import fourier' is identified as Third Party and 'import numpy' is identified as Third Party.

(ioSPI) dhcp-128-189-219-129:ioSPI gw$

Screen Shot 2021-10-04 at 6 18 00 PM

@geoffwoollard
Copy link
Contributor Author

geoffwoollard commented Oct 5, 2021

@ninamiolane
Copy link
Contributor

@geoffwoollard the pre-commit hook flake8 does not correct the files automatically, it is just failing. In this case, we need to write the error messages and address them. Here:

  • there is a docstring missing at the very top of the test_fourier.py file (isort cannot write a docstring on its own)
  • the second one is a bit weirder, it seems to say that you need an additional blank line before this ordeR? Did you try this?

Badges in README.md. What am I supposed to use for the links at the top of https://raw.githubusercontent.com/compSPI/reduceSPI/master/README.md

Does it work to just replace reduceSPI by ioSPI?

reduceSPI just has tests in tests/test_.py. However ioSPI has tests/test_.py and also tests/test_iotools/test_*.py. What should be in ioSPI/ci_codecov/pytest.ini to handle the extra folder? geoffwoollard/ioSPI@b668095

Let's use tests/test_*.py for now. We'll organize them in subfolders when we have more tests: bottom-up approach = we do it only when we need it.

I took the isort and black transformers out of .deepsource.toml geoffwoollard/ioSPI@d99cc15

Yay thanks.

.codecov.yml has an extra part to ignore folders that are absent in reduceSPI. I removed coverage folder because its empty in ioSPI and absent in reduceSPI. geoffwoollard/ioSPI@1980c1e

Cool. thanks.

.github/workflows/build.yml is quite a bit different. Note that the flags for black are absent. geoffwoollard/ioSPI@6311a51#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721L51 These were important to have the linting and testing pass.

OK!

Aside: there's a folder iospi/iotools and also ioSPI/iotools/. They have different .py files in them. Is it supposed to be like that?

No, it's not meant to be like this: ioSPI/iotools is redundant, since we know that we will have iotools in ioSPI. Let's use the bottom up approach again, and only have one ioSPI folder, with *.py modules in it. We'll subdivide this in subfolders when we need to (not before!).

@geoffwoollard
Copy link
Contributor Author

geoffwoollard commented Oct 5, 2021

The problem is that flake8 wants

import numpy as np
from ioSPI import fourier

And isort wants

import numpy as np

from ioSPI import fourier

When I commit with the hooks, isort changes things to

import numpy as np

from ioSPI import fourier

Then flake8 fails.

These links say I need to tell flake8 somehow that there should be a line between them, because ioSPI is local, not third party.
PyCQA/flake8-import-order#145
https://github.com/PyCQA/flake8-import-order#configuration

…tatement, otherwise tries to put together. But isort knows it is local so automatically edits
@geoffwoollard
Copy link
Contributor Author

Actually this works

import numpy as np

from ..ioSPI import fourier

@geoffwoollard
Copy link
Contributor Author

There is an issue with iospi and ioSPI. When I checked out the files inside iospi from the main branch, then went inside ioSPI. So now on my branch there is no iospi, only ioSPI folder. Hopefully it stays that way when I merge and there is only only the ioSPI folder and no more iospi.
Screen Shot 2021-10-04 at 9 03 53 PM

.flake8 Outdated
docstring-convention = numpy
import_order_style = smarkets
max-line-length = 88
extend-ignore = E203
Copy link
Contributor

Choose a reason for hiding this comment

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

@geoffwoollard how about adding I202 to the extend-ignore line?

…ts own __init__.py file and it can not go above that level to ioSPI
…are in the wrong order. 'import ioSPI.iotools.cryo_dataset' should be before 'import torch'
@geoffwoollard
Copy link
Contributor Author

I was really confused for a while that the CI couldn't find this module. Locally it was in ioSPI, but actually git saw it as in iospi. So I just copied it (cp, not git mv) and renamed it as cryodataset.py. 2b78842

(ioSPI) dhcp-128-189-219-129:iotools gw$ git mv cryo_dataset.py cryodataset.py
fatal: not under version control, source=ioSPI/iotools/cryo_dataset.py, destination=ioSPI/iotools/cryodataset.py

@geoffwoollard
Copy link
Contributor Author

@fredericpoitevin maybe you can write some tests for atomic_models.py?

----------- coverage: platform linux, python 3.9.5-final-0 -----------
Name                             Stmts   Miss  Cover   Missing
--------------------------------------------------------------
ioSPI/__init__.py                    1      0   100%
ioSPI/fourier.py                    67     17    75%   26-33, 54-61, 104
ioSPI/iotools/__init__.py            0      0   100%
ioSPI/iotools/atomic_models.py      51     35    31%   45, 47, 54, 76-80, 102-110, 127-134, 156-168
ioSPI/iotools/cryodataset.py        71     12    83%   36, 38-39, 47-50, 56-59, 87
--------------------------------------------------------------
TOTAL                              190     64    66%
Coverage XML written to file coverage.xml

FAIL Required test coverage of 90.0% not reached. Total coverage: 66.32%

============================= 15 passed in 12.03s ==============================
Error: Process completed with exit code 1.

@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@cf53c24). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 54ad298 differs from pull request most recent head a34d93f. Consider uploading reports for the commit a34d93f to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##             master      #19   +/-   ##
=========================================
  Coverage          ?   66.32%           
=========================================
  Files             ?        4           
  Lines             ?      190           
  Branches          ?        0           
=========================================
  Hits              ?      126           
  Misses            ?       64           
  Partials          ?        0           

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 cf53c24...a34d93f. Read the comment docs.

Copy link
Contributor

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

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

Looking good! We can merge this since most of it is working, and it will give us a chance to see if everything else is in place at the next PR.

But only if you can tackle the 90% code coverage threshold ASAP?

.codecov.yml Outdated
project:
default:
target: 90%
target: 50%
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be 90% though: this is the threshold under which the PR will not pass: we don't want a PR to pass if we don't have a least 90% of the code that is covered, i.e. tested by the unit-tests. Why the decrease here?

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 I'll see if I can write some tests for Fred's atomic_models.py

.codecov.yml Outdated
default:
# basic
target: 90%
target: 50%
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

ignore:
- "data"
- "coverage"
- "notebooks"
Copy link
Contributor

Choose a reason for hiding this comment

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

We will have to test the notebooks actually, but we can leave this for later I guess.

docstring-convention = numpy
import_order_style = smarkets
max-line-length = 88
extend-ignore = E203,I202,I100
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, what is I100? Do you know why I didn't need these exclude in reduceSPI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's very similar as I202, with the spacing between the imports. Flake does not know that ioSPI is local, and wants to put the imports together, while isort knows and splits them up. See 2d7e03c

In your tests you do https://github.com/compSPI/reduceSPI/blob/master/tests/test_offline.py#L3, but there is no other import like import numpy or something nearby. My guess is that you would have the same issue.

@geoffwoollard
Copy link
Contributor Author

I wrote some tests, but the CI is not happening? Where did they go?

@ninamiolane
Copy link
Contributor

Oh yeah, I had the same problem with reduceSPI at some point... and then it came back! I don't know what is happening, TBH it could be that github action is experiencing a bug, or latency?

Maybe let's try to merge this, and see what it gives on a new PR?

@ninamiolane
Copy link
Contributor

Oh lol, it's back x)

@geoffwoollard
Copy link
Contributor Author

There's some problem with the code coverage. I wrote tests for parts that is says aren't covered. They are special because they are @Jitted, so maybe there's some issue with that.

----------- coverage: platform linux, python 3.9.5-final-0 -----------
Name                             Stmts   Miss  Cover   Missing
--------------------------------------------------------------
ioSPI/__init__.py                    1      0   100%
ioSPI/fourier.py                    67     16    76%   26-33, 54-61
ioSPI/iotools/__init__.py            0      0   100%
ioSPI/iotools/atomic_models.py      51      1    98%   159
ioSPI/iotools/cryodataset.py        71     12    83%   36, 38-39, 47-50, 56-59, 87
--------------------------------------------------------------
TOTAL                              190     29    85%

The tests are https://github.com/geoffwoollard/ioSPI/blob/ci_codecov/tests/test_fourier.py#L51 and https://github.com/geoffwoollard/ioSPI/blob/ci_codecov/tests/test_fourier.py#L65

@ninamiolane
Copy link
Contributor

Let's merge and see what codecov says. Thanks for this 🎉

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.

2 participants