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

[HfApi] Add submit_paper endpoint #2745

Open
hanouticelina opened this issue Jan 13, 2025 · 0 comments
Open

[HfApi] Add submit_paper endpoint #2745

hanouticelina opened this issue Jan 13, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@hanouticelina
Copy link
Contributor

Feature request from @NielsRogge and @AK391, slack thread here (private).

Description

Add a submit_paper() method to the HfApi class to allow authors to submit papers to Daily Papers on Hugging Face Hub. This endpoint is currently available via /api/papers/submit.

Endpoint Specs

API Endpoint: POST /api/papers/submit

inputs:

  • paper_id (required): ArXiv ID of the paper to submit.
  • comment (optional): Text comment about the paper.
  • media_urls (optional): List of media URLs associated with the paper.

limitations:

  • User must have at least one paper on HF to submit.
  • cannot submit papers on weekends.
  • Regular users limited to X submissions per day.
  • Papers older than 7 days cannot be submitted.
  • Same paper cannot be submitted twice.

The server throws HTTP errors in these cases.

Implementation Details

@validate_hf_hub_args
def submit_paper(
    self,
    paper_id: str,
    *,
    comment: Optional[str] = None, 
    media_urls: Optional[List[str]] = None,
    token: Union[bool, str, None] = None,
) -> None:
   """Submit a paper to the Daily Papers feed.

    Note:
        - You must have at least one paper on HF to submit.
        - You cannot submit papers on weekends.
        - The number of submissions per day is limited.
        - Papers older than 7 days cannot be submitted.
        - Same paper cannot be submitted twice.
    
    Args:
        paper_id (`str`):
            The ArXiv ID of the paper to submit (e.g. "2401.12345") 
        comment (`str`, *optional*):
            An optional comment about the paper
        media_urls (`List[str]`, *optional*): 
            Optional list of media URLs to attach to the submission
        token (`Union[bool, str, None]`, *optional*):
            Authentication token. Required.
    
    Returns:
        None
        
    Raises:
        - ValueError if submission criteria not met
        - HTTPError for various failure cases
    """

Tests

We still need to figure out how to run tests properly in the staging environment hub-ci. We need to have a dummy user with at least one paper submitted and find how to mock the paper submission date.
⚠️ Not sure if it's worth investing too much time on the tests here given the limited usage.

@hanouticelina hanouticelina added the enhancement New feature or request label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant