Skip to content

Commit 72ceac0

Browse files
committed
Clean up initial ACDD rules
Adds documentation for ACDD tests, isodate to the dependencies, and updates the changes.
1 parent 588df34 commit 72ceac0

File tree

15 files changed

+120
-27
lines changed

15 files changed

+120
-27
lines changed

CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# XRLint Change History
22

3+
## Upcoming
4+
5+
- Implements an initial set of [Attribute Conventions Data Discovery (ACCD)](https://wiki.esipfed.org/Category:Attribute_Conventions_Dataset_Discovery) rules adapted from the [IOOS Compliance Checker](https://github.com/ioos/compliance-checker/) library.
6+
- Configs for ACDD 1.0, 1.1, and 1.3, and with selectable levels of severity. The reccomended set uses ACDD 1.3 with the highly recomended rules as errors.
7+
- Global attribute existance rules.
8+
- Checks that ACDD is in the conventions attribute.
9+
- Makes sure the date attributes are ISO formatted.
10+
- Metadata links are URLs.
11+
- The ID attribute should not be blank.
12+
313
## Version 0.5.1 (from 2025-02-21)
414

515
- XRLint now also loads default configuration from files named

docs/rule-ref.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,75 @@ Time coordinate and dimension should be called 'time'.
199199

200200
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
201201

202+
## ACDD Rules
203+
204+
### :material-bug: `1.0-attrs-highly-recommended`
205+
206+
Global attributes that are highly reccomended by ACDD-1.0.
207+
[More...](https://wiki.esipfed.org/Category:Attribute_Conventions_Dataset_Discovery)
208+
209+
Contained in: `acdd_1.0`-:material-lightning-bolt:
210+
211+
### :material-bug: `1.0-attrs-recommended`
212+
213+
Global attributes that are recommended by ACDD-1.0.
214+
[More...](https://wiki.esipfed.org/Category:Attribute_Conventions_Dataset_Discovery)
215+
216+
Contained in: `acdd_1.0`-:material-alert:
217+
218+
### :material-bug: `1.0-attrs-suggested`
219+
220+
Global attributes that are suggested by ACDD-1.0.
221+
[More...](https://wiki.esipfed.org/Category:Attribute_Conventions_Dataset_Discovery)
222+
223+
Contained in: `acdd_1.0`-:material-alert:
224+
225+
### :material-bug: `1.3-attrs-highly-recommended`
226+
227+
Global attributes that are highly recommended by ACDD-1.3.
228+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
229+
230+
Contained in: `acdd_1.3`-:material-lightning-bolt: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-lightning-bolt: `acdd_1.3_warn`-:material-alert: `recommended`-:material-lightning-bolt:
231+
232+
### :material-bug: `1.3-attrs-recommended`
233+
234+
Global attributes that are recommended by ACDD-1.3.
235+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
236+
237+
Contained in: `acdd_1.3`-:material-alert: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-lightning-bolt: `acdd_1.3_warn`-:material-alert: `recommended`-:material-alert:
238+
239+
### :material-bug: `1.3-attrs-suggested`
240+
241+
Global attributes that are suggested by ACDD 1.3.
242+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
243+
244+
Contained in: `acdd_1.3`-:material-alert: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-alert: `acdd_1.3_warn`-:material-alert: `recommended`-:material-alert:
245+
246+
### :material-bug: `1.3-conventions`
247+
248+
The `Conventions` global attribute should include `ACDD-1.3`.
249+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
250+
251+
Contained in: `acdd_1.3`-:material-lightning-bolt: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-lightning-bolt: `acdd_1.3_warn`-:material-alert: `recommended`-:material-lightning-bolt:
252+
253+
### :material-bug: `1.3-dates-iso-format`
254+
255+
ACDD date attributes must be in ISO format.
256+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
257+
258+
Contained in: `acdd_1.3`-:material-alert: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-alert: `acdd_1.3_warn`-:material-alert: `recommended`-:material-alert:
259+
260+
### :material-bug: `1.3-metadata-link`
261+
262+
The `metadata` attribute should be a URL.
263+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
264+
265+
Contained in: `acdd_1.3`-:material-alert: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-alert: `acdd_1.3_warn`-:material-alert: `recommended`-:material-alert:
266+
267+
### :material-bug: `1.3-no-blanks-in-id`
268+
269+
The `id` attribute should not contain blanks.
270+
[More...](https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3)
271+
272+
Contained in: `acdd_1.3`-:material-alert: `acdd_1.3_strict`-:material-lightning-bolt: `acdd_1.3_strict_reccomended`-:material-alert: `acdd_1.3_warn`-:material-alert: `recommended`-:material-alert:
273+

mkruleref.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
def write_rule_ref_page():
2828
import xrlint.plugins.core
2929
import xrlint.plugins.xcube
30+
import xrlint.plugins.acdd
3031

3132
core = xrlint.plugins.core.export_plugin()
3233
xcube = xrlint.plugins.xcube.export_plugin()
34+
acdd = xrlint.plugins.acdd.export_plugin()
3335
with open("docs/rule-ref.md", "w") as stream:
3436
stream.write("# Rule Reference\n\n")
3537
stream.write(
@@ -41,6 +43,8 @@ def write_rule_ref_page():
4143
write_plugin_rules(stream, core)
4244
stream.write("## xcube Rules\n\n")
4345
write_plugin_rules(stream, xcube)
46+
stream.write("## ACDD Rules\n\n")
47+
write_plugin_rules(stream, acdd)
4448

4549

4650
def write_plugin_rules(stream, plugin: Plugin):

pyproject.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ build-backend = "setuptools.build_meta"
66
name = "xrlint"
77
dynamic = ["version", "readme"]
88
authors = [
9-
{name = "Norman Fomferra (Brockmann Consult GmbH)"}
9+
{name = "Norman Fomferra (Brockmann Consult GmbH)"},
10+
{name = "Alex Kerney (GMRI / NERACOOS)", email = "akerney@gmri.org"}
1011
]
1112
description = "A linter for xarray datasets."
1213
keywords = [
@@ -17,6 +18,7 @@ requires-python = ">=3.10"
1718
dependencies = [
1819
"click",
1920
"fsspec",
21+
"isodate>=0.7.2",
2022
"pyyaml",
2123
"tabulate",
2224
"xarray",
@@ -63,11 +65,6 @@ exclude = ["**/*.ipynb"]
6365
[project.scripts]
6466
xrlint = "xrlint.cli.main:main"
6567

66-
[project.optional-dependencies]
67-
acdd = [
68-
"isodate>=0.7.2",
69-
]
70-
7168
[dependency-groups]
7269
dev = [
7370
# Development tools

tests/plugins/acdd/rules/test_attributes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"title": "Tis only a test",
1111
"summary": "This is only a test dataset.",
1212
"keywords": "test, example, sample",
13-
"conventions": "ACDD-1.3",
13+
"Conventions": "ACDD-1.3",
1414
},
1515
)
1616
invalid_1_3_highly_rec_dataset = xr.Dataset()
1717

1818

1919
Attributes_1_3_Highly_ReccomendedTest = RuleTester.define_test(
20-
"1.3_attrs_highly_recommended",
20+
"1.3-attrs-highly-recommended",
2121
Attributes_1_3_Highly_Reccomended,
2222
valid=[RuleTest(dataset=valid_1_3_highly_rec_dataset)],
2323
invalid=[
@@ -27,7 +27,7 @@
2727
"Missing highly recommended attribute 'title'",
2828
"Missing highly recommended attribute 'keywords'",
2929
"Missing highly recommended attribute 'summary'",
30-
"Missing highly recommended attribute 'conventions'",
30+
"Missing highly recommended attribute 'Conventions'",
3131
],
3232
),
3333
],

tests/plugins/acdd/rules/test_conventions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
ConventionsTest = RuleTester.define_test(
14-
"1.3_conventions",
14+
"1.3-conventions",
1515
Conventions,
1616
valid=[
1717
RuleTest(dataset=valid_dataset_0),

tests/plugins/acdd/rules/test_id_blanks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
from xrlint.plugins.acdd.rules.no_id_blanks import NoBlanksInID
55

6-
valid_dataset_0 = xr.Dataset(attrs={"id": "testind_dataset"})
6+
valid_dataset_0 = xr.Dataset(attrs={"id": "testing_dataset"})
77

88
invalid_dataset_0 = xr.Dataset()
99
invalid_dataset_1 = xr.Dataset(attrs={"id": "testing dataset"})
1010

1111

1212
IdBlanksTest = RuleTester.define_test(
13-
"1.3_no_blanks_in_id",
13+
"1.3-no-blanks-in-id",
1414
NoBlanksInID,
1515
valid=[RuleTest(dataset=valid_dataset_0)],
1616
invalid=[
@@ -20,7 +20,7 @@
2020
),
2121
RuleTest(
2222
dataset=invalid_dataset_1,
23-
expected=["There should be no blanks in the id field"],
23+
expected=["There should not be blanks in the id field"],
2424
),
2525
],
2626
)

tests/plugins/acdd/rules/test_iso_dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
) # Invalid hour
2222

2323
IsoDatesTest = RuleTester.define_test(
24-
"1.3_dates_iso_format",
24+
"1.3-dates-iso-format",
2525
IsoDates,
2626
valid=[
2727
RuleTest(dataset=valid_dataset_0),

tests/plugins/acdd/rules/test_metadata_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
invalid_dataset_0 = xr.Dataset(attrs={"metadata_link": "example.com/metadata"})
1111

1212
Metadata_LinkTest = RuleTester.define_test(
13-
"1.3_metadata_link",
13+
"1.3-metadata-link",
1414
MetadataLink,
1515
valid=[
1616
RuleTest(dataset=valid_dataset_0),

tests/plugins/acdd/test_plugin.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ def test_rules_complete(self):
88
plugin = export_plugin()
99
self.assertEqual(
1010
{
11-
"1.3_conventions",
12-
"1.0_attrs_suggested",
13-
"1.0_attrs_highly_recommended",
14-
"1.0_attrs_recommended",
15-
"1.3_attrs_recommended",
16-
"1.3_attrs_suggested",
17-
"1.3_attrs_highly_recommended",
18-
"1.3_no_blanks_in_id",
19-
"1.3_metadata_link",
20-
"1.3_dates_iso_format",
11+
"1.3-conventions",
12+
"1.0-attrs-suggested",
13+
"1.0-attrs-highly-recommended",
14+
"1.0-attrs-recommended",
15+
"1.3-attrs-recommended",
16+
"1.3-attrs-suggested",
17+
"1.3-attrs-highly-recommended",
18+
"1.3-no-blanks-in-id",
19+
"1.3-metadata-link",
20+
"1.3-dates-iso-format",
2121
},
2222
set(plugin.rules.keys()),
2323
)

0 commit comments

Comments
 (0)