Skip to content
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

RF: Add logging, dissolve duct_print (INFO level), add CLI option -l, dissolve --quiet #140

Merged
merged 10 commits into from
Aug 16, 2024

Conversation

yarikoptic
Copy link
Member

When we have logging, and it also goes to stderr, there is really no need for some dedicated "duct_print". Now everything can be controlled with -l and no additional --quiet is needed (good that it was not demoed in https://blog.datalad.org/ post).

I also added a few lgr.debug level statements.

I delayed setup of logging.basicConfig until main so it might be more coherent later on with desire to make this whole thing into a reusable Python module

Closes #134

@yarikoptic yarikoptic added the semver-minor Increment the minor version when merged label Aug 15, 2024
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 94.59%. Comparing base (ea784ba) to head (ec03e2c).
Report is 10 commits behind head on main.

Files Patch % Lines
src/con_duct/__main__.py 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #140      +/-   ##
==========================================
- Coverage   95.26%   94.59%   -0.67%     
==========================================
  Files           2        2              
  Lines         401      407       +6     
  Branches       63       62       -1     
==========================================
+ Hits          382      385       +3     
- Misses         12       14       +2     
- Partials        7        8       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

… dissolve --quiet

When we have logging, and it also goes to stderr, there is really no need for
some dedicated "duct_print". Now everything can be controlled with -l and
no additional --quiet is needed.

the only location is when to report that command is incorrect - that is where I used
explicit print to stderr since so far the only location.

I also added a few lgr.debug level statements.
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "./.update-readme-help.py",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
Comment on lines +368 to 370
except subprocess.CalledProcessError as exc: # when session_id has no processes
lgr.debug("Error collecting sample: %s", str(exc))
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except subprocess.CalledProcessError as exc: # when session_id has no processes
lgr.debug("Error collecting sample: %s", str(exc))
return None
except subprocess.CalledProcessError as exc:
lgr.debug("Could not collect sample (process may have finished): %s", str(exc))
return None

I know its just debug, but since this will happen almost every run we should make it sound not scary to unsuspecting users ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok
No need for str though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since its set to DEBUG, i dont see a problem leaving the exc in, it could be useful if ps fails for some other reason

Copy link
Member

@asmacdo asmacdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions, feel free to accept as you see fit and merge when ready.

FWIW https://blog.datalad.org/posts/intro-duct-tion/ will be out of date (uses --quiet) lets fix that before we release

Co-authored-by: Austin Macdonald <[email protected]>
@yarikoptic
Copy link
Member Author

Dang, is searched for it, I guess for silent not quiet. I will add deprecation warning when get to laptop

Before this commit we could effectively disable logging by setting the
level to CRITICAL, but that only works because there are no CRITICAL
logs, and that isn't something we should expect users to know. This
feature is required by the use case in the datalad blog post
https://blog.datalad.org/posts/intro-duct-tion/
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "./.update-readme-help.py",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
@asmacdo asmacdo merged commit ddec9cd into main Aug 16, 2024
28 of 30 checks passed
@asmacdo asmacdo deleted the enh-logging branch August 16, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logger
2 participants