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

Add support for createdAt field #1816

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Add support for createdAt field #1816

merged 1 commit into from
Nov 10, 2023

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Nov 10, 2023

Followup PR after huggingface/hub-docs#1091 (private).

A new field createdAt is now returned by the server for every model/dataset/repo. This PR adds it as an official property for ModelInfo, DatasetInfo and SpaceInfo. Note that the lowest value is 2022-03-02T23:29:04.000Z, corresponding to the date when we began to store creation dates (as documented here).

>>> from huggingface_hub import HfApi 
>>> api = HfApi()

>>> api.model_info("gpt2").created_at
datetime.datetime(2022, 3, 2, 23, 29, 4, tzinfo=datetime.timezone.utc)
>>> api.dataset_info("bigcode/the-stack").created_at
datetime.datetime(2022, 10, 3, 2, 34, 54, tzinfo=datetime.timezone.utc)
>>> api.space_info("FaceOnLive/Face-Recognition-SDK").created_at
datetime.datetime(2023, 11, 2, 14, 51, 11, tzinfo=datetime.timezone.utc)

>>> list(api.list_models(limit=5))[0].created_at
datetime.datetime(2022, 3, 2, 23, 29, 4, tzinfo=datetime.timezone.utc)
>>> list(api.list_datasets(limit=5))[0].created_at
datetime.datetime(2022, 3, 2, 23, 29, 22, tzinfo=datetime.timezone.utc)
>>> list(api.list_spaces(limit=5))[0].created_at
datetime.datetime(2022, 3, 2, 23, 29, 35, tzinfo=datetime.timezone.utc)

EDIT: failing tests are unrelated

@Wauplin Wauplin requested a review from LysandreJik November 10, 2023 13:24
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 10, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Looks good to me! Nice that the backend returns this now :)

@Wauplin
Copy link
Contributor Author

Wauplin commented Nov 10, 2023

Thanks for the quick review Julien and Lysandre! Merging now :)

@Wauplin Wauplin merged commit 9b9baa0 into main Nov 10, 2023
12 of 16 checks passed
@Wauplin Wauplin deleted the add-created-at-field branch November 10, 2023 14:27
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.

4 participants