Skip to content

Refactor deployment time extraction and error handling#548

Open
leilabbb wants to merge 15 commits intomainfrom
parse_deployment_dates
Open

Refactor deployment time extraction and error handling#548
leilabbb wants to merge 15 commits intomainfrom
parse_deployment_dates

Conversation

@leilabbb
Copy link
Copy Markdown
Contributor

used regular expression to parse deployment dates

used regular expression to parse deployment dates
@leilabbb leilabbb requested a review from benjwadams March 31, 2026 22:11
@leilabbb leilabbb linked an issue Mar 31, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@benjwadams benjwadams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test -- should handle the following:

{deployment_name}-{ISO8601LIKE} (base case)
{deployment_name}-{ISO8601LIKE}Z UTC TZ specified, possibly handle other TZ, although I rarely see this in practice
{deployment_name}-{ISO8601LIKE}-{extra_string} Often extra_string is "delayed" for delayed mode data, pursuant to #355

Comment thread glider_qc/glider_qc.py Outdated
@leilabbb
Copy link
Copy Markdown
Contributor Author

leilabbb commented Apr 1, 2026

pre-commit.ci autofix

Comment thread glider_qc/glider_qc.py
Comment thread glider_qc/glider_qc.py Outdated
Add functions to validate and normalize timestamps.
@benjwadams
Copy link
Copy Markdown
Contributor

benjwadams commented Apr 1, 2026

pre-commit.ci autofix

@benjwadams benjwadams self-requested a review April 1, 2026 21:45
Comment thread glider_qc/glider_qc.py
# Build ISO string and let dateutil validate calendar correctness (e.g., April 31)
iso = f"{y:04d}-{mo:02d}-{d:02d}T{hh:02d}:{mm:02d}:{ss:02d}Z"
try:
dt = isoparse(iso)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isoparse should handle most of these validation cases:

>>> from dateutil.parser import isoparse
>>> isoparse("9999-99-99T27:68:68")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/dateutil/parser/isoparser.py", line 37, in func
    return f(self, str_in, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/dateutil/parser/isoparser.py", line 146, in isoparse
    return datetime(*components)
ValueError: month must be in 1..12

I don't see an import statement for dateutil.parsers.isoparse so I think this will result in a runtime error when this line is run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is right I need to add that

Comment thread glider_qc/glider_qc.py
iso = f"{y:04d}-{mo:02d}-{d:02d}T{hh:02d}:{mm:02d}:{ss:02d}Z"
try:
dt = isoparse(iso)
except Exception as exc:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't catch raw exceptions, change this to catch ValueError and log the exception, proceeding with logic for failure conditions.

leilabbb added 2 commits April 1, 2026 21:01
Handle parsing errors for ISO date strings by logging exceptions and appending error messages to the report list.
Copy link
Copy Markdown
Contributor

@benjwadams benjwadams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per earlier comment I intended as a code review, please add unit tests for at least the following cases:

{deployment_name}-{ISO8601LIKE} (base case)
{deployment_name}-{ISO8601LIKE}Z UTC TZ specified, possibly handle other TZ, although I rarely see this in practice
{deployment_name}-{ISO8601LIKE}-{extra_string} Often extra_string is "delayed" for delayed mode data, pursuant to https://github.com/ioos/glider-dac/issues/355

benjwadams

This comment was marked as duplicate.

@benjwadams
Copy link
Copy Markdown
Contributor

benjwadams commented Apr 2, 2026

^^ I guess this is a review, I was confused by the comment portion.

@benjwadams benjwadams removed this from the Add Additional Variables for QC milestone Apr 2, 2026
@leilabbb leilabbb requested a review from benjwadams May 1, 2026 15:32
leilabbb and others added 2 commits May 1, 2026 15:10
added <att name="dac_qc_comment">...</att> in the <addAttributes> block in ERDDAP XML chunk to overwrite the value from the NetCDF files in the ERDDAP aggregated dataset.
Fix dac_qc_comment attribute to aggregated dataset
@benjwadams
Copy link
Copy Markdown
Contributor

benjwadams commented May 4, 2026

Commit 5ec220c says "Fix trailing whitespace and end-of-file issues", but it appears to have much more than just formatting logic. Could you please rebase and split out some of these changes into separate commits, assuming you don't want to squash the formatting changes into the original commit upon rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QC routines can't parse deployment dates from certain filenames

2 participants