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

Improve logging #235

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

stellasia
Copy link
Contributor

@stellasia stellasia commented Dec 13, 2024

Description

Truncate long lists and strings in logs. The max length of list of string is configurable using env vars.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

Complexity: Low

How Has This Been Tested?

  • Unit tests
  • E2E tests
  • Manual tests

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • E2E tests have been updated
  • Examples have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed
  • CHANGELOG.md updated if appropriate

@stellasia stellasia force-pushed the fix/debuging-exprience branch from 80b0647 to e4342e8 Compare January 2, 2025 17:35
@stellasia stellasia changed the title WIP: improve logging Improve logging Jan 3, 2025
@stellasia stellasia marked this pull request as ready for review January 3, 2025 10:12
@stellasia stellasia requested a review from a team as a code owner January 3, 2025 10:12
@@ -101,10 +103,14 @@ def from_config(
cls, config: AbstractPipelineConfig | dict[str, Any], do_cleaning: bool = False
) -> Self:
wrapper = PipelineConfigWrapper.model_validate({"config": config})
logger.debug(
f"PIPELINE_RUNNER: instantiate Pipeline from config type: {wrapper.config.template_}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor but this should probably be instantiating and not instantiate

return value


prettyfier = Prettyfier()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why instantiate an instance of the Prettyfier class here and then import the instance? Why not just import the class and then create an instance of it where it's used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason is to keep things simple when logging, we already need an extra step (calling the function), if we also have to instantiate the class every time we use a logger, I think it makes the code more complicated.

We could also have a function like this:

def prettify(value):
   prettifer = Prettifyer()
   return prettifier(value)

and import this function when logging, but since the Prettifyer class is always the same, I though it would be easier like this. But I'm happy to change if you prefer the function approach or another one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm happy to leave it for now as I don't have a good intuition for what would be the best approach in this situation. It might be something worth changing in a future refactor though.

DEFAULT_MAX_STRING_LENGTH: int = 200


class Prettyfier:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any unit tests for this class? I think testing the nested functionality would be especially useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants