Skip to content

Commit 8eb445e

Browse files
Merge pull request #71 from nasa/cleanup
Tidying up the Repo
2 parents c7b13a9 + c9a3906 commit 8eb445e

17 files changed

Lines changed: 4989 additions & 22 deletions

File tree

.git-hooks/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ python .git-hooks/check-unused-dependencies.py --include-optional
7272

7373
# Exclude archived notebooks
7474
python .git-hooks/check-unused-dependencies.py --exclude-archived
75+
```
7576

7677
## Common Options
7778

.git-hooks/check-notebook-imports.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import ast
99
import sys
10+
import warnings
1011

1112
try:
1213
import tomllib # Python 3.11+
@@ -27,8 +28,21 @@
2728
)
2829

2930

31+
# Packages that are intentionally allowed but cannot or should not be declared
32+
# in pyproject.toml (local helper modules, platform-specific, proprietary, etc.)
33+
ALLOWLIST = {
34+
# Local helper modules shipped alongside notebooks
35+
"local_sageiii_plot",
36+
"tolnet_v01",
37+
# Proprietary / platform-specific (cannot be pip-installed)
38+
"arcpy",
39+
# Installed via !pip in notebook cells rather than as a project dependency
40+
"gnss_lib_py",
41+
}
42+
43+
3044
def load_allowed_packages() -> Set[str]:
31-
"""Load package names from pyproject.toml."""
45+
"""Load package names from pyproject.toml plus the static allowlist."""
3246
pyproject_path = Path("pyproject.toml")
3347

3448
if not pyproject_path.exists():
@@ -58,6 +72,9 @@ def load_allowed_packages() -> Set[str]:
5872
# Standard library (already lowercase, but be explicit)
5973
packages.update(get_stdlib_modules())
6074

75+
# Static allowlist for packages that can't be declared as dependencies
76+
packages.update(ALLOWLIST)
77+
6178
return packages
6279

6380

@@ -85,7 +102,10 @@ def extract_imports_from_code(code: str) -> Set[str]:
85102
imports = set()
86103

87104
try:
88-
tree = ast.parse(code)
105+
# Suppress SyntaxWarnings from invalid escape sequences in notebook code
106+
with warnings.catch_warnings():
107+
warnings.simplefilter("ignore", SyntaxWarning)
108+
tree = ast.parse(code)
89109
for node in ast.walk(tree):
90110
if isinstance(node, ast.Import):
91111
for alias in node.names:

.git-hooks/notebook_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def get_notebooks_from_args(args: argparse.Namespace) -> tuple[List[Path], str]:
261261

262262
if args.exclude_archived:
263263
exclude_patterns.append("archived")
264+
exclude_patterns.append("_archive")
264265

265266
if args.exclude_additional_drafts:
266267
exclude_patterns.append("additional_drafts")
@@ -272,6 +273,7 @@ def get_notebooks_from_args(args: argparse.Namespace) -> tuple[List[Path], str]:
272273
exclusions = []
273274
if args.exclude_archived:
274275
exclusions.append("archived")
276+
exclusions.append("_archive")
275277
if args.exclude_additional_drafts:
276278
exclusions.append("drafts")
277279
if exclusions:

.github/workflows/validate-pr.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "Validate Pull Request"
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
lint:
12+
name: Lint & format check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- uses: astral-sh/setup-uv@v6
18+
with:
19+
enable-cache: true
20+
21+
- name: Ruff lint
22+
run: uvx ruff check .
23+
24+
- name: Ruff format check
25+
run: uvx ruff format --check .
26+
27+
notebooks:
28+
name: Validate notebook structure
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v6
32+
33+
- uses: astral-sh/setup-uv@v6
34+
with:
35+
enable-cache: true
36+
37+
- run: uv sync --frozen
38+
39+
- name: Check notebook headers
40+
run: >
41+
uv run python .git-hooks/check-notebook-headers.py
42+
--all-notebooks --exclude-archived --exclude-additional-drafts
43+
44+
- name: Check notebook imports (advisory)
45+
run: >
46+
uv run python .git-hooks/check-notebook-imports.py
47+
--all-notebooks --exclude-archived --exclude-additional-drafts --warn-only
48+
49+
render:
50+
name: Quarto render (no deploy)
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v6
54+
55+
- uses: quarto-dev/quarto-actions/setup@v2
56+
57+
- uses: conda-incubator/setup-miniconda@v3
58+
with:
59+
activate-environment: quarto-env
60+
environment-file: environment.yml
61+
62+
- name: Render site
63+
uses: quarto-dev/quarto-actions/render@v2
64+
65+
- name: Upload rendered site
66+
if: always()
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: site-preview
70+
path: _site/
71+
retention-days: 5

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,25 @@ dmypy.json
139139
.DS_Store
140140

141141
index_files/*
142+
143+
# Data or notebook files at the top-level in the repository
144+
*.nc
145+
*.h5
146+
*.hdf
147+
*.csv
148+
*.json
149+
*.txt
150+
*.zip
151+
*.tar.gz
152+
*.ipynb
153+
154+
# Data and binary files in subdirectories (already blocked at top-level)
155+
**/*.nc
156+
**/*.h5
157+
**/*.hdf
158+
**/*.zip
159+
**/*.tar.gz
160+
**/*.gif
161+
162+
# Keep small reference images but block large ones by convention
163+
# (rely on PR review for image files)

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ci:
22
autoupdate_schedule: "monthly" # Like dependabot
33
autoupdate_commit_msg: "chore: update pre-commit hooks"
4-
autoupdate_branch: "develop"
4+
autoupdate_branch: "main"
55
autofix_prs: false # Comment "pre-commit.ci autofix" on a PR to trigger
66

77
default_language_version:

POWER/index.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "POWER Prediction Of Worldwide Energy Resources) Project resources"
2+
title: "POWER (Prediction Of Worldwide Energy Resources) Project resources"
33
date: last-modified
44
author: "Atmospheric Science Data Center (ASDC)"
55
---

README.md

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,68 @@
11
# Data Tutorials and User Services for the ASDC
22

3-
This GitHub page serves as a comprehensive resource for end users
4-
seeking guidance and instructions on
5-
working with data from select missions that are archived and distributed by
6-
the Atmospheric Science Data Center (ASDC).
7-
Its aim is to enhance the knowledge and proficiency of data users,
8-
enabling more effective usage of the valuable resources made available by ASDC.
9-
Through this transfer of expertise from ASDC to users, we hope to
10-
foster a collaborative environment that drives innovation and progress in space-related endeavors.
11-
12-
**View the rendered page [here](https://nasa.github.io/ASDC_Data_and_User_Services/).**
13-
14-
*This site is under active, open development. Stay tuned for more and ever-evolving content!*
3+
How-to guides, tutorials, and scripts for working with data from missions
4+
archived and distributed by NASA's
5+
[Atmospheric Science Data Center (ASDC)](https://www.earthdata.nasa.gov/centers/asdc-daac).
6+
The site covers CALIPSO, CERES, DSCOVR, MAIA, MISR, MOPITT, POWER, PREFIRE,
7+
SAGE III-ISS, STAQS, TEMPO, and TOLNet.
8+
9+
**Browse the rendered site: <https://nasa.github.io/ASDC_Data_and_User_Services/>**
10+
11+
*This site is under active, open development. Stay tuned for more and ever-evolving content!*
12+
13+
## Getting started (contributors)
14+
15+
You need [Python 3.10+](https://www.python.org/),
16+
[uv](https://docs.astral.sh/uv/), and
17+
[Quarto](https://quarto.org/docs/get-started/).
18+
19+
```bash
20+
git clone https://github.com/nasa/ASDC_Data_and_User_Services.git
21+
cd ASDC_Data_and_User_Services
22+
23+
uv sync # install Python dependencies
24+
pre-commit install # enable local quality checks on commit
25+
quarto preview # live-preview the site at localhost
26+
```
27+
28+
See the [Contributing Guide](https://nasa.github.io/ASDC_Data_and_User_Services/contributing.html)
29+
for notebook style and content guidelines.
30+
31+
### Environment files
32+
33+
This repo has two environment definitions. They serve different purposes:
34+
35+
| File | Managed by | Purpose |
36+
|------|------------|---------|
37+
| `pyproject.toml` / `uv.lock` | `uv` | **Local development.** All packages needed to run every notebook. Use `uv sync` to install. |
38+
| `environment.yml` | conda (CI only) | **Site builds.** Minimal Jupyter kernel so Quarto can render pre-executed notebooks. You should not need this locally. |
39+
40+
Quarto is configured with `freeze: true`, which means it never re-executes
41+
notebook code during a build. It converts the already-rendered `.ipynb` outputs
42+
straight to HTML. This keeps CI fast and avoids the need for data access
43+
credentials in the build environment.
44+
45+
### Pre-commit hooks
46+
47+
The pre-commit configuration runs on every commit:
48+
49+
- **gitleaks** — secret detection
50+
- **ruff** — Python linting and formatting
51+
- **markdown-link-check** — broken link detection
52+
- **check-notebook-headers** — validates required sections (summary, prerequisites, author)
53+
- **check-notebook-imports** — cross-references imports against `pyproject.toml` (warn-only)
54+
55+
See [`.git-hooks/README.md`](.git-hooks/README.md) for details on the custom
56+
notebook hooks.
57+
58+
## Data files
59+
60+
Notebooks should fetch data programmatically at runtime (e.g., via
61+
`earthaccess` or `harmony-py`) rather than committing data files to the
62+
repository. Large files such as `.nc`, `.hdf`, and `.h5` are not tracked
63+
by git and should stay that way.
64+
65+
## Questions or issues?
66+
67+
Open an [issue](https://github.com/nasa/ASDC_Data_and_User_Services/issues) or
68+
reach out via the [Earthdata Forum](https://forum.earthdata.nasa.gov/).
-13.9 MB
Binary file not shown.

TEMPO/Effect_of_Lightning_on_tropospheric_NO2/test_figures/readme

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)