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

Fix timestamp parsing to always include milliseconds #2683

Merged
merged 2 commits into from
Nov 28, 2024

Conversation

hanouticelina
Copy link
Contributor

fixes #2671.

See the original slack thread (internal) for more context.

The client expects timestamps to follow the pattern %Y-%m-%dT%H:%M:%S.%fZ, but the server was inconsistently returning timestamps without milliseconds when they were zero (e.g. "2024-11-20T20:01:58Z"). This causes the parsing error reported in the issue mentioned above.
we're handling this client-side as it's intentional behavior in the API to reduce precision, see this comment (private).

this is fixed by a small refactoring of parse_datetime() function and adding a normalization to ensure it has six digits of microseconds by padding with zeros or truncating. This approach handles inputs with or without milliseconds and nanoseconds.

cc @ErikKaum

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Thanks @hanouticelina! Looks good to me. Glad we've already had some unit tests for the existing part ^^

@ErikKaum
Copy link
Member

Thank you for handling this @hanouticelina 🙌

@hanouticelina hanouticelina merged commit e1f404f into main Nov 28, 2024
17 checks passed
@hanouticelina hanouticelina deleted the fix-datetime-parsing branch November 28, 2024 09:59
hanouticelina added a commit that referenced this pull request Nov 28, 2024
* fix datetime parsing when ms are zero

* small refactoring
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.

list_inference_endpoints fails with Date parsing error
4 participants