You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/01/08 09:26:04 UTC
[GitHub] [airflow] sarutak opened a new pull request #7099: [AIRFLOW-6507]
Replace the use of impl.load_source with another solution.
sarutak opened a new pull request #7099: [AIRFLOW-6507] Replace the use of impl.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099
As of Python 3.4, impl module will be deprecated and recommended to use importlib.
Almost all the part of code in Airflow uses importlib except for impl.load_source in models/dagbag.py.
This change propose a solution that use `importlib.SourceFileLoader`.
I didn't add new test-case because existing test-cases in `TestDagBag` covers.
---
Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
- [x] Description above provides context of the change
- [x] Commit message/PR title starts with `[AIRFLOW-NNNN]`. AIRFLOW-NNNN = JIRA ID<sup>*</sup>
- [x] Unit tests coverage for changes (not needed for documentation changes)
- [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
- [x] Relevant documentation is updated including usage instructions.
- [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
<sup>*</sup> For document-only changes commit message can start with `[AIRFLOW-XXXX]`.
---
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] boring-cyborg[bot] commented on issue #7099:
[AIRFLOW-6507] Replace the use of impl.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #7099: [AIRFLOW-6507] Replace the use of impl.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-571963211
Congratulations on your first Pull Request and welcome to the Apache Airflow community!
If you have any issues or are unsure about any anything please check our
Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
Here are some useful points:
- Pay attention to the quality of your code (flake8, pylint and type annotations). Our [pre-commits](
https://github.com/apache/airflow/blob/master/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks)
will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory).
Adding a new operator? Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/master/BREEZE.rst) for testing
locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from
Committers.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://apache-airflow-slack.herokuapp.com/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] kaxil commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364443683
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
We don't need this, do we?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] kaxil merged pull request #7099: [AIRFLOW-6507] Replace
the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] feluelle commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364200648
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,7 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ m = importlib.machinery.SourceFileLoader(mod_name, filepath).load_module()
Review comment:
```suggestion
m = importlib.machinery.SourceFileLoader(mod_name, filepath).exec_module()
```
https://docs.python.org/3/library/importlib.html#importlib.machinery.SourceFileLoader.load_module
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] kaxil commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r365212566
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
You are right, thanks for pointing out that link.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] kaxil commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364951020
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
We shouldn't be updating the sys.modules directly.
I will fallback to what other committers think @potiuk @ashb :
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] codecov-io edited a comment on issue #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-572019856
# [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=h1) Report
> Merging [#7099](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/fe20ef6147f157b7c963ad46e13aff7c16458632?src=pr&el=desc) will **decrease** coverage by `0.22%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7099 +/- ##
==========================================
- Coverage 85.15% 84.93% -0.23%
==========================================
Files 680 682 +2
Lines 38824 38993 +169
==========================================
+ Hits 33061 33118 +57
- Misses 5763 5875 +112
```
| [Impacted Files](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [airflow/models/dagbag.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9tb2RlbHMvZGFnYmFnLnB5) | `86.95% <100%> (+0.15%)` | :arrow_up: |
| [airflow/kubernetes/volume\_mount.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZV9tb3VudC5weQ==) | `44.44% <0%> (-55.56%)` | :arrow_down: |
| [airflow/kubernetes/volume.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZS5weQ==) | `52.94% <0%> (-47.06%)` | :arrow_down: |
| [airflow/kubernetes/pod\_launcher.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3BvZF9sYXVuY2hlci5weQ==) | `45.25% <0%> (-46.72%)` | :arrow_down: |
| [airflow/kubernetes/refresh\_config.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3JlZnJlc2hfY29uZmlnLnB5) | `50.98% <0%> (-23.53%)` | :arrow_down: |
| [...rflow/contrib/operators/kubernetes\_pod\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9rdWJlcm5ldGVzX3BvZF9vcGVyYXRvci5weQ==) | `78.75% <0%> (-20%)` | :arrow_down: |
| [airflow/providers/amazon/aws/operators/batch.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9wcm92aWRlcnMvYW1hem9uL2F3cy9vcGVyYXRvcnMvYmF0Y2gucHk=) | `93.75% <0%> (-2.09%)` | :arrow_down: |
| [airflow/contrib/hooks/gcp\_spanner\_hook.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL2hvb2tzL2djcF9zcGFubmVyX2hvb2sucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/awsbatch\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9hd3NiYXRjaF9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/gcp\_spanner\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9nY3Bfc3Bhbm5lcl9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| ... and [5 more](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=footer). Last update [fe20ef6...f826a47](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] codecov-io edited a comment on issue #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-572019856
# [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=h1) Report
> Merging [#7099](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/fe20ef6147f157b7c963ad46e13aff7c16458632?src=pr&el=desc) will **decrease** coverage by `0.22%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7099 +/- ##
==========================================
- Coverage 85.15% 84.92% -0.23%
==========================================
Files 680 682 +2
Lines 38824 38981 +157
==========================================
+ Hits 33061 33106 +45
- Misses 5763 5875 +112
```
| [Impacted Files](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [airflow/models/dagbag.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9tb2RlbHMvZGFnYmFnLnB5) | `86.74% <100%> (-0.06%)` | :arrow_down: |
| [airflow/kubernetes/volume\_mount.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZV9tb3VudC5weQ==) | `44.44% <0%> (-55.56%)` | :arrow_down: |
| [airflow/kubernetes/volume.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZS5weQ==) | `52.94% <0%> (-47.06%)` | :arrow_down: |
| [airflow/kubernetes/pod\_launcher.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3BvZF9sYXVuY2hlci5weQ==) | `45.25% <0%> (-46.72%)` | :arrow_down: |
| [airflow/kubernetes/refresh\_config.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3JlZnJlc2hfY29uZmlnLnB5) | `50.98% <0%> (-23.53%)` | :arrow_down: |
| [...rflow/contrib/operators/kubernetes\_pod\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9rdWJlcm5ldGVzX3BvZF9vcGVyYXRvci5weQ==) | `78.75% <0%> (-20%)` | :arrow_down: |
| [airflow/providers/amazon/aws/operators/batch.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9wcm92aWRlcnMvYW1hem9uL2F3cy9vcGVyYXRvcnMvYmF0Y2gucHk=) | `93.75% <0%> (-2.09%)` | :arrow_down: |
| [airflow/contrib/hooks/gcp\_spanner\_hook.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL2hvb2tzL2djcF9zcGFubmVyX2hvb2sucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/awsbatch\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9hd3NiYXRjaF9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/gcp\_spanner\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9nY3Bfc3Bhbm5lcl9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| ... and [3 more](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=footer). Last update [fe20ef6...7dee296](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] sarutak commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
sarutak commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364487841
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
Thanks for you comment.
What you suggested is actually my first approach.
https://github.com/apache/airflow/pull/7099/commits/7fd424457a10e161e819bf376b601716e481f194
But it doesn't pass tests.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] codecov-io edited a comment on issue #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-572019856
# [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=h1) Report
> Merging [#7099](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/fe20ef6147f157b7c963ad46e13aff7c16458632?src=pr&el=desc) will **decrease** coverage by `0.22%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7099 +/- ##
==========================================
- Coverage 85.15% 84.93% -0.23%
==========================================
Files 680 682 +2
Lines 38824 38993 +169
==========================================
+ Hits 33061 33118 +57
- Misses 5763 5875 +112
```
| [Impacted Files](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [airflow/models/dagbag.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9tb2RlbHMvZGFnYmFnLnB5) | `86.95% <100%> (+0.15%)` | :arrow_up: |
| [airflow/kubernetes/volume\_mount.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZV9tb3VudC5weQ==) | `44.44% <0%> (-55.56%)` | :arrow_down: |
| [airflow/kubernetes/volume.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZS5weQ==) | `52.94% <0%> (-47.06%)` | :arrow_down: |
| [airflow/kubernetes/pod\_launcher.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3BvZF9sYXVuY2hlci5weQ==) | `45.25% <0%> (-46.72%)` | :arrow_down: |
| [airflow/kubernetes/refresh\_config.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3JlZnJlc2hfY29uZmlnLnB5) | `50.98% <0%> (-23.53%)` | :arrow_down: |
| [...rflow/contrib/operators/kubernetes\_pod\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9rdWJlcm5ldGVzX3BvZF9vcGVyYXRvci5weQ==) | `78.75% <0%> (-20%)` | :arrow_down: |
| [airflow/providers/amazon/aws/operators/batch.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9wcm92aWRlcnMvYW1hem9uL2F3cy9vcGVyYXRvcnMvYmF0Y2gucHk=) | `93.75% <0%> (-2.09%)` | :arrow_down: |
| [airflow/contrib/hooks/gcp\_spanner\_hook.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL2hvb2tzL2djcF9zcGFubmVyX2hvb2sucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/awsbatch\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9hd3NiYXRjaF9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/gcp\_spanner\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9nY3Bfc3Bhbm5lcl9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| ... and [5 more](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=footer). Last update [fe20ef6...f826a47](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] codecov-io edited a comment on issue #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-572019856
# [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=h1) Report
> Merging [#7099](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/fe20ef6147f157b7c963ad46e13aff7c16458632?src=pr&el=desc) will **decrease** coverage by `0.22%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7099 +/- ##
==========================================
- Coverage 85.15% 84.93% -0.23%
==========================================
Files 680 682 +2
Lines 38824 38993 +169
==========================================
+ Hits 33061 33118 +57
- Misses 5763 5875 +112
```
| [Impacted Files](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [airflow/models/dagbag.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9tb2RlbHMvZGFnYmFnLnB5) | `86.95% <100%> (+0.15%)` | :arrow_up: |
| [airflow/kubernetes/volume\_mount.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZV9tb3VudC5weQ==) | `44.44% <0%> (-55.56%)` | :arrow_down: |
| [airflow/kubernetes/volume.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZS5weQ==) | `52.94% <0%> (-47.06%)` | :arrow_down: |
| [airflow/kubernetes/pod\_launcher.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3BvZF9sYXVuY2hlci5weQ==) | `45.25% <0%> (-46.72%)` | :arrow_down: |
| [airflow/kubernetes/refresh\_config.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3JlZnJlc2hfY29uZmlnLnB5) | `50.98% <0%> (-23.53%)` | :arrow_down: |
| [...rflow/contrib/operators/kubernetes\_pod\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9rdWJlcm5ldGVzX3BvZF9vcGVyYXRvci5weQ==) | `78.75% <0%> (-20%)` | :arrow_down: |
| [airflow/providers/amazon/aws/operators/batch.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9wcm92aWRlcnMvYW1hem9uL2F3cy9vcGVyYXRvcnMvYmF0Y2gucHk=) | `93.75% <0%> (-2.09%)` | :arrow_down: |
| [airflow/contrib/hooks/gcp\_spanner\_hook.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL2hvb2tzL2djcF9zcGFubmVyX2hvb2sucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/awsbatch\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9hd3NiYXRjaF9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/gcp\_spanner\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9nY3Bfc3Bhbm5lcl9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| ... and [5 more](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=footer). Last update [fe20ef6...f826a47](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] feluelle commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364201480
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,7 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ m = importlib.machinery.SourceFileLoader(mod_name, filepath).load_module()
Review comment:
Actually you then also need to call https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.create_module first.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] sarutak commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
sarutak commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r365094489
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
FYI:
The way manipulating `sys.modules` directly is introduced in [the Python official document](https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] sarutak commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
sarutak commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364497578
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
It's the second approach.
https://github.com/apache/airflow/pull/7099/commits/68c539fdcd74b900bcc60f441ac5ceb3b4f1b63d
That approach successfully finish some test-cases that the first one fails.
But still fails a test-case.
`test_backfill_job.py::TestBackfillJob::test_backfill_examples_2_example_skip_dag`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] codecov-io edited a comment on issue #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-572019856
# [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=h1) Report
> Merging [#7099](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/fe20ef6147f157b7c963ad46e13aff7c16458632?src=pr&el=desc) will **decrease** coverage by `0.22%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7099 +/- ##
==========================================
- Coverage 85.15% 84.92% -0.23%
==========================================
Files 680 682 +2
Lines 38824 38981 +157
==========================================
+ Hits 33061 33106 +45
- Misses 5763 5875 +112
```
| [Impacted Files](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [airflow/models/dagbag.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9tb2RlbHMvZGFnYmFnLnB5) | `86.74% <100%> (-0.06%)` | :arrow_down: |
| [airflow/kubernetes/volume\_mount.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZV9tb3VudC5weQ==) | `44.44% <0%> (-55.56%)` | :arrow_down: |
| [airflow/kubernetes/volume.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZS5weQ==) | `52.94% <0%> (-47.06%)` | :arrow_down: |
| [airflow/kubernetes/pod\_launcher.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3BvZF9sYXVuY2hlci5weQ==) | `45.25% <0%> (-46.72%)` | :arrow_down: |
| [airflow/kubernetes/refresh\_config.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3JlZnJlc2hfY29uZmlnLnB5) | `50.98% <0%> (-23.53%)` | :arrow_down: |
| [...rflow/contrib/operators/kubernetes\_pod\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9rdWJlcm5ldGVzX3BvZF9vcGVyYXRvci5weQ==) | `78.75% <0%> (-20%)` | :arrow_down: |
| [airflow/providers/amazon/aws/operators/batch.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9wcm92aWRlcnMvYW1hem9uL2F3cy9vcGVyYXRvcnMvYmF0Y2gucHk=) | `93.75% <0%> (-2.09%)` | :arrow_down: |
| [airflow/contrib/hooks/gcp\_spanner\_hook.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL2hvb2tzL2djcF9zcGFubmVyX2hvb2sucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/awsbatch\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9hd3NiYXRjaF9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/gcp\_spanner\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9nY3Bfc3Bhbm5lcl9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| ... and [3 more](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=footer). Last update [fe20ef6...7dee296](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] codecov-io commented on issue #7099: [AIRFLOW-6507]
Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-572019856
# [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=h1) Report
> Merging [#7099](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=desc) into [master](https://codecov.io/gh/apache/airflow/commit/fe20ef6147f157b7c963ad46e13aff7c16458632?src=pr&el=desc) will **decrease** coverage by `0.22%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #7099 +/- ##
==========================================
- Coverage 85.15% 84.92% -0.23%
==========================================
Files 680 682 +2
Lines 38824 38981 +157
==========================================
+ Hits 33061 33106 +45
- Misses 5763 5875 +112
```
| [Impacted Files](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [airflow/models/dagbag.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9tb2RlbHMvZGFnYmFnLnB5) | `86.74% <100%> (-0.06%)` | :arrow_down: |
| [airflow/kubernetes/volume\_mount.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZV9tb3VudC5weQ==) | `44.44% <0%> (-55.56%)` | :arrow_down: |
| [airflow/kubernetes/volume.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3ZvbHVtZS5weQ==) | `52.94% <0%> (-47.06%)` | :arrow_down: |
| [airflow/kubernetes/pod\_launcher.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3BvZF9sYXVuY2hlci5weQ==) | `45.25% <0%> (-46.72%)` | :arrow_down: |
| [airflow/kubernetes/refresh\_config.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9rdWJlcm5ldGVzL3JlZnJlc2hfY29uZmlnLnB5) | `50.98% <0%> (-23.53%)` | :arrow_down: |
| [...rflow/contrib/operators/kubernetes\_pod\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9rdWJlcm5ldGVzX3BvZF9vcGVyYXRvci5weQ==) | `78.75% <0%> (-20%)` | :arrow_down: |
| [airflow/providers/amazon/aws/operators/batch.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9wcm92aWRlcnMvYW1hem9uL2F3cy9vcGVyYXRvcnMvYmF0Y2gucHk=) | `93.75% <0%> (-2.09%)` | :arrow_down: |
| [airflow/contrib/hooks/gcp\_spanner\_hook.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL2hvb2tzL2djcF9zcGFubmVyX2hvb2sucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/awsbatch\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9hd3NiYXRjaF9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [airflow/contrib/operators/gcp\_spanner\_operator.py](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree#diff-YWlyZmxvdy9jb250cmliL29wZXJhdG9ycy9nY3Bfc3Bhbm5lcl9vcGVyYXRvci5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| ... and [3 more](https://codecov.io/gh/apache/airflow/pull/7099/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=footer). Last update [fe20ef6...7dee296](https://codecov.io/gh/apache/airflow/pull/7099?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] kaxil commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364446643
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
The following should also work:
```python
spec = importlib.util.spec_from_file_location(module_name, module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] sarutak commented on issue #7099: [AIRFLOW-6507] Replace
the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
sarutak commented on issue #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#issuecomment-574537650
I noticed there are 2 `imp` left...
I'll open another PR to fix them.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] kaxil commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364488560
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,11 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ loader = importlib.machinery.SourceFileLoader(mod_name, filepath)
+ spec = importlib.util.spec_from_loader(mod_name, loader)
+ m = importlib.util.module_from_spec(spec)
+ sys.modules[spec.name] = m
Review comment:
Ok but you should not need "sys.modules[spec.name] = m"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [airflow] sarutak commented on a change in pull request #7099:
[AIRFLOW-6507] Replace the use of imp.load_source with another solution.
Posted by GitBox <gi...@apache.org>.
sarutak commented on a change in pull request #7099: [AIRFLOW-6507] Replace the use of imp.load_source with another solution.
URL: https://github.com/apache/airflow/pull/7099#discussion_r364212215
##########
File path: airflow/models/dagbag.py
##########
@@ -248,7 +247,7 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True):
with timeout(self.DAGBAG_IMPORT_TIMEOUT):
try:
- m = imp.load_source(mod_name, filepath)
+ m = importlib.machinery.SourceFileLoader(mod_name, filepath).load_module()
Review comment:
Thanks. I'll fix it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services