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

Minor Fix tool push_to_hub #460

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

keetrap
Copy link
Contributor

@keetrap keetrap commented Jan 31, 2025

Fixed issue where passing the token directly in the push_to_hub function was not working.

@@ -343,7 +343,7 @@ def push_to_hub(
space_sdk="gradio",
)
repo_id = repo_url.repo_id
metadata_update(repo_id, {"tags": ["tool"]}, repo_type="space")
metadata_update(repo_id, {"tags": ["tool"]}, repo_type="space", token=token)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this not create a problem by exposing private tokens in the space? (I' not sure what metadata_update does)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it will not expose token. Token is required for this but we are not passing it.

def metadata_update(
    repo_id: str,
    metadata: Dict,
    *,
    repo_type: Optional[str] = None,
    overwrite: bool = False,
    token: Optional[str] = None,
    commit_message: Optional[str] = None,
    commit_description: Optional[str] = None,
    revision: Optional[str] = None,
    create_pr: bool = False,
    parent_commit: Optional[str] = None,
) -> str:
    """
    Updates the metadata in the README.md of a repository on the Hugging Face Hub.
    If the README.md file doesn't exist yet, a new one is created with metadata and an
    the default ModelCard or DatasetCard template. For `space` repo, an error is thrown
    as a Space cannot exist without a `README.md` file.

@aymeric-roucher
Copy link
Collaborator

aymeric-roucher commented Feb 4, 2025

LGTM! Thank you for the fix and the explanation @keetrap ! 😃

@aymeric-roucher aymeric-roucher merged commit a8918f7 into huggingface:main Feb 4, 2025
@keetrap keetrap deleted the fix_tool_push_to_hub branch February 21, 2025 18:16
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.

2 participants