question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Check if repo / file exists

See original GitHub issue

Hi, not sure if these functions are already implement, but I was not able to find them. It would be nice to have the following two methods:

  • a function that checks if a repository exists. I provide a name, it checks if huggingface.co/[model_name] exists. Returns True / False.
  • a function that checks if a specific file in a repository exists. For sentence-transformers, I check if there is a sentence-transformers specific file (modules.json) in that repositoryand depending on it I execute different code. Currently I do this with cached_download(url_to_modules_json_file) and catching a 404 exception. But having a function that just checks if the file exists (without downloading) and return True / False would have been nice.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
julien-ccommented, May 11, 2021

yes, we return a 404 (cc @Pierrci)

0reactions
nreimerscommented, May 11, 2021

I am also wondering what the response would be for a private model if the user is not authenticated? 404 or 401 Unauthorized?

404 would be more secure (so you cannot probe names from privat models), 401 Unauthorized would be more informative for users.

Not sure which one is the fastest compared to getting and checking the list from hf_api.list_models()

The hf_api.list_models() approach will not scale, e.g. once there are 100k models, the names for 100k models must be downloaded just to check if one name exists. So I think the 404 approach is much nicer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

enabling API users to check if a file exists, before requesting ...
Problem to solve. Whenever you want to know how if or if not a file exists with a certain name in a specified...
Read more >
Command to check if repository exists · Issue #1690 - GitHub
Feature request It would be nice if there was an option to check if a repository exists. This is particularly useful when restic...
Read more >
Repo File Checks | Checks | OpsLevel Docs
With the Repo File Check, you can verify the existence or contents of a file in your repo. Repo File Checks by default...
Read more >
Github Action : Stop the action if PR already exists
I want to change: If already a PR exists ( master <- dev ) no need to run this action, so how can...
Read more >
Build Azure Repos Git repositories - Azure Pipelines
You create a new pipeline by first selecting a repository and then a YAML file in that repository. The repository in which the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found