Review huggingface_hub integration
          #2592
        
          
      
                
     Merged
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
TL;DR:
timmis compatible withhuggingface_hubv0.x and v1.xAt first I just wanted to check that the current implementation was compatible with the upcoming
huggingface_hubv1.0 release (see huggingface/huggingface_hub#3340). This is indeed the case (breaking changes should not affect timm). However I took the advantage to update thehuggingface_hubintegration, and especially:file_existsinstead ofget_hf_file_metadata+hf_hub_urlin order to check if the repo user is uploading to has a READMEv0.17.0which has been release in Sept' 2023 and introducedfile_existsutility. I don't think this bump is a major problem as it's 2 years old.repo_idmanually usingrepo_type_and_id_from_hf_idas this is already done by thecreate_reporeturn value (since Dec' 2022 so included inv0.17+)HfApiinstead of individual methods when uploading a modeltimm(only done forhf_hub_downloadso far)tokenonce and for all => previously theget_hf_file_metadata(hf_hub_url(repo_id=repo_id, filename="README.md", revision=revision))was necessarily failing in case of private repo since token was not forwarded