-
-
Notifications
You must be signed in to change notification settings - Fork 954
Get system user id in a lazy manner #1072
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -582,8 +582,16 @@ def _from_string(cls, string): | |
@classmethod | ||
def _main_actor(cls, env_name, env_email, config_reader=None): | ||
actor = Actor('', '') | ||
default_email = get_user_id() | ||
default_name = default_email.split('@')[0] | ||
user_id = None # We use this to avoid multiple calls to getpass.getuser() | ||
|
||
def default_email(): | ||
nonlocal user_id | ||
if not user_id: | ||
user_id = get_user_id() | ||
return user_id | ||
|
||
def default_name(): | ||
default_email().split('@')[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @athos-ribeiro @Byron There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was investigating an error in our CI and found this patch which is included in https://github.com/mlflow/mlflow/pull/3584/checks?check_run_id=1297036420#step:4:1677 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guess I messed up on this one :) Will provide a follow-up fix right away. I am sorry for this :(
|
||
|
||
for attr, evar, cvar, default in (('name', env_name, cls.conf_name, default_name), | ||
('email', env_email, cls.conf_email, default_email)): | ||
|
@@ -592,10 +600,10 @@ def _main_actor(cls, env_name, env_email, config_reader=None): | |
setattr(actor, attr, val) | ||
except KeyError: | ||
if config_reader is not None: | ||
setattr(actor, attr, config_reader.get_value('user', cvar, default)) | ||
setattr(actor, attr, config_reader.get_value('user', cvar, default())) | ||
# END config-reader handling | ||
if not getattr(actor, attr): | ||
setattr(actor, attr, default) | ||
setattr(actor, attr, default()) | ||
# END handle name | ||
# END for each item to retrieve | ||
return actor | ||
|