-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from nsidc/tests-and-ci
Tests and ci
- Loading branch information
Showing
21 changed files
with
9,131 additions
and
818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
# Default to bash in login mode; key to activating conda environment | ||
# https://github.com/mamba-org/provision-with-micromamba#IMPORTANT | ||
defaults: | ||
run: | ||
shell: "bash -l {0}" | ||
|
||
jobs: | ||
test: | ||
name: "Run tests" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: "Check out repository" | ||
uses: "actions/checkout@v3" | ||
|
||
- name: "Install Conda environment" | ||
uses: "mamba-org/setup-micromamba@v1" | ||
with: | ||
environment-file: "conda-lock.yml" | ||
# When using a lock-file, we have to set an environment name. | ||
environment-name: "seaice_ecdr-ci" | ||
cache-environment: true | ||
# Increase this key to trigger cache invalidation | ||
cache-environment-key: 1 | ||
|
||
- name: "Check out pm_icecon repository" | ||
uses: "actions/checkout@v3" | ||
with: | ||
repository: "nsidc/pm_icecon" | ||
ref: "update_for_nise_cdr_cetb" | ||
path: "pm_icecon" | ||
|
||
- name: "Check out pm_tb_data repository" | ||
uses: "actions/checkout@v3" | ||
with: | ||
repository: "nsidc/pm_tb_data" | ||
ref: "main" | ||
path: "pm_tb_data" | ||
|
||
# Linter | ||
- name: "Run pre-commit tests" | ||
run: "pre-commit run --all-files" | ||
|
||
# Unit tests | ||
- name: "Run mypy" | ||
run: "PYTHONPATH=/home/runner/work/seaice_ecdr/seaice_ecdr/pm_icecon/:/home/runner/work/seaice_ecdr/seaice_ecdr/pm_tb_data/ mypy" | ||
|
||
# Unit tests | ||
# - name: "Run unit tests" | ||
# run: "PYTHONPATH=/home/runner/work/seaice_ecdr/seaice_ecdr/pm_icecon/:/home/runner/work/seaice_ecdr/seaice_ecdr/pm_tb_data/ python -m pytest seaice_ecdr/tests/unit/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
default_language_version: | ||
python: "python3.10" | ||
|
||
|
||
repos: | ||
|
||
- repo: "https://github.com/pre-commit/pre-commit-hooks" | ||
rev: "v4.4.0" | ||
hooks: | ||
- id: "check-added-large-files" | ||
- id: "check-vcs-permalinks" | ||
- id: "end-of-file-fixer" | ||
|
||
- repo: "https://github.com/charliermarsh/ruff-pre-commit" | ||
rev: "v0.0.291" | ||
hooks: | ||
- id: "ruff" | ||
# NOTE: "--exit-non-zero-on-fix" is important for CI to function | ||
# correctly! | ||
args: ["--fix", "--exit-non-zero-on-fix"] | ||
|
||
- repo: "https://github.com/psf/black" | ||
rev: "23.9.1" | ||
hooks: | ||
- id: "black" | ||
|
||
- repo: "https://github.com/jendrikseipp/vulture" | ||
rev: "v2.9.1" | ||
hooks: | ||
- id: "vulture" |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
<p align="center"> | ||
<img alt="NSIDC logo" src="https://nsidc.org/themes/custom/nsidc/logo.svg" width="150" /> | ||
<p float="left" align="center"> | ||
<img alt="NSIDC logo" src="https://nsidc.org/themes/custom/nsidc/logo.svg" height="150" /> | ||
<img alt="NOAA@NSIDC logo" src="https://nsidc.org/sites/default/files/images/Logo/noaa_at_nsidc.png" height="150" /> | ||
<img alt="NASA logo" src="https://gpm.nasa.gov/sites/default/files/document_files/NASA-Logo-Large.png" height="150" /> | ||
</p> | ||
|
||
# Enhanced Sea Ice CDR | ||
|
||
# Enhanced SeaIce CDR | ||
Enhanced SeaIce CDR (ECDR) enables the creation of the 12.5km SeaIce CDR. | ||
|
||
Enhanced SeaIce CDR enables the creation of the 12.5km SeaIce CDR | ||
Please note that this repository is a work in progress and breaking changes are | ||
to be expected. Initial work on this repository is specific to NSIDC's internal | ||
systems and may not work as expected for external collaborators. | ||
|
||
|
||
## Level of Support | ||
|
@@ -17,34 +22,111 @@ See the [LICENSE](GENERAL) for details on permissions and warranties. Please con | |
[email protected] for more information. | ||
|
||
|
||
## Requirements | ||
## Requirements and installation | ||
|
||
The ]seaice_ecdr_vm repository](https://bitbucket.org/nsidc/seaice_ecdr_vm/src/main/) provides the NSIDC VM configuration for this project. | ||
This code relies on the python packages defined in the included | ||
`environment.yml` file. | ||
|
||
Use [conda](https://docs.conda.io/en/latest/) or | ||
[mamba](https://mamba.readthedocs.io/en/latest/index.html) to install the | ||
requirements: | ||
|
||
## Installation | ||
``` | ||
$ conda env create | ||
``` | ||
|
||
Clone the seaice_ecdr_vm repository and check out appropriate branches of pm_icecon and seaice_ecdr to install this package | ||
To activate the environment: | ||
|
||
``` | ||
$ conda activate pm_tb_data | ||
``` | ||
|
||
## Usage | ||
|
||
TODO | ||
|
||
## Development/contributing | ||
|
||
### For developers at NSIDC | ||
|
||
For developers at the NSIDC, the [seaice_ecdr_vm | ||
repository](https://bitbucket.org/nsidc/seaice_ecdr_vm/src/main/) provides the | ||
NSIDC VM configuration for this project. | ||
|
||
An initial copy of the pm_icecon "cdr" generation can be executed from the VM directory: | ||
|
||
~/seaice_ecdr/ | ||
`~/seaice_ecdr/` | ||
|
||
using the cli.sh command: | ||
|
||
``` | ||
./scripts/cli.sh bootstrap amsr2 --date 2022-08-01 --hemisphere north --output-dir /tmp/ --resolution 12 | ||
``` | ||
|
||
### Adding dependencies | ||
|
||
To add new dependencies to this project, update the `environment.yml` file with | ||
the new dependency. Then update your conda environment: | ||
|
||
``` | ||
$ mamba env update | ||
``` | ||
|
||
Once the conda environment has been updated, lock the environment using `conda-lock`: | ||
|
||
``` | ||
$ conda-lock | ||
``` | ||
|
||
Commit the changes for the `environment.yml` and the `conda-lock.yml` files. | ||
|
||
|
||
### Running tests/CI | ||
|
||
#### Linting / formatting | ||
This project uses [pre-commit](https://pre-commit.com/) to run pre-commit hooks | ||
that check and format this project's code for stylistic consistency (using | ||
`ruff` and `black`) . | ||
|
||
The pre-commit configuration for this project can be found in | ||
`.pre-commit-config.yaml`. Configuration for specific tools (e.g., `mypy`) is | ||
given in the included `pyproject.toml`. | ||
|
||
For more information about using `pre-commit`, please sese the [Scientific | ||
Python Library Development Guide's section on | ||
pre-commit](https://learn.scientific-python.org/development/guides/gha-basic/#pre-commit). | ||
|
||
To install pre-commit to run checks for each commit you make: | ||
|
||
``` | ||
$ pre-commit install | ||
``` | ||
|
||
To manually run the pre-commit hooks without a commit: | ||
|
||
``` | ||
$ pre-commit run --all-files | ||
``` | ||
|
||
#### Running unit tests | ||
|
||
Use `pytest` to run unit tests: | ||
|
||
``` | ||
$ python -m pytest | ||
``` | ||
|
||
#### Type-checking | ||
|
||
## Troubleshooting | ||
Use `mypy` to run static typechecking | ||
|
||
No specific troubleshooting suggestions are currently available. | ||
``` | ||
$ mypy | ||
``` | ||
|
||
## License | ||
|
||
See [LICENSE](GENERAL). | ||
See [LICENSE](LICENSE). | ||
|
||
|
||
## Code of Conduct | ||
|
@@ -54,5 +136,5 @@ See [Code of Conduct](CODE_OF_CONDUCT.md). | |
|
||
## Credit | ||
|
||
This content was developed by the National Snow and Ice Data Center with funding from | ||
multiple sources. | ||
This software was developed by the National Snow and Ice Data Center with | ||
funding from NASA and NOAA. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.