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

Configurable logging for libraries #10614

Merged
merged 17 commits into from
Jan 5, 2022
Merged

Conversation

tayfun
Copy link
Contributor

@tayfun tayfun commented Dec 31, 2021

Proposed changes:

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

Tayfun Sen added 5 commits December 31, 2021 13:44
This used to be taken from endpoints configuration but it was
undocumented and also not consistent, ie. pika did not utilize this for
example. We also want to use env variables here (I think?).
@tayfun tayfun requested a review from a team as a code owner December 31, 2021 17:07
@tayfun tayfun requested review from usc-m and removed request for a team December 31, 2021 17:07
@@ -216,4 +212,4 @@ def _close(self) -> None:
@rasa.shared.utils.common.lazy_property
def rasa_environment(self) -> Optional[Text]:
"""Get value of the `RASA_ENVIRONMENT` environment variable."""
return os.environ.get("RASA_ENVIRONMENT")
return os.environ.get("RASA_ENVIRONMENT", "RASA_ENVIRONMENT_NOT_SET")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melindaloubser1 I've added this default because otherwise kafka publish fails with

2021-12-31 16:26:18 ERROR    rasa.core.brokers.kafka  - Could not publish message to kafka url 'localhost'. Failed with error: encoding without a string argument

I think we also need to document this?

Copy link
Contributor

Choose a reason for hiding this comment

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

noticed a similar change here

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I was not online so just seeing this now - is it resolved/documented already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melindaloubser1 I've added the default RASA_ENVIRONMENT_NOT_SET but I haven't documented it as I'm not sure what the use case for this is. Seeing you added this you may be better suited to document it? We can also create a ticket for someone else. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh wait a sec I remember this now! The default here should be production. This is about multiple deployment environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melindaloubser1 I think there's a typo in https://rasa.com/docs/rasa-x/enterprise/deployment-environments where environments are listed after By default, two environments are defined:. Worker should be development.

I've approved your PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

The image shows development in addition to worker, but only worker is default, so no typo as far as I can see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean there are two environments, production and development but the list shows worker as an environment:

By default, two environments are defined:

production
worker

Copy link
Contributor

Choose a reason for hiding this comment

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

It's referring to the right hand side box:
image

development is not a default environment. It must be added manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melindaloubser1 Hmm, I see. I think I'm just confused then :D I thought prod and dev are default environments whereas worker would be separate instance just for training. Thanks for the explanation.

@tayfun tayfun requested a review from joejuzl January 4, 2022 14:06
@tayfun
Copy link
Contributor Author

tayfun commented Jan 4, 2022

Does this solution look good? I'll add tests and docs once we agree on a path to take.

Copy link
Contributor

@joejuzl joejuzl left a comment

Choose a reason for hiding this comment

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

Nice 👍

@@ -216,4 +212,4 @@ def _close(self) -> None:
@rasa.shared.utils.common.lazy_property
def rasa_environment(self) -> Optional[Text]:
"""Get value of the `RASA_ENVIRONMENT` environment variable."""
return os.environ.get("RASA_ENVIRONMENT")
return os.environ.get("RASA_ENVIRONMENT", "RASA_ENVIRONMENT_NOT_SET")
Copy link
Contributor

Choose a reason for hiding this comment

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

noticed a similar change here

3. LOG_LEVEL_RABBITMQ: This is the specialized environment variable to configure log level only for AMQP libraries, at the moment it handles log levels from `aio_pika` and `aiormq`.
4. LOG_LEVEL_KAFKA: This is the specialized environment variable to configure log level only for kafka.

General configuration (`LOG_LEVEL_LIBRARIES`) has less priority than library level specific configuration (`LOG_LEVEL_MATPLOTLIB`, `LOG_LEVEL_RABBITMQ` etc); and CLI parameter has the highest precedence. This means variables can be used together with a predictable result. As an example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Does CLI parameter have the highest precedence really? In the example below the cli is set to DEBUG but does't override the WARNING level of matplotlib... or am I understanding the example incorrectly?
Or maybe it only overrides to a less verbose level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, CLI parameter sets the level at the root level (which also has the important handler - coloredlogs handler). This means CLI level will be used for every log which is not explicitly set (matplotlib, rabbitmq, or rasa and any other library) but it also means CLI level overrides all other log levels if it is a less verbose level, like you said.

I'll change the wording in the docs.

@tayfun tayfun enabled auto-merge (squash) January 5, 2022 13:34
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2022

🚀 A preview of the docs have been deployed at the following URL: https://10614--rasahq-docs-rasa-v2.netlify.app/docs/rasa

@tayfun tayfun merged commit f00148b into main Jan 5, 2022
@tayfun tayfun deleted the tayfun/10203-configurable-logging branch January 5, 2022 15:26
@tayfun tayfun mentioned this pull request Jan 5, 2022
4 tasks
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.

Make logging verbosity configurable per package for verbose packages.
3 participants