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

[AIRFLOW-4686] Make dags Pylint compatible #5753

Merged

Conversation

feluelle
Copy link
Member

@feluelle feluelle commented Aug 7, 2019

Make sure you have checked all steps below.

Jira

  • My PR addresses the following Airflow Jira issues and references them in the PR title. For example, "[AIRFLOW-XXX] My Airflow PR"
    • https://issues.apache.org/jira/browse/AIRFLOW-4686
    • In case you are fixing a typo in the documentation you can prepend your commit with [AIRFLOW-XXX], code changes always need a Jira issue.
    • In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal (AIP).
    • In case you are adding a dependency, check if the license complies with the ASF 3rd Party License Policy.

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 (not including Jira issue reference)
    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"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
    • If you implement backwards incompatible changes, please leave a note in the Updating.md so we can assign it to a appropriate release

Code Quality

  • Passes flake8

@feluelle
Copy link
Member Author

feluelle commented Aug 8, 2019

@potiuk I do not understand why I have this test failing when I didn't change anything there.

======================================================================

21) FAIL: test_execute (tests.contrib.operators.test_cassandra_to_gcs_operator.CassandraToGCSTest)

----------------------------------------------------------------------

   Traceback (most recent call last):

    /usr/local/lib/python3.5/unittest/mock.py line 1159 in patched

      return func(*args, **keywargs)

    tests/contrib/operators/test_cassandra_to_gcs_operator.py line 53 in test_execute

      test_bucket, schema, TMP_FILE_NAME, "application/json", gzip

    /usr/local/lib/python3.5/unittest/mock.py line 794 in assert_called_with

      raise AssertionError(_error_message()) from cause

   AssertionError: Expected call: upload('test-bucket', 'schema.json', 'temp-file', 'application/json', True)

   Actual call: upload('test-bucket', 'data.json', 'temp-file', 'application/json', True)

The test was added here and it passed all tests.

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

Yeah. I think it's a flaky test - passing sometimes - I saw it failing in master as well. I think we need to remove it for now.

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

It looks like there are two calls - one for schema.json and one for data.json and sometimes one comes first, sometimes the other :).

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

Yeah. We are experiencing this: https://stackoverflow.com/questions/7242433/asserting-successive-calls-to-a-mock-method - assert_called_with only check the last call and there are two - and they race each other

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

I will do a quick fix

@feluelle
Copy link
Member Author

feluelle commented Aug 8, 2019

Yes, I just noticed that, too, that I 've never used assert_called_with.

I use assert_has_calls for multiple calls and for single calls I use assert_called_once_with

@feluelle
Copy link
Member Author

feluelle commented Aug 8, 2019

We could use assert_has_calls with any_order set to True.

@feluelle
Copy link
Member Author

feluelle commented Aug 8, 2019

Oh that's exactly what the link is saying :D

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

Yep. Just submitting this fix :)

       call_schema = call(test_bucket, schema, TMP_FILE_NAME, "application/json", gzip)
        call_data = call(test_bucket, filename, TMP_FILE_NAME, "application/json", gzip)
        mock_upload.assert_has_calls([call_schema, call_data], any_order=True)

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

Fix here: #5758

@feluelle
Copy link
Member Author

feluelle commented Aug 8, 2019

We should make a pre-commit hook to check if we have assert_called_with in our /tests :P

I've integrated the pre-commit framework for our custom plugins - works like a charm :)

@potiuk
Copy link
Member

potiuk commented Aug 8, 2019

Oh yeah. That's coming :)

@feluelle feluelle force-pushed the feature/AIRFLOW-4686-dags-pylint-compatible branch from 3d2a859 to 0772512 Compare August 12, 2019 09:57
@feluelle
Copy link
Member Author

@potiuk is this fine now? :P ..or may want @ashb have a quick look at this? :)

Copy link
Member

@mik-laj mik-laj left a comment

Choose a reason for hiding this comment

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

One small comment and today I hope merge this PR.

@feluelle feluelle force-pushed the feature/AIRFLOW-4686-dags-pylint-compatible branch from 0772512 to d68462e Compare August 12, 2019 19:19
@feluelle feluelle force-pushed the feature/AIRFLOW-4686-dags-pylint-compatible branch from d68462e to 1344a75 Compare August 12, 2019 19:21
@mik-laj mik-laj merged commit 571ffcc into apache:master Aug 13, 2019
@mik-laj
Copy link
Member

mik-laj commented Aug 13, 2019

@feluelle Thanks. Great work. Fixing pylint errors is very important. This will allow for faster development of the project.

ashb pushed a commit to ashb/airflow that referenced this pull request Oct 11, 2019
adityav pushed a commit to adityav/airflow that referenced this pull request Oct 14, 2019
@feluelle feluelle deleted the feature/AIRFLOW-4686-dags-pylint-compatible branch April 30, 2020 07:03
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.

3 participants