Comments (5)
🤖
Hello again @adammarples! It's good to see you back in our issue threads. I hope you're doing well.
I understand that you're experiencing an issue with duplicate log lines when running a CeleryExecutor on Astronomer hosted, using astronomer-cosmos==1.2.5, even after setting AIRFLOW__COSMOS__PROPAGATE_LOGS = "False"
or AIRFLOW__COSMOS__PROPAGATE_LOGS=false
.
This issue might be due to the logger not correctly picking up the propagate_logs
configuration from the Airflow settings. The get_logger
function in the Cosmos codebase is trying to read the propagate_logs
configuration from the cosmos
section of the Airflow configuration. If the configuration is not found, it defaults to True
, which means the logs will be propagated to the parent loggers, potentially causing duplicate log lines. You can find this in the cosmos/log.py file.
To prevent duplicate log lines, you need to ensure that the propagate_logs
configuration is correctly set in the Airflow configuration. However, you mentioned that you have already tried setting AIRFLOW__COSMOS__PROPAGATE_LOGS = "False"
or AIRFLOW__COSMOS__PROPAGATE_LOGS=false
, but it didn't work.
This might be due to a mismatch between the environment variable and the configuration option that the get_logger
function is trying to read. The get_logger
function is looking for propagate_logs
in the cosmos
section, but the environment variable you're setting is AIRFLOW__COSMOS__PROPAGATE_LOGS
.
To resolve this issue, you can try setting the propagate_logs
configuration directly in the airflow.cfg
file under the cosmos
section:
[cosmos]
propagate_logs = False
If this doesn't work, there might be an issue with the way the get_logger
function is reading the configuration. You can try modifying the get_logger
function to print out the value of propagateLogs
after it's read from the configuration to see if it's correctly picking up the setting:
def get_logger(name: str | None = None) -> logging.Logger:
propagateLogs: bool = True
if conf.has_option("cosmos", "propagate_logs"):
propagateLogs = conf.getboolean("cosmos", "propagate_logs")
print(f"propagateLogs: {propagateLogs}") # Add this line
logger = logging.getLogger(name)
formatter: logging.Formatter = CustomTTYColoredFormatter(fmt=LOG_FORMAT) # type: ignore
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.propagate = propagateLogs
return logger
This will help you debug whether the propagate_logs
configuration is being correctly read from the Airflow configuration.
I hope this helps! If you have any other questions or need further clarification, feel free to ask.
Sources
- Annoying duplicate celery logging in Airflow task logs when running in celery worker
- cosmos/log.py
- docs/configuration/logging.rst
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
from astronomer-cosmos.
Hi @tatiana, I am just investigating it. It's my bad, it's not a bug, these log propagation changes work fine in main branch but are not included in version 1.2.5, so I'll wait for the update.
from astronomer-cosmos.
@adammarples Sorry - we are really lacking versioned docs, I logged #750 so we don't lose track of this issue.
from astronomer-cosmos.
@adammarples, thanks for reporting the issue!
This may be a bug, and the robot suggested using the configuration file as a workaround. Could you confirm this works?
A possible fix could be done along these lines:
astronomer-cosmos/tests/test_log.py
Lines 20 to 22 in 6ccde5c
And we could add a test to make sure things work with the env vars:
astronomer-cosmos/tests/test_log.py
Lines 19 to 24 in 6ccde5c
Would you like to make this contribution?
from astronomer-cosmos.
@adammarples this change is available in the release 1.3.0a2, in case you'd like to try it out:
https://pypi.org/project/astronomer-cosmos/1.3.0a2/
Since it is a new feature, we didn't release as part of a 1.2 micro release. For some reason we missed to include it in our release notes, I'll fix this:
https://github.com/astronomer/astronomer-cosmos/releases/tag/astronomer-cosmos-v1.3.0a2
from astronomer-cosmos.
Related Issues (20)
- Decouple `LoadMode.AUTOMATIC` from `load()` method in `DbtGraph`
- Cosmos tasks randomly getting marked as zombie tasks HOT 3
- Fix hard to read AirflowException error logs from dbt command HOT 2
- bug please help me this is my project (ubuntu) HOT 6
- Permission issue with Cosmos cache in some restricted environments HOT 2
- [Bug]: Trial Issue using Bug report template HOT 1
- This a new feature request using Feature request Issue template HOT 1
- Link to dbt docs from task HOT 1
- [Cosmos CI] 2.7 unit tests taking a long time to run
- Remove dependency on Pydantic
- Improve how we authorise non-commiters to run Cosmos integration tests
- New Features
- Support docs generated with `dbt docs generate --static`
- Test task is generated though it is not defined HOT 2
- Reduce task queueing latency when using Cosmos HOT 5
- Emit Airflow metrics to support analysing Cosmos performance HOT 2
- `LoadMode.AUTOMATIC` does not seem to work as documented HOT 4
- Using EMR transient cluster with Cosmos HOT 1
- AthenaAccessKeyProfileMapping does not work as expected locally HOT 3
- [Bug] cosmos 1.4.1 does not create virtualenv when using `ExecutionMode.VIRTUALENV` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from astronomer-cosmos.