Datetime parsing error when calling get_inference_endpoint

I have an inference ednpoint on the hub and when I try to get it with endpoint = get_inference_endpoint("vlt5-base-keywords-twitopt")

I get an error related to datetime parsing

Traceback (most recent call last):
  File "/Users/tropianhs/coding/twitter_optimize/analyze_topics.py", line 190, in <module>
    start_endpoint()
  File "/Users/tropianhs/coding/twitter_optimize/analyze_topics.py", line 22, in start_endpoint
    endpoint = get_inference_endpoint("vlt5-base-keywords-twitopt").resume().wait()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tropianhs/coding/twitter_optimize/.twitopt/lib/python3.11/site-packages/huggingface_hub/hf_api.py", line 7336, in get_inference_endpoint
    return InferenceEndpoint.from_raw(response.json(), namespace=namespace, token=token)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tropianhs/coding/twitter_optimize/.twitopt/lib/python3.11/site-packages/huggingface_hub/_inference_endpoints.py", line 140, in from_raw
    return cls(raw=raw, namespace=namespace, _token=token, _api=api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 7, in __init__
  File "/Users/tropianhs/coding/twitter_optimize/.twitopt/lib/python3.11/site-packages/huggingface_hub/_inference_endpoints.py", line 144, in __post_init__
    self._populate_from_raw()
  File "/Users/tropianhs/coding/twitter_optimize/.twitopt/lib/python3.11/site-packages/huggingface_hub/_inference_endpoints.py", line 383, in _populate_from_raw
    self.updated_at = parse_datetime(self.raw["status"]["updatedAt"])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tropianhs/coding/twitter_optimize/.twitopt/lib/python3.11/site-packages/huggingface_hub/utils/_datetime.py", line 59, in parse_datetime
    raise ValueError(
ValueError: Cannot parse '2024-03-30T04:40:02Z' as a datetime. Date string is expected to follow '%Y-%m-%dT%H:%M:%S.%fZ' pattern.

The endpoint is paused. But if I resume it manually from the web interface the code runs ok.

1 Like

Iā€™m getting the same error maybe 1/20 times when resuming an endpoint. The only fix is to manually pause and resume from the website.

Traceback (most recent call last):
  File "python3.12/site-packages/huggingface_hub/utils/_datetime.py", line 56, in parse_datetime
    dt = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S.%fZ")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/_strptime.py", line 554, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/_strptime.py", line 333, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-07-25T11:30:24Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'