Skip to content

Commit e468c0a

Browse files
Merge pull request #6 from nasa/implement-pre-commit
2 parents ce99ba1 + 8645d1d commit e468c0a

40 files changed

+6086
-4292
lines changed

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# For more information, see:
2+
# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
3+
4+
# Black code formatting of entire repository
5+
56dd43f69d901abbba6cfb765a98dee26ff71cfc

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ A short description of the changes in this PR.
1111
## PR Acceptance Checklist
1212
* [ ] Jira ticket acceptance criteria met.
1313
* [ ] `CHANGELOG.md` updated to include high level summary of PR changes.
14-
* [ ] `VERSION` updated if publishing a release.
14+
* [ ] `docker/service_version.txt` updated if publishing a release.
1515
* [ ] Tests added/updated and passing.
1616
* [ ] Documentation updated (if needed).

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-json
8+
- id: check-yaml
9+
- id: check-added-large-files
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.3.4
12+
hooks:
13+
- id: ruff
14+
args: ["--fix", "--show-fixes"]
15+
- repo: https://github.com/psf/black-pre-commit-mirror
16+
rev: 24.3.0
17+
hooks:
18+
- id: black-jupyter
19+
args: ["--skip-string-normalization"]
20+
language_version: python3.11

CHANGELOG.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
## v1.0.4
2+
### 2024-04-05
3+
4+
This version of HOSS implements `black` code formatting across the repository.
5+
There should be no functional changes in the service.
6+
17
## v1.0.3
2-
### 2024-3-29
8+
### 2024-03-29
39

4-
This version of HOSS handles the error in the crs_wkt attribute in ATL19 where the
5-
north polar crs variable has a leading iquotation mark escaped by back slash in the
6-
crs_wkt attribute. This causes errors when the projection is being interpreted from
7-
the crs variable attributes.
10+
This version of HOSS handles the error in the crs_wkt attribute in ATL19 where the
11+
north polar crs variable has a leading iquotation mark escaped by back slash in the
12+
crs_wkt attribute. This causes errors when the projection is being interpreted from
13+
the crs variable attributes.
814

915
## v1.0.2
10-
### 2024-2-26
16+
### 2024-02-26
1117

1218
This version of HOSS correctly handles edge-aligned geographic collections by
1319
adding the attribute `cell_alignment` with the value `edge` to `hoss_config.json`

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,39 @@ newest release of the code (starting at the top of the file).
240240
## vX.Y.Z
241241
```
242242

243+
### pre-commit hooks:
244+
245+
This repository uses [pre-commit](https://pre-commit.com/) to enable pre-commit
246+
checking the repository for some coding standard best practices. These include:
247+
248+
* Removing trailing whitespaces.
249+
* Removing blank lines at the end of a file.
250+
* JSON files have valid formats.
251+
* [ruff](https://github.com/astral-sh/ruff) Python linting checks.
252+
* [black](https://black.readthedocs.io/en/stable/index.html) Python code
253+
formatting checks.
254+
255+
To enable these checks:
256+
257+
```bash
258+
# Install pre-commit Python package as part of test requirements:
259+
pip install -r tests/pip_test_requirements.txt
260+
261+
# Install the git hook scripts:
262+
pre-commit install
263+
264+
# (Optional) Run against all files:
265+
pre-commit run --all-files
266+
```
267+
268+
When you try to make a new commit locally, `pre-commit` will automatically run.
269+
If any of the hooks detect non-compliance (e.g., trailing whitespace), that
270+
hook will state it failed, and also try to fix the issue. You will need to
271+
review and `git add` the changes before you can make a commit.
272+
273+
It is planned to implement additional hooks, possibly including tools such as
274+
`mypy`.
275+
243276
## Get in touch:
244277

245278
You can reach out to the maintainers of this repository via email:

docker/service_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.3
1+
1.0.4

docker/tests.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ENV PYTHONDONTWRITEBYTECODE=1
1616
COPY tests/pip_test_requirements.txt .
1717
RUN conda run --name hoss pip install --no-input -r pip_test_requirements.txt
1818

19-
# Copy test directory containing Python unittest suite, test data and utilities
19+
# Copy test directory containing Python unittest suite, test data and utilities
2020
COPY ./tests tests
2121

2222
# Set conda environment to hoss, as conda run will not stream logging.

docs/HOSS_DAAC_Operator_Documentation.ipynb

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@
170170
"metadata": {},
171171
"outputs": [],
172172
"source": [
173-
"temporal_range = {'start': datetime(2020, 1, 1, 0, 0, 0),\n",
174-
" 'stop': datetime(2020, 1, 31, 23, 59, 59)}"
173+
"temporal_range = {\n",
174+
" 'start': datetime(2020, 1, 1, 0, 0, 0),\n",
175+
" 'stop': datetime(2020, 1, 31, 23, 59, 59),\n",
176+
"}"
175177
]
176178
},
177179
{
@@ -273,14 +275,19 @@
273275
"outputs": [],
274276
"source": [
275277
"# Define the request:\n",
276-
"variable_subset_request = Request(collection=collection, variables=[variable_to_subset], max_results=1)\n",
278+
"variable_subset_request = Request(\n",
279+
" collection=collection, variables=[variable_to_subset], max_results=1\n",
280+
")\n",
277281
"\n",
278282
"# Submit the request and download the results\n",
279283
"variable_subset_job_id = harmony_client.submit(variable_subset_request)\n",
280284
"harmony_client.wait_for_processing(variable_subset_job_id, show_progress=True)\n",
281-
"variable_subset_outputs = [file_future.result()\n",
282-
" for file_future\n",
283-
" in harmony_client.download_all(variable_subset_job_id, overwrite=True)]\n",
285+
"variable_subset_outputs = [\n",
286+
" file_future.result()\n",
287+
" for file_future in harmony_client.download_all(\n",
288+
" variable_subset_job_id, overwrite=True\n",
289+
" )\n",
290+
"]\n",
284291
"\n",
285292
"replace(variable_subset_outputs[0], 'hoss_variable_subset.nc4')\n",
286293
"\n",
@@ -308,15 +315,22 @@
308315
"outputs": [],
309316
"source": [
310317
"# Define the request:\n",
311-
"temporal_subset_request = Request(collection=collection, temporal=temporal_range,\n",
312-
" variables=[variable_to_subset], max_results=1)\n",
318+
"temporal_subset_request = Request(\n",
319+
" collection=collection,\n",
320+
" temporal=temporal_range,\n",
321+
" variables=[variable_to_subset],\n",
322+
" max_results=1,\n",
323+
")\n",
313324
"\n",
314325
"# Submit the request and download the results\n",
315326
"temporal_subset_job_id = harmony_client.submit(temporal_subset_request)\n",
316327
"harmony_client.wait_for_processing(temporal_subset_job_id, show_progress=True)\n",
317-
"temporal_subset_outputs = [file_future.result()\n",
318-
" for file_future\n",
319-
" in harmony_client.download_all(temporal_subset_job_id, overwrite=True)]\n",
328+
"temporal_subset_outputs = [\n",
329+
" file_future.result()\n",
330+
" for file_future in harmony_client.download_all(\n",
331+
" temporal_subset_job_id, overwrite=True\n",
332+
" )\n",
333+
"]\n",
320334
"\n",
321335
"replace(temporal_subset_outputs[0], 'hoss_temporal_subset.nc4')\n",
322336
"\n",
@@ -351,14 +365,17 @@
351365
"outputs": [],
352366
"source": [
353367
"# Define the request:\n",
354-
"bbox_subset_request = Request(collection=collection, spatial=bounding_box, max_results=1)\n",
368+
"bbox_subset_request = Request(\n",
369+
" collection=collection, spatial=bounding_box, max_results=1\n",
370+
")\n",
355371
"\n",
356372
"# Submit the request and download the results\n",
357373
"bbox_subset_job_id = harmony_client.submit(bbox_subset_request)\n",
358374
"harmony_client.wait_for_processing(bbox_subset_job_id, show_progress=True)\n",
359-
"bbox_subset_outputs = [file_future.result()\n",
360-
" for file_future\n",
361-
" in harmony_client.download_all(bbox_subset_job_id, overwrite=True)]\n",
375+
"bbox_subset_outputs = [\n",
376+
" file_future.result()\n",
377+
" for file_future in harmony_client.download_all(bbox_subset_job_id, overwrite=True)\n",
378+
"]\n",
362379
"\n",
363380
"replace(bbox_subset_outputs[0], 'hoss_bbox_subset.nc4')\n",
364381
"\n",
@@ -389,14 +406,19 @@
389406
"outputs": [],
390407
"source": [
391408
"# Define the request:\n",
392-
"shape_file_subset_request = Request(collection=collection, shape='shape_files/bermuda_triangle.geo.json', max_results=1)\n",
409+
"shape_file_subset_request = Request(\n",
410+
" collection=collection, shape='shape_files/bermuda_triangle.geo.json', max_results=1\n",
411+
")\n",
393412
"\n",
394413
"# Submit the request and download the results\n",
395414
"shape_file_subset_job_id = harmony_client.submit(shape_file_subset_request)\n",
396415
"harmony_client.wait_for_processing(shape_file_subset_job_id, show_progress=True)\n",
397-
"shape_file_subset_outputs = [file_future.result()\n",
398-
" for file_future\n",
399-
" in harmony_client.download_all(shape_file_subset_job_id, overwrite=True)]\n",
416+
"shape_file_subset_outputs = [\n",
417+
" file_future.result()\n",
418+
" for file_future in harmony_client.download_all(\n",
419+
" shape_file_subset_job_id, overwrite=True\n",
420+
" )\n",
421+
"]\n",
400422
"\n",
401423
"replace(shape_file_subset_outputs[0], 'hoss_shape_file_subset.nc4')\n",
402424
"# Inspect the results:\n",

docs/HOSS_User_Documentation.ipynb

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,19 @@
127127
"source": [
128128
"variables = ['atmosphere_cloud_liquid_water_content']\n",
129129
"\n",
130-
"variable_subset_request = Request(collection=ghrc_collection, variables=variables, granule_id=[ghrc_granule_id])\n",
130+
"variable_subset_request = Request(\n",
131+
" collection=ghrc_collection, variables=variables, granule_id=[ghrc_granule_id]\n",
132+
")\n",
131133
"variable_subset_job_id = harmony_client.submit(variable_subset_request)\n",
132134
"\n",
133135
"print(f'Processing job: {variable_subset_job_id}')\n",
134136
"\n",
135-
"for filename in [file_future.result()\n",
136-
" for file_future\n",
137-
" in harmony_client.download_all(variable_subset_job_id, overwrite=True, directory=demo_directory)]:\n",
137+
"for filename in [\n",
138+
" file_future.result()\n",
139+
" for file_future in harmony_client.download_all(\n",
140+
" variable_subset_job_id, overwrite=True, directory=demo_directory\n",
141+
" )\n",
142+
"]:\n",
138143
" print(f'Downloaded: {filename}')"
139144
]
140145
},
@@ -157,14 +162,19 @@
157162
"source": [
158163
"gpm_bounding_box = BBox(w=45, s=-45, e=75, n=-15)\n",
159164
"\n",
160-
"bbox_request = Request(collection=gpm_collection, spatial=gpm_bounding_box, granule_id=[gpm_granule_id])\n",
165+
"bbox_request = Request(\n",
166+
" collection=gpm_collection, spatial=gpm_bounding_box, granule_id=[gpm_granule_id]\n",
167+
")\n",
161168
"bbox_job_id = harmony_client.submit(bbox_request)\n",
162169
"\n",
163170
"print(f'Processing job: {bbox_job_id}')\n",
164171
"\n",
165-
"for filename in [file_future.result()\n",
166-
" for file_future\n",
167-
" in harmony_client.download_all(bbox_job_id, overwrite=True, directory=demo_directory)]:\n",
172+
"for filename in [\n",
173+
" file_future.result()\n",
174+
" for file_future in harmony_client.download_all(\n",
175+
" bbox_job_id, overwrite=True, directory=demo_directory\n",
176+
" )\n",
177+
"]:\n",
168178
" print(f'Downloaded: {filename}')"
169179
]
170180
},
@@ -196,15 +206,22 @@
196206
"gpm_bounding_box = BBox(w=45, s=-45, e=75, n=-15)\n",
197207
"gpm_variables = ['/Grid/precipitationCal']\n",
198208
"\n",
199-
"combined_request = Request(collection=gpm_collection, spatial=gpm_bounding_box,\n",
200-
" granule_id=[gpm_granule_id], variables=gpm_variables)\n",
209+
"combined_request = Request(\n",
210+
" collection=gpm_collection,\n",
211+
" spatial=gpm_bounding_box,\n",
212+
" granule_id=[gpm_granule_id],\n",
213+
" variables=gpm_variables,\n",
214+
")\n",
201215
"combined_job_id = harmony_client.submit(combined_request)\n",
202216
"\n",
203217
"print(f'Processing job: {combined_job_id}')\n",
204218
"\n",
205-
"for filename in [file_future.result()\n",
206-
" for file_future\n",
207-
" in harmony_client.download_all(combined_job_id, overwrite=True, directory=demo_directory)]:\n",
219+
"for filename in [\n",
220+
" file_future.result()\n",
221+
" for file_future in harmony_client.download_all(\n",
222+
" combined_job_id, overwrite=True, directory=demo_directory\n",
223+
" )\n",
224+
"]:\n",
208225
" print(f'Downloaded: {filename}')"
209226
]
210227
},
@@ -229,14 +246,19 @@
229246
"source": [
230247
"ghrc_bounding_box = BBox(w=-30, s=-50, e=30, n=0)\n",
231248
"\n",
232-
"edge_request = Request(collection=ghrc_collection, spatial=ghrc_bounding_box, granule_id=[ghrc_granule_id])\n",
249+
"edge_request = Request(\n",
250+
" collection=ghrc_collection, spatial=ghrc_bounding_box, granule_id=[ghrc_granule_id]\n",
251+
")\n",
233252
"edge_job_id = harmony_client.submit(edge_request)\n",
234253
"\n",
235254
"print(f'Processing job: {edge_job_id}')\n",
236255
"\n",
237-
"for filename in [file_future.result()\n",
238-
" for file_future\n",
239-
" in harmony_client.download_all(edge_job_id, overwrite=True, directory=demo_directory)]:\n",
256+
"for filename in [\n",
257+
" file_future.result()\n",
258+
" for file_future in harmony_client.download_all(\n",
259+
" edge_job_id, overwrite=True, directory=demo_directory\n",
260+
" )\n",
261+
"]:\n",
240262
" print(f'Downloaded: {filename}')"
241263
]
242264
},
@@ -268,15 +290,22 @@
268290
"point_in_pixel_box = BBox(w=43.2222, s=-25.1111, e=43.2222, n=-25.1111)\n",
269291
"gpm_variables = ['/Grid/precipitationCal']\n",
270292
"\n",
271-
"point_in_pixel_request = Request(collection=gpm_collection, spatial=point_in_pixel_box,\n",
272-
" granule_id=[gpm_granule_id], variables=gpm_variables)\n",
293+
"point_in_pixel_request = Request(\n",
294+
" collection=gpm_collection,\n",
295+
" spatial=point_in_pixel_box,\n",
296+
" granule_id=[gpm_granule_id],\n",
297+
" variables=gpm_variables,\n",
298+
")\n",
273299
"point_in_pixel_job_id = harmony_client.submit(point_in_pixel_request)\n",
274300
"\n",
275301
"print(f'Processing job: {point_in_pixel_job_id}')\n",
276302
"\n",
277-
"for filename in [file_future.result()\n",
278-
" for file_future\n",
279-
" in harmony_client.download_all(point_in_pixel_job_id, overwrite=True, directory=demo_directory)]:\n",
303+
"for filename in [\n",
304+
" file_future.result()\n",
305+
" for file_future in harmony_client.download_all(\n",
306+
" point_in_pixel_job_id, overwrite=True, directory=demo_directory\n",
307+
" )\n",
308+
"]:\n",
280309
" print(f'Downloaded: {filename}')"
281310
]
282311
},
@@ -298,15 +327,22 @@
298327
"corner_point_box = BBox(w=160, s=20, e=160, n=20)\n",
299328
"gpm_variables = ['/Grid/precipitationCal']\n",
300329
"\n",
301-
"corner_point_request = Request(collection=gpm_collection, spatial=corner_point_box,\n",
302-
" granule_id=[gpm_granule_id], variables=gpm_variables)\n",
330+
"corner_point_request = Request(\n",
331+
" collection=gpm_collection,\n",
332+
" spatial=corner_point_box,\n",
333+
" granule_id=[gpm_granule_id],\n",
334+
" variables=gpm_variables,\n",
335+
")\n",
303336
"corner_point_job_id = harmony_client.submit(corner_point_request)\n",
304337
"\n",
305338
"print(f'Processing job: {corner_point_job_id}')\n",
306339
"\n",
307-
"for filename in [file_future.result()\n",
308-
" for file_future\n",
309-
" in harmony_client.download_all(corner_point_job_id, overwrite=True, directory=demo_directory)]:\n",
340+
"for filename in [\n",
341+
" file_future.result()\n",
342+
" for file_future in harmony_client.download_all(\n",
343+
" corner_point_job_id, overwrite=True, directory=demo_directory\n",
344+
" )\n",
345+
"]:\n",
310346
" print(f'Downloaded: {filename}')"
311347
]
312348
}

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#
1+
#
22
# These requirements are used by the documentation Jupyter notebooks in the
33
# harmony-opendap-subsetter/docs directory.
44
#

0 commit comments

Comments
 (0)