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.

Rename `allow_regex` and `ignore_regex` in `snapshot_download` to be consistent with `fnmatch`

See original GitHub issue

https://github.com/huggingface/huggingface_hub/blob/3e72bc876d72855445a3c204f483eb761eb91da5/src/huggingface_hub/snapshot_download.py#L214-L223

In the above, fnmatch is being used to filter files against allow_regex and ignore_regex. Acknowledging that I might be being overly pedantic here, the official docs for fnmatch include the following disclaimer at the top:

This module provides support for Unix shell-style wildcards, which are not the same as regular expressions (which are documented in the re module).

One place where this inconsistency might cause an issue is if someone is downloading a snapshot of a model with large weights and only wants weights for one particular framework. If they created regular expression strings for ignore_regex, they’d be unpleasantly surprised with the function downloading everything anyway.

I can open a PR changing the names of the parameters if you’re open to making this change and let me know what you’d prefer them be changed to. Perhaps allow_patterns and ignore_patterns, respectively?

Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
patrickvonplatencommented, Apr 18, 2022

Ok for me to rename the function arguments. I’d prefer to go over a deprecation cycle though that would still allow allow_regex and ignore_regex to be passed, but would throw a warning to instead use allow_patterns.

We should then also update the naming here:

0reactions
Wauplincommented, Aug 18, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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