Skip to content

[Airflow-1606] airflow.models.DAG.sync_to_db is no longer a static method#2605

Closed
ashb wants to merge 1 commit intoapache:masterfrom
ashb:AIRFLOW-1606-db-sync_to_db-not-static
Closed

[Airflow-1606] airflow.models.DAG.sync_to_db is no longer a static method#2605
ashb wants to merge 1 commit intoapache:masterfrom
ashb:AIRFLOW-1606-db-sync_to_db-not-static

Conversation

@ashb
Copy link
Member

@ashb ashb commented Sep 13, 2017

Dear Airflow maintainers,

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

JIRA

Description

This will need #2602 merged first (to make dag.logger available again)

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"

Dear Airflow maintainers,

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

JIRA

Description

airflow.models.DAG.sync_to_db is declared as a static method, but it takes as it's first argument a DAG object (i.e. the same class that the method is delcared on). This is a bit odd

This will need #2602 (AIRFLOW-1605) merged first (to make dag.logger available again)

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason: initdb is already tested.

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"

@bolkedebruin
Copy link
Contributor

LGTM. Please rebase, squash and use imperative for commit message. After successful ci I'll merge.

@ashb ashb force-pushed the AIRFLOW-1606-db-sync_to_db-not-static branch 2 times, most recently from 9ecf249 to c33cc23 Compare September 13, 2017 10:21
Previously it was a static method that took as it's first argument a
DAG, which really meant it wasn't truly a static method.

To avoid reversing the parameter order I have given sensible defaults
from the one and only use in the rest of the code base.

Also remove documented "sync_to_db" parameter on DagBag that no longer
exists -- this doc string refers to a parameter that was removed in
[AIRFLOW-160].
@ashb ashb force-pushed the AIRFLOW-1606-db-sync_to_db-not-static branch from c33cc23 to 16b1eca Compare September 13, 2017 10:23
@ashb
Copy link
Member Author

ashb commented Sep 13, 2017

Squashed. Happy with the commit message?

@codecov-io
Copy link

codecov-io commented Sep 13, 2017

Codecov Report

Merging #2605 into master will increase coverage by <.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2605      +/-   ##
==========================================
+ Coverage   70.71%   70.71%   +<.01%     
==========================================
  Files         150      150              
  Lines       11564    11565       +1     
==========================================
+ Hits         8177     8178       +1     
  Misses       3387     3387
Impacted Files Coverage Δ
airflow/utils/db.py 84.42% <100%> (-0.26%) ⬇️
airflow/models.py 86.98% <81.81%> (-0.03%) ⬇️
airflow/executors/dask_executor.py 81.39% <0%> (+2.32%) ⬆️

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 956699f...16b1eca. Read the comment docs.

@Fokko
Copy link
Contributor

Fokko commented Sep 13, 2017

@ashb
Copy link
Member Author

ashb commented Sep 13, 2017

Argh, well spotted! Edit, updated that one now.

@bolkedebruin
Copy link
Contributor

Happy with the message. If you fix that last call ;-) then I'll merge.

@ashb
Copy link
Member Author

ashb commented Sep 13, 2017

Done.

@bolkedebruin
Copy link
Contributor

BTW: as tests did not catch that missed refactor should we make it so (i.e. fail if it uses the old call)?

@ashb
Copy link
Member Author

ashb commented Sep 13, 2017

It turns out that (at least in Py3) this change is backwards compatible:

class Foo:

    def foo(self):
        print(self)


class Bar:
    @staticmethod
    def bar(x):
        print(x)


foo = Foo()
bar = Bar()

Foo.foo(foo)
foo.foo()
Bar.bar(bar)

And the output is:

<__main__.Foo object at 0x10f125dd8>
<__main__.Foo object at 0x10f125dd8>
<__main__.Bar object at 0x10f125e10>

So since the arg order was the same this missed one wasn't an actual problem. Which also means I'm not sure how we might test for it.

@bolkedebruin
Copy link
Contributor

K, just assuming you refactored properly then :P

@asfgit asfgit closed this in 028b3b8 Sep 13, 2017
@bolkedebruin
Copy link
Contributor

Oef, commit message wasn't entirely clean. We will survive.

@Fokko
Copy link
Contributor

Fokko commented Sep 13, 2017

That was merged too soon, I think the amend of @ashb is missing:
https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L1717

@bolkedebruin
Copy link
Contributor

Mmm yes it seems so. Anyone for a hot fix?

@ashb
Copy link
Member Author

ashb commented Sep 13, 2017

D'oh yes, missed the force push after final rebase :( A new PR against the same Jira ticket?

@ashb
Copy link
Member Author

ashb commented Sep 13, 2017

Ah someone is on it already 👍

@ashb ashb deleted the AIRFLOW-1606-db-sync_to_db-not-static branch September 13, 2017 13:00
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.

4 participants