Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing of isoformat string returned by observation register api endpoint fails in regobslib #28

Open
gh-PonyM opened this issue Nov 25, 2024 · 0 comments

Comments

@gh-PonyM
Copy link

gh-PonyM commented Nov 25, 2024

Problem

We identified that the server response form regobs production could not be parsed in python 3.10. Python 3.8 and 3.9 are also affected.

Here are some logs showing the problem using regobslib v1.0.3.

2024-11-16 00:00:30.443 gpregobs.observation_registry ERROR: Failed to retry ../var/opt/regobs/objects/2ac22a7710df036628f53d308112ac1a4b9e4c8d3f802eb098f3eb0d74959ebf.json. Next retry in PT1M
Traceback (most recent call last):
  File "/app/gpregobs/observation_registry.py", line 24, in retry_object
    await register(
  File "/app/gpregobs/observation_registry.py", line 94, in register
    await regobs.register(
  File "/app/gpregobs/backends/regobs.py", line 207, in register
    return await trio.to_thread.run_sync(
  File "/app/.venv/lib/python3.10/site-packages/trio/_threads.py", line 215, in to_thread_run_sync
    return await trio.lowlevel.wait_task_rescheduled(abort)
  File "/app/.venv/lib/python3.10/site-packages/trio/_core/_traps.py", line 166, in wait_task_rescheduled
    return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()
  File "/app/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 138, in unwrap
    raise captured_error
  File "/app/.venv/lib/python3.10/site-packages/trio/_threads.py", line 161, in do_release_then_return_result
    return result.unwrap()
  File "/app/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 138, in unwrap
    raise captured_error
  File "/app/.venv/lib/python3.10/site-packages/trio/_threads.py", line 175, in worker_fn
    ret = sync_fn(*args)
  File "/app/gpregobs/backends/regobs.py", line 200, in _register
    submitted_registration = connection.submit(
  File "/app/.venv/lib/python3.10/site-packages/regobslib/connection.py", line 139, in submit
    return self.get(reg_id)
  File "/app/.venv/lib/python3.10/site-packages/regobslib/connection.py", line 151, in get
    return SnowRegistration.deserialize(returned_reg.json())
  File "/app/.venv/lib/python3.10/site-packages/regobslib/submit.py", line 357, in deserialize
    obs_time = cls._apply(json, "DtObsTime", lambda x: dt.datetime.fromisoformat(x))
  File "/app/.venv/lib/python3.10/site-packages/regobslib/submit.py", line 60, in _apply
    return apply(elem) if elem is not None else None
  File "/app/.venv/lib/python3.10/site-packages/regobslib/submit.py", line 357, in <lambda>
    obs_time = cls._apply(json, "DtObsTime", lambda x: dt.datetime.fromisoformat(x))
ValueError: Invalid isoformat string: '2024-11-16T00:13:20.58+01:00'
2024-11-16 00:01:30.502 gpregobs.observation_registry DEBUG: Start object retry...

The issue is also described here: python/cpython#9522.
As described in the issue, dateutil.parser.isoparse could be used instead since datetime.fromisoformat should only used internally in python.

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

No branches or pull requests

1 participant