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 Space variable when updatedAt is missing #2050

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/huggingface_hub/_space_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,18 @@ class SpaceVariable:
Variable value. Example: `"the_model_repo_id"`.
description (`str` or None):
Description of the variable. Example: `"Model Repo ID of the implemented model"`.
updatedAt (`datetime`):
datetime of the last update of the variable.
updatedAt (`datetime` or None):
datetime of the last update of the variable (if the variable has been updated at least once).
"""

key: str
value: str
description: Optional[str]
updated_at: datetime
updated_at: Optional[datetime]

def __init__(self, key: str, values: Dict) -> None:
self.key = key
self.value = values["value"]
self.description = values.get("description")
self.updated_at = parse_datetime(values["updatedAt"])
updated_at = values.get("updatedAt")
self.updated_at = parse_datetime(updated_at) if updated_at is not None else None
Loading