-
Notifications
You must be signed in to change notification settings - Fork 2
Support DVC legacy user_id file path #31
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 2 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 |
---|---|---|
|
@@ -112,6 +112,7 @@ venv/ | |
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
.idea/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -196,7 +196,9 @@ def _find_or_create_user_id(): | |||||||||||||||||
IDs are generated randomly with UUID. | ||||||||||||||||||
""" | ||||||||||||||||||
|
||||||||||||||||||
config_dir = user_config_dir("telemetry", "iterative") | ||||||||||||||||||
config_dir = user_config_dir( | ||||||||||||||||||
os.path.join("iterative", "telemetry"), "iterative" | ||||||||||||||||||
) | ||||||||||||||||||
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. Could you explain what was wrong with the previous approach? user_config_dir is following particular convention and it is kinda strange that we use 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.
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. @omesser So maybe
Suggested change
then? The os.path.join pretty much hacks the convention and might not be desirable. dvc#7707 just talks about it being consistent, I'm sure particular location can be flexible, as long as it is constant and follows conventions. Also this change will probably break backward compatibility for MLEM? cc @mike0sv 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.
Yes, but that's probably early enough in the game to be ok (?) about the new path - I don't feel strongly either way (because we can change it again), but having an 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. It's not MLEM alone, this is VS Code also. I remember we had this discussion in Notion and agreed on something like
(I remember we also had a discussion with @mattseddon on this already but don't remember the details) 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. 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. CML/TPI use:
Suggested change
for maximum cross-platform compatibility. Anything else would break currently released TPI. Suggest #32 instead 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. Thanks @casperdcl - gonna add the code writing to the old path as well here, and was planning to move to 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. not sure what was decided? to leave iterative/telemetry? 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. That's my understanding, because vs-code is doing iterative/telemetry and that was also what was decided in https://www.notion.so/iterative/Telemetry-Specification-1a0197b8e34d43a89777a4c9a00ad1fe?d=46ce025aef734858a653d0c485d4e896#ddef310469b44c13a445c686f73014d4 |
||||||||||||||||||
fname = os.path.join(config_dir, "user_id") | ||||||||||||||||||
lockfile = os.path.join(config_dir, "user_id.lock") | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -213,7 +215,9 @@ def _find_or_create_user_id(): | |||||||||||||||||
user_id = json.load(fobj)["user_id"] | ||||||||||||||||||
|
||||||||||||||||||
except (FileNotFoundError, ValueError, KeyError): | ||||||||||||||||||
user_id = str(uuid.uuid4()) | ||||||||||||||||||
|
||||||||||||||||||
# Backwards compatibility with DVC legacy telemetry location. | ||||||||||||||||||
user_id = _try_read_legacy_user_id() or str(uuid.uuid4()) | ||||||||||||||||||
|
||||||||||||||||||
with open(fname, "w", encoding="utf8") as fobj: | ||||||||||||||||||
json.dump({"user_id": user_id}, fobj) | ||||||||||||||||||
|
@@ -223,3 +227,16 @@ def _find_or_create_user_id(): | |||||||||||||||||
except Timeout: | ||||||||||||||||||
logger.debug("Failed to acquire %s", lockfile) | ||||||||||||||||||
return None | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
def _try_read_legacy_user_id(): | ||||||||||||||||||
fname = os.path.join(user_config_dir("dvc", "iterative"), "user_id") | ||||||||||||||||||
omesser marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
||||||||||||||||||
try: | ||||||||||||||||||
with open(fname, encoding="utf8") as fobj: | ||||||||||||||||||
return json.load(fobj)["user_id"] | ||||||||||||||||||
|
||||||||||||||||||
except (FileNotFoundError, ValueError, KeyError): | ||||||||||||||||||
pass | ||||||||||||||||||
|
||||||||||||||||||
return None | ||||||||||||||||||
casperdcl marked this conversation as resolved.
Show resolved
Hide resolved
|
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 thoroughly dislike any OS and IDE-specific things appearing in
.gitignore
.About 50% of this file is noxious to me :)
The world does not need this cruft in every repo. Better to modify your system-wide git config. Possibly a topic for a follow-up issue/discussion?
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.
😄 Doing this in the repo's git-tracked
.gitignore
is still the convention in virtually every project I've seen, personally.Making assumptions about contributors global git config is probably too risky - and projects need to be robust to people configuring their systems/dev-boxes whichever way they like
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.
agreed with @omesser - dont see any downsides to have a couple more lines in
.gitignore
for all popular IDEs. also this repo was generated from our template so might be worth to add it there also https://github.com/iterative/py-template