Skip to content

[AIRFLOW-1602] LoggingMixin in DAG class#2602

Closed
Fokko wants to merge 1 commit intoapache:masterfrom
Fokko:AIRFLOW-1602-use-loggingmixin-in-dag-class
Closed

[AIRFLOW-1602] LoggingMixin in DAG class#2602
Fokko wants to merge 1 commit intoapache:masterfrom
Fokko:AIRFLOW-1602-use-loggingmixin-in-dag-class

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Sep 13, 2017

Dear Airflow maintainers,

As @ashb mentioned. Within the DAG class we want to use the LoggingMixer for more transparent logger instead of creating a new anonymous logger.

Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!

JIRA

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

Commits

  • My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Within the DAG class we want to use the LoggingMixer for more
transparent logger instead of creating a new anonymous logger
@mention-bot
Copy link

@Fokko, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mistercrunch, @bolkedebruin and @aoen to be potential reviewers.

orm_dag = DagModel(dag_id=dag.dag_id)
log = LoggingMixin().logger
log.info("Creating ORM DAG for %s", dag.dag_id)
dag.logger.info("Creating ORM DAG for %s", dag.dag_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is odd. You are logging in a different class here. I kind of assume a log is private to the class (although we are not explicitly doing that)

Copy link
Member

Choose a reason for hiding this comment

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

Not the subject of this PR, but this being a static method, where the first argument is an instance of the class is very odd.

There are two uses. One in utils/db.py:

    for dag in dagbag.dags.values():
        models.DAG.sync_to_db(dag, dag.owner, now)

This would make more sense as dag.sync_to_db(synctime=now). The other use is inside this method itself:

        for subdag in dag.subdags:
            DAG.sync_to_db(subdag, owner, sync_time, session=session)

which could be become subdag.sync_to_db(owner=self.owner, sync_time=sync_time, session=session)

Think that's worth adding as a standalone PR and not changing this logger use?

Copy link
Member

Choose a reason for hiding this comment

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

(or not changing this logger use now, but in that PR)

Copy link
Contributor

Choose a reason for hiding this comment

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

@ashb absolutely, that makes sense. A PR would be very welcome.

Copy link
Member

Choose a reason for hiding this comment

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

Raised as #2605 (which will need this PR)

@codecov-io
Copy link

codecov-io commented Sep 13, 2017

Codecov Report

Merging #2602 into master will decrease coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2602      +/-   ##
=========================================
- Coverage   70.71%   70.7%   -0.02%     
=========================================
  Files         150     150              
  Lines       11566   11564       -2     
=========================================
- Hits         8179    8176       -3     
- Misses       3387    3388       +1
Impacted Files Coverage Δ
airflow/models.py 86.97% <66.66%> (-0.02%) ⬇️
airflow/executors/dask_executor.py 79.06% <0%> (-2.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ece956...4d4d349. Read the comment docs.

@bolkedebruin
Copy link
Contributor

LGTM, given the follow up PRs

@asfgit asfgit closed this in 956699f Sep 13, 2017
@Fokko Fokko deleted the AIRFLOW-1602-use-loggingmixin-in-dag-class branch September 15, 2017 12:58
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.

5 participants