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
Stats improvements #465
Stats improvements #465
Conversation
Once OKed I'll squash the commits |
author idomic <michael.ido@gmail.com> 1641325888 -0500 committer idomic <michael.ido@gmail.com> 1641401611 -0500 # This is a combination of 5 commits. # This is the 1st commit message: Working v2 + Tests # This is the commit message #2: Added tests # This is the commit message #3: linting # This is the commit message #4: Pulled from master # This is the commit message #5: Rebased Pulled from master
2760394
to
ed3e5ff
Compare
src/ploomber/telemetry/telemetry.py
Outdated
def check_first_time_usage(): | ||
config_path = os.path.join(check_dir_file_exist(CONF_DIR), 'config.yaml') | ||
uid_path = os.path.join(check_dir_file_exist(CONF_DIR), 'uid.yaml') | ||
return not os.path.exists(uid_path) and os.path.exists(config_path) |
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.
shouldn't this be not os.path.exists(uid_path) and not os.path.exists(config_path)
?
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.
No since the call is being performed after the check for a stats config file (check the calling function)
src/ploomber/telemetry/telemetry.py
Outdated
uid = str(uuid.uuid4()) | ||
try: # Create for future runs | ||
with open(uid_path, "w") as file: | ||
with uid_path.open("w", encoding="utf-8") as file: |
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.
can we leave the default encoding instead of hardcoding? this is system-dependent. no need to change it but for future reference you can use Path.write_text
and Path.read_text
instead of Path.open
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.
Sure, where I can I'll try these functions, here I figured it's better to enforce a yaml structure via the class, without open it will not work. You can take a look of this thread: https://stackoverflow.com/questions/57296168/pathlib-path-write-text-in-append-mode
what happens if any of the functions that check the config fail? like So maybe have something like this: def _check_uid():
# all the logic here
pass
def check_uid():
try:
return _check_uid():
exception Exception:
return None thoughts? |
No description provided.