-
Notifications
You must be signed in to change notification settings - Fork 571
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
Improve Mixin #34
Improve Mixin #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
setup.py
Outdated
extras["testing"] = [ | ||
"pytest", | ||
] | ||
] + extras["torch"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there value in having a second CI setup with no torch? (to make sure we don't introduce a dependency on torch inadvertently down the road)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can add that
if isinstance(use_auth_token, str): | ||
huggingface_token = use_auth_token | ||
elif use_auth_token is None and repo_url is not None: | ||
# If the repo url exists, then no need for a token | ||
huggingface_token = None | ||
else: | ||
huggingface_token = HfFolder.get_token() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(use_auth_token, str): | |
huggingface_token = use_auth_token | |
elif use_auth_token is None and repo_url is not None: | |
# If the repo url exists, then no need for a token | |
huggingface_token = None | |
else: | |
huggingface_token = HfFolder.get_token() | |
if isinstance(use_auth_token, str): | |
huggingface_token = use_auth_token | |
elif use_auth_token: | |
huggingface_token = HfFolder.get_token() | |
else: | |
huggingface_token = None |
let's use the same logic as elsewhere no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with using the same logic as elsewhere is that the API becomes weird to use, in order to cover a rare use-case. Namely, the following will never work:
model.push_to_hub("xxx")
it needs to be the following:
model.push_to_hub("xxx", use_auth_token=True)
I fail to see when a user would want to push to the hub without having an auth_token
, as it's necessary to create a repo. If the repo already exists and one wants to push to it, then the user already has to specify the repo_url
to push to.
I think the API is cleaner by having model.push_to_hub("xxx")
work if you already have an authentication token in your HF folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
files = os.listdir(f"{WORKING_REPO_DIR}/{REPO_NAME}") | ||
self.assertTrue("config.json" in files) | ||
self.assertTrue("pytorch_model.bin" in files) | ||
self.assertEqual(len(files), 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
) | ||
self.assertTrue(model.config == {"num": 10, "act": "gelu_fast"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertEqual
should work, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed!
Improves the Mixin in the hub by adding support for
api_endpoint
,use_auth_token
, as well asgit_user
andgit_email
.It updates the tests so that they run in the staging environment. In doing so, I found a bug relative to absolute paths in
from_pretrained
, this fixes that at the same time.