-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
chore: enforce kwarg logging #7207
Conversation
d2c7ae5
to
aa80a38
Compare
aa80a38
to
3cca2e1
Compare
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.
Let's do this, I think the approach has several advantages:
- it brings in consistency
- it makes structure logging effective, not just an available feature
- I like when Haystack is opinionated, and this is a great opportunity to do so
Approving the idea, code review to be done
8269160
to
f598266
Compare
@@ -296,6 +296,7 @@ select = [ | |||
"T10", # flake8-debugger | |||
"W", # pycodestyle | |||
"YTT", # flake8-2020 | |||
"I" # isort |
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'm sorry for this as this causes a big diff but pylint complains about the import order for all logging imports (since the third-party import of logging
became a first-party import from haystack
) and I couldn't bother fixing them manually. In my opinion this should be enabled by default (and we should also run ruff in the CI!)
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.
We tried but turned out we should rethink the whole lint/format workflow, see #5931
@@ -1,9 +1,9 @@ | |||
import haystack.logging |
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.
explanation for import order change here: https://github.com/deepset-ai/haystack/pull/7207/files#r1505884720
9cdad45
to
355bf50
Compare
@@ -40,23 +41,6 @@ def test_skip_logging_configuration( | |||
# Nothing should be captured by capfd since structlog is not configured | |||
assert capfd.readouterr().err == "" | |||
|
|||
def test_skip_logging_if_structlog_not_installed( |
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.
this somehow breaks pytest itself. I tried to fix it but couldn't figure out what happened. Would be nice to test the import error but in my opinion also not super crucial (it's hard to test in the first place)
return wrapper | ||
|
||
|
||
def _patch_structlog_call_information(logger: logging.Logger) -> None: |
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 wholeheartedly apologize for 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.
created an issue for this as well: hynek/structlog#602
Pull Request Test Coverage Report for Build 8096409462Details
💛 - Coveralls |
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.
Left one question but it looks very good to me! Now that I see in action I'm even more convinced this is the right approach, love it!
I might as well miss something but I swear I went through all the changed files 😅
@@ -296,6 +296,7 @@ select = [ | |||
"T10", # flake8-debugger | |||
"W", # pycodestyle | |||
"YTT", # flake8-2020 | |||
"I" # isort |
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.
We tried but turned out we should rethink the whole lint/format workflow, see #5931
"Increase the max_tokens parameter to allow for longer completions.", | ||
message.meta["index"], | ||
index=message.meta["index"], | ||
finish_reason=message.meta["finish_reason"], |
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 can't see the {finish_reason}
placeholder, is that missing?
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.
great catch - this is actually an extra key-value which I found useful to be logged (so it's not interpolated in the message, just attached as key value)
Related Issues
Proposed Changes:
How did you test it?
Notes for the reviewer
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.