Skip to content

Commit a9a9234

Browse files
committed
Merge branch 'main' into dmr-adapter
2 parents dde9c57 + f6e2b72 commit a9a9234

File tree

6 files changed

+182
-59
lines changed

6 files changed

+182
-59
lines changed

.github/workflows/integration-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
name: Integration Tests
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- .github/workflows/integration-test*.yml
9+
- earthaccess/**
10+
- scripts/integration-test.sh
11+
- tests/**
12+
- uv.lock
413
pull_request:
514
branches:
615
- main

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ and this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
77

88
## [Unreleased]
99

10+
## [v0.12.0] - 2024-11-13
11+
1012
### Changed
1113

14+
- Refactored our development guide to clarify development environment setup and how to run tests
15+
([@jhkennedy](https://github.com/jhkennedy))
1216
- Use built-in `assert` statements instead of `unittest` assertions in
1317
integration tests ([#743](https://github.com/nsidc/earthaccess/issues/743))
1418
([@chuckwondo](https://github.com/chuckwondo))
@@ -650,7 +654,8 @@ _Conception!_
650654
- Add basic classes to interact with NASA CMR, EDL and cloud access.
651655
- Basic object formatting.
652656

653-
[Unreleased]: https://github.com/nsidc/earthaccess/compare/v0.11.0...HEAD
657+
[Unreleased]: https://github.com/nsidc/earthaccess/compare/v0.12.0...HEAD
658+
[0.12.0]: https://github.com/nsidc/earthaccess/compare/v0.11.0...v0.12.0
654659
[0.11.0]: https://github.com/nsidc/earthaccess/releases/tag/v0.11.0
655660
[0.10.0]: https://github.com/nsidc/earthaccess/releases/tag/v0.10.0
656661
[0.9.0]: https://github.com/nsidc/earthaccess/releases/tag/v0.9.0

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ keywords:
2626
url: "https://earthaccess.readthedocs.io"
2727
repository-code: "https://github.com/nsidc/earthaccess"
2828

29-
version: "0.11.0"
30-
date-released: "2024-10-01"
29+
version: "0.12.0"
30+
date-released: "2024-11-13"
3131

3232
authors:
3333
- family-names: "Barrett"

docs/contributing/development.md

Lines changed: 147 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,105 @@
77
```bash
88
git clone [email protected]:{my-username}/earthaccess
99
```
10+
1. We recommend creating a feature branch when developing new features, fixing bugs, updating docs, etc. It's best to give the branch
11+
a descriptive name For example, if you're updating the contributing docs, you might create a branch called `update-contributing-docs`:
12+
```bash
13+
git switch -c update-contributing-docs
14+
```
1015

11-
In order to develop new features or fix bugs etc. we need to set up a virtual
16+
Next, In order to develop new features or fix bugs etc., you'll need to set up a virtual
1217
environment and install the library locally.
1318

14-
## Quickstart development
19+
## Development environment setup
1520

16-
The fastest way to start with development is to use nox. If you don't have nox,
17-
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
18-
If you don't have pipx (pip for applications), then you can install with
19-
`pip install pipx` (the only case were installing an application with regular
20-
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
21-
`brew install pipx nox`.
2221

23-
To use, run `nox` without any arguments. This will run the type check and unit
24-
test "sessions" (tasks) using your local (and active) Python version.
25-
Nox handles everything for you, including setting up a temporary virtual
26-
environment for each run.
22+
There are a few options for setting up a development environment; you can use Python's `venv`, use `conda`/`mamba`, or _not_
23+
manage one yourself and use `pipx` to run tests and build docs with `nox`.
2724

28-
You can see all available sessions with `nox --list`:
25+
* If you're a Windows user, you'll likely want to set up an environment yourself with `conda`/`mamba`.
26+
* If you're working in a JupyterHub, you'll likely want to set up an environment yourself with `conda`/`mamba`.
27+
* If you're using an IDE like VS Code or PyCharm, you'll likely want to set up an environment yourself with `venv` or `conda`/`mamba`.
28+
* If you're using a plain text editor and don't know how to or want to manage a virtual environment, you'll likely want to start with `pipx`.
29+
30+
=== "`venv`"
31+
32+
`venv` is a virtual environment manager that's built into Python.
33+
34+
Create and activate the development environment with:
35+
36+
```bash
37+
python -m venv .venv
38+
source .venv/bin/activate
39+
```
40+
41+
Then install `earthaccess` into the environment in editable mode with the optional development dependencies:
42+
43+
```bash
44+
python -m pip install --editable ".[dev,test,docs]"
45+
```
46+
47+
=== "`conda`/`mamba`"
48+
49+
`conda` and `mamba` are open-source package and environment managers that are language and platform agnostic.
50+
`mamba` is a newer and faster re-implementation of `conda` -- you can use either `conda` or `mamba`
51+
in the commands below.
52+
53+
After you have followed [the `conda`/`mamba` installation instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) (we recommend Miniforge), you can create and activate the development environment with:
54+
55+
```bash
56+
mamba env update -f environment.yml
57+
mamba activate earthaccess
58+
```
59+
60+
This will ensure the `earthaccess` environment exists and is up-to-date, and active it. The `earthaccess` package will
61+
be installed into the environment in editable mode with the optional development dependencies.
62+
63+
??? note "2024-09-23: Conda environment name changed from `earthaccess-dev` -> `earthaccess`"
64+
65+
On Sept. 23, 2024, the name of the conda environment changed from `earthaccess-dev` to `earthacess` to align with
66+
community best practices. If you have an `earthaccess-dev` environment, we recommend deleting it and creating a new one.
67+
From the repository root, you can do that with these commands:
68+
69+
```bash
70+
mamba env update -f environment.yml
71+
mamba activate earthaccess
72+
mamba env remove -n earthaccess-dev
73+
```
74+
75+
=== "`pipx`+`nox`"
76+
77+
`pipx` is a tool to help you install and run end-user applications written in Python and `nox` is Python application
78+
that automates testing in multiple Python environments. By using `pipx` to install `nox` and using `nox` to run common development tasks, some users can avoid the need to set up and manage a full development environment.
79+
Once you have [installed `pipx` following the official instructions](https://github.com/pypa/pipx?tab=readme-ov-file#install-pipx), you can either run `nox` without installing it via:
80+
81+
```bash
82+
pipx run nox [NOX_ARGS]
83+
```
2984

85+
or install `nox` into an isolated environment and run it with:
86+
87+
```bash
88+
pipx install nox
89+
nox [NOX_ARGS]
90+
```
91+
92+
`nox` handles everything for you, including setting up a temporary virtual environment for each task (e.g. running tests, building docs, etc.) you need to run.
93+
94+
Now that your development environment is set up, you can run the tests.
95+
96+
## Running tests
97+
98+
We recommend using `nox` to run the various "sessions" (`nox`'s term for tasks) provided by `earthaccess`. To use, run `nox` without
99+
any arguments:
100+
101+
```bash
102+
nox
103+
```
104+
105+
This will run the type check and unit test sessions using your local (and active) Python
106+
version. `nox` handles everything for you, including setting up a temporary virtual environment for each run.
107+
108+
You can see all available sessions with `nox --list`:
30109
```
31110
$ nox --list
32111
Sessions defined in earthaccess/noxfile.py:
@@ -41,8 +120,7 @@ Sessions defined in earthaccess/noxfile.py:
41120
sessions marked with * are selected, sessions marked with - are skipped.
42121
```
43122

44-
You can also run individual tasks (_sessions_ in `nox` parlance, hence the `-s`
45-
option below), like so:
123+
You can also run individual sessions like so:
46124

47125
```bash
48126
nox -s integration-tests
@@ -54,57 +132,74 @@ and pass options to the underlying session like:
54132
nox -s integration-tests -- [ARGS]
55133
```
56134

57-
!!! tip
58-
59-
In order to run integration tests locally, you must set the
60-
environment variables `EARTHDATA_USERNAME` and `EARTHDATA_PASSWORD` to your
61-
username and password, respectively, of your
62-
[NASA Earthdata](https://urs.earthdata.nasa.gov/) account (registration is
63-
free).
64-
65-
135+
!!! info "Important"
66136

67-
## Manual development environment setup
137+
In order to run integration tests locally, you must set the environment variables `EARTHDATA_USERNAME` and
138+
`EARTHDATA_PASSWORD` to the username and password of your [NASA Earthdata](https://urs.earthdata.nasa.gov/)
139+
account, respectively (registration is free).
68140

69-
While `nox` is the fastest way to get started, you will likely need a full
70-
development environment for making code contributions, for example to test in a
71-
REPL, or to resolve references in your favorite IDE. This development
72-
environment also includes `nox`. You can create it with `venv`, `conda`, or `mamba`.
141+
### IDE setup
73142

74-
=== "`venv`"
143+
Integrated development environments (IDEs) like VS Code and PyCharm provide powerful refactoring, testing, and
144+
debugging integrations, but they typically don't understand "task runners" like `nox` and won't know how to launch
145+
debugging or testing sessions connected to the provided integrations.
75146

76-
`venv` is a virtual environment manager that's built into Python.
147+
Fortunately, if you've set up a development environment you should be able to call the underlying testing tools
148+
(e.g., `mypy` and `pytest`) directly, or run them via your IDE integrations. To understand how `nox` is running the
149+
underlying tools in each test session you can read the `noxfile.py` in the repository root, or, run all the test directly
150+
in your development environment like:
77151

78-
Create and activate the development environment with:
152+
```bash
153+
nox -fb none --no-install
154+
```
79155

80-
```bash
81-
python -m venv .venv
82-
source .venv/bin/activate
83-
```
156+
This will force `nox` to not use an environment backend (will just use the active environment) and not attempt to install
157+
any packages. When `nox` runs, it will describe the commands it executes:
84158

85-
Then install `earthaccess` into the environment in editable mode with the optional development dependencies:
159+
```
160+
$ nox -fb none --no-install
161+
nox > Running session typecheck
162+
nox > mypy
163+
Success: no issues found in 35 source files
164+
nox > Session typecheck was successful.
165+
nox > Running session tests
166+
nox > pytest tests/unit -rxXs
167+
========================================== test session starts ==========================================
168+
...
169+
==================================== 43 passed, 1 xfailed in 24.01s =====================================
170+
nox > Session tests was successful.
171+
nox > Ran multiple sessions:
172+
nox > * typecheck: success
173+
nox > * tests: success
174+
```
86175

87-
```bash
88-
python -m pip install --editable ".[dev,test,docs]"
89-
```
176+
Note these lines in particular:
90177

178+
```
179+
nox > Running session typecheck
180+
nox > mypy
181+
nox > Running session tests
182+
nox > pytest tests/unit -rxXs
183+
```
91184

92-
=== "`conda`/`mamba`"
185+
So to reproduce the typecheck session all you have to do is run `mypy` in your development environment. Similarly, reproducing
186+
the unit tests is running `pytest test/unit -rxXs`.
93187

94-
`conda` and `mamba` are open-source package and environment managers that are language and platform agnostic.
95-
`mamba` is a newer and faster re-implementation of `conda` -- you can use either `conda` or `mamba`
96-
in the commands below.
188+
Since we're not doing any complicated configuration or setting complicated arguments to pytest, simply hitting the "play" button
189+
for a pytest in your IDE should work once you've configured it to use your development environment.
97190

98-
Create and activate the development environment with:
191+
!!! info "Important"
99192

193+
Currently, our integration tests are *flakey* and a small number of random failures are expected. When the integration
194+
test suite runs, it may return a status code of 99 if the failure rate was less than an "acceptable" threshold. Since
195+
any non-zero status code is considered an error, your console and/or IDE will consider this a failure by default.
196+
`nox`, however, knows about this special status code and will report a success. To get pytest or your IDE to match
197+
this behavior, you can modify the special status code to be zero with the `EARTHACCESS_ALLOWABLE_FAILURE_STATUS_CODE`
198+
evnironment variable:
100199
```bash
101-
mamba env update -f environment.yml
102-
mamba activate earthaccess
200+
export EARTHACCESS_ALLOWABLE_FAILURE_STATUS_CODE=0
103201
```
104202

105-
This will update (or create if missing) the `earthaccess` environment and active it. The `earthaccess` package will
106-
be installed into the environment in editable mode with the optional development dependencies.
107-
108203
## Managing Dependencies
109204

110205
If you need to add a new dependency, edit `pyproject.toml` and insert the
@@ -134,14 +229,14 @@ Since `python-cmr` exposes the `cmr` package, the stubs appear under `stubs/cmr`
134229
To work on documentation locally, we provide a script that will automatically re-render the docs when you make changes:
135230

136231
```
137-
nox -s serve_docs
232+
nox -s serve-docs
138233
```
139234

140235
MkDocs does not support incremental rebuilds and will execute every Jupyter Notebook every time it builds a new
141236
version of the site, which can be quite slow. To speed up the build, you can pass MkDocs these options:
142237

143238
```
144-
nox -s serve_docs -- --dirty --no-strict
239+
nox -s serve-docs -- --dirty --no-strict
145240
```
146241

147242
!!! warning

docs/css/styles.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
.details .open {
22
}
3+
4+
.tabbed-set {
5+
padding: 5px;
6+
border: 1px lightgrey;
7+
border-radius: 2px;
8+
border-style: solid;
9+
}

pyproject.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "earthaccess"
7-
version = "0.11.0"
7+
version = "0.12.0"
88
description = "Client library for NASA Earthdata APIs"
99
authors = [
1010
{name = "earthaccess contributors"}
@@ -180,7 +180,7 @@ combine-as-imports = true
180180
convention = "google"
181181

182182
[tool.bumpversion]
183-
current_version = "0.11.0"
183+
current_version = "0.12.0"
184184
commit = false
185185
tag = false
186186
regex = true
@@ -192,8 +192,15 @@ replace = 'version = "{new_version}"'
192192

193193
[[tool.bumpversion.files]]
194194
filename = "CHANGELOG.md"
195-
search = "^## Unreleased$"
196-
replace = "## [v{new_version}] {now:%Y-%m-%d}"
195+
regex = true
196+
search = "^## \\[Unreleased\\]"
197+
replace = "## [Unreleased]\n\n## [v{new_version}] - {now:%Y-%m-%d}"
198+
199+
[[tool.bumpversion.files]]
200+
filename = "CHANGELOG.md"
201+
regex = true
202+
search = "\\[Unreleased\\]: (https://.+?)v{current_version}\\.\\.\\.HEAD"
203+
replace = "[Unreleased]: \\1v{new_version}...HEAD\n[{new_version}]: \\1v{current_version}...v{new_version}"
197204

198205
[[tool.bumpversion.files]]
199206
filename = "CITATION.cff"

0 commit comments

Comments
 (0)