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

how can unit tests and CI be added to the repo? #453

Open
edwardhartnett opened this issue Sep 4, 2024 · 3 comments
Open

how can unit tests and CI be added to the repo? #453

edwardhartnett opened this issue Sep 4, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@edwardhartnett
Copy link
Contributor

How can unit tests and CI be added to the repo?

There are shell scripts and python code.

Let's explore ways to add some unit testing.

@edwardhartnett
Copy link
Contributor Author

Unit tests are great to find bugs and program faster. But they do have a cost. Whereas the code problems detected by pylint/flake8 are free, requiring no more than that we look at the output and fix our code. See #456 for discussion.

I will continue adding a unit test to demonstrate; it may be that you want to have unit testing in place in some cases before fixing the problems detected by pylint.

@edwardhartnett
Copy link
Contributor Author

OK, if you take a look at my branch you will see the following (failing) test:

from exrrfs_process_glmfed import addmodelfed

def test_addmodelfed():
    addmodelfed(".")

This fails like this:

scripts/test_sample.py:5: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
scripts/exrrfs_process_glmfed.py:45: in addmodelfed
    u = nc.Dataset(corefile,'r')
src/netCDF4/_netCDF4.pyx:2470: in netCDF4._netCDF4.Dataset.__init__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   FileNotFoundError: [Errno 2] No such file or directory: '.fv_core.res.tile1.nc'

src/netCDF4/_netCDF4.pyx:2107: FileNotFoundError


I need a copy of the file:

corefile = restartpath+'fv_core.res.tile1.nc' # need diff names for ensembles?
Can you tell me where to find one of these files for testing?

@edwardhartnett
Copy link
Contributor Author

OK, we have begun our unit testing journey and that is very exciting. We now have a CI job which runs a flake8 test of the python code to check for syntax errors. If it passes, there are no syntax errors in the python code.

We have a long way to go, but that's a great start.

GitHub repo owners: you need to create a ruleset and apply it to the dev-sci branch. The ruleset should require that only PRs are used to update the branch, and that the flake8 tests must pass. Let me know if you need help setting this up, we have it on all the NCEPLIBS if you want to look.

As new error messages are added to the flake8 check, you'll get incrementally closer to clearing all flake8 warnings.

@edwardhartnett edwardhartnett self-assigned this Oct 2, 2024
@edwardhartnett edwardhartnett added the enhancement New feature or request label Oct 2, 2024
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

No branches or pull requests

1 participant