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
Add transformers id to hub requests #10811
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! I added a small nitpick below, but nothing important.
src/transformers/file_utils.py
Outdated
@@ -213,6 +214,7 @@ | |||
PYTORCH_PRETRAINED_BERT_CACHE = os.getenv("PYTORCH_PRETRAINED_BERT_CACHE", default_cache_path) | |||
PYTORCH_TRANSFORMERS_CACHE = os.getenv("PYTORCH_TRANSFORMERS_CACHE", PYTORCH_PRETRAINED_BERT_CACHE) | |||
TRANSFORMERS_CACHE = os.getenv("TRANSFORMERS_CACHE", PYTORCH_TRANSFORMERS_CACHE) | |||
TRANSFORMERS_ID = uuid4().hex |
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.
I had a preference for the previous name SESSION_ID
that I find more informative.
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.
I defer to @n1t0 in this case :-)
@@ -1211,7 +1213,7 @@ def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str: | |||
""" | |||
Formats a user-agent string with basic info about a request. | |||
""" | |||
ua = "transformers/{}; python/{}".format(__version__, sys.version.split()[0]) | |||
ua = f"transformers/{__version__}; python/{sys.version.split()[0]}; session_id/{SESSION_ID}" |
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.
should we trim the id slightly to e.g. 12 chars? @philschmid cc @n1t0
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.
I don't have a strong opinion on this
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.
I wanted to leave this unchanged and adding 20 more characters to it won`t be that big of a problem. But I am open to adjusting it.
* add uuid.hext to user_agent * add log * changed order of it * renamed as session id * renamed variable * reverted naming of the const
What does this PR do?
This PR adds a
TRANSFORMERS_ID
const, which helps us to group the several files request against the hub.