question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ImportChangesRule` raises false positives

See original GitHub issue

Apache Airflow version: 1.10.14, apache-airflow-upgrade-check==1.1.0

Kubernetes version (if you are using kubernetes) (use kubectl version):

Environment:

  • Cloud provider or hardware configuration: on-premise Linux server
  • OS (e.g. from /etc/os-release): RHEL 7
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:

What happened:

Running airflow upgrade_check gives a series of false positives for the import check rule. For example:

('Using `airflow.contrib.hooks.sftp_hook.SFTPHook` should be replaced by '
 '`airflow.providers.sftp.hooks.sftp.SFTPHook`. Affected file: '
 '/airflow/dags/std_wsljobs_dags/hccmodel_dag.py')

However, this import has actually already been updated in the indicated file, and when viewing the code using the “Code” button in the Airflow UI it shows the updated path.

What you expected to happen:

That this file would not be flagged by the ImportChangesRule.

How to reproduce it:

Run airflow upgrade_check with a DAG file containing one of the classes whose import path changed.

Anything else we need to know:

I believe the culprit is this section from the ImportChangesRule:

  @staticmethod
  def _check_file(file_path):
      problems = []
      providers = set()
      with open(file_path, "r") as file:
          content = file.read()
          for change in ImportChangesRule.ALL_CHANGES:
              if change.old_class in content:
                  problems.append(change.info(file_path))
                  if change.providers_package:
                      providers.add(change.providers_package)
      return problems, providers

It is only checking the the old_class is present, not the old_path. The if statement should read: if change.old_path in content:. If I make this change in the source file, I receive zero problems back instead of 39.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jecolvincommented, Apr 1, 2021

Yes this did it. Thank you!!

Get Outlookhttps://aka.ms/qtex0l for iOS


From: eladkal @.> Sent: Thursday, April 1, 2021 6:04:31 AM To: apache/airflow @.> Cc: James Colvin @.>; Mention @.> Subject: Re: [apache/airflow] ImportChangesRule raises false positives (#13570)

@yergihttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fyergi&data=04|01||5179bc931f7144f02fd408d8f4f58b9f|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|637528682744009278|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&sdata=hMtTPDI7UuIOZLY3c1gekiqWA5Xy211Igc%2B%2FhM3AjyE%3D&reserved=0 were you able to verify ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fairflow%2Fissues%2F13570%23issuecomment-811801612&data=04|01||5179bc931f7144f02fd408d8f4f58b9f|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|637528682744019264|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&sdata=S1dgvNuRhzh6sv9DLr0xSQnDGBKiGEq290Rbkkv9kuY%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABZIHL7TVZ7LZNURQQ6PTETTGRAK7ANCNFSM4V2VZH7A&data=04|01||5179bc931f7144f02fd408d8f4f58b9f|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|637528682744019264|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|1000&sdata=BtvjudxtQ4A1P82G1KIwAHH7lrEblGu26Pbjw4njiM8%3D&reserved=0.

1reaction
jecolvincommented, Jan 11, 2021

Yes, I just created this PR. It’s my first time ever contributing to an open-source project, so please be gentle. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is a False Positive COVID-19 Test? - Prevention.com
False positive COVID-19 tests occur when you don't have the novel coronavirus, but the test is positive. Experts explain how and why false...
Read more >
Potential for False Positive Results with Certain Lots of Ellume ...
Potential for False Positive Results with Certain Lots of Ellume COVID-19 Home Tests Due to a Manufacturing Issue: FDA Safety Communication.
Read more >
org.apache.airflow.commits - 2021 January - 5,819 messages ...
[GitHub] [airflow] boring-cyborg[bot] commented on issue #13570: `ImportChangesRule` raises false positives - GitBox. [GitHub] [airflow] dstandish commented ...
Read more >
Home virus tests recalled over false positives reach 2 million ...
Home virus tests recalled over false positives reach 2 million kits. Ellume says far more than 400,000 of its rapid test kits may...
Read more >
False positives/negatives and Bayes rule for COVID-19 testing
Why both false positives and false negatives are bad for the COVID-19 tests. Why Bayes rule is important for these situations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found