You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kunaljubce (via GitHub)" <gi...@apache.org> on 2025/12/30 10:21:06 UTC
[PR] Fix CLI dag parsing issues during reserialization [airflow]
kunaljubce opened a new pull request, #59928:
URL: https://github.com/apache/airflow/pull/59928
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+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 a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix CLI dag parsing issues during reserialization [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #59928:
URL: https://github.com/apache/airflow/pull/59928#issuecomment-4178119990
This draft pull request has had no activity from the author for over 3 weeks.
**@kunaljubce**, you are welcome to reopen this PR when you are ready to continue working on it. Thank you for your contribution!
<!-- Pull Request quality criteria -->
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix CLI dag parsing issues during reserialization [airflow]
Posted by "Nataneljpwd (via GitHub)" <gi...@apache.org>.
Nataneljpwd commented on code in PR #59928:
URL: https://github.com/apache/airflow/pull/59928#discussion_r2658949082
##########
airflow-core/src/airflow/dag_processing/dagbag.py:
##########
@@ -439,7 +439,20 @@ def parse(mod_name, filepath):
spec = importlib.util.spec_from_loader(mod_name, loader)
new_module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = new_module
- loader.exec_module(new_module)
+ module_dir = os.fspath(Path(filepath).parent)
Review Comment:
It looks like a patch only of it is 1 directory above or below, what happens when a task is nested 2 modules deep?
##########
airflow-core/src/airflow/dag_processing/dagbag.py:
##########
@@ -439,7 +439,20 @@ def parse(mod_name, filepath):
spec = importlib.util.spec_from_loader(mod_name, loader)
new_module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = new_module
- loader.exec_module(new_module)
+ module_dir = os.fspath(Path(filepath).parent)
+ # Insert module directory into sys.path to allow relative imports. Imp to note
+ # that this is just for the duration of `loader.exec_module(new_module)`, ensuring
+ # that helper modules located alongside the DAG are importable.
+ path_inserted = False
Review Comment:
Do we need this intermediate variable? As it will be in position 0 only when we add it there
##########
airflow-core/src/airflow/dag_processing/dagbag.py:
##########
@@ -439,7 +439,20 @@ def parse(mod_name, filepath):
spec = importlib.util.spec_from_loader(mod_name, loader)
Review Comment:
Maybe we should change to not use a source file loader and instead use spec_from_file_location and use the loader withing the spec?
I think it can solve this issue
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix CLI dag parsing issues during reserialization [airflow]
Posted by "kunaljubce (via GitHub)" <gi...@apache.org>.
kunaljubce commented on code in PR #59928:
URL: https://github.com/apache/airflow/pull/59928#discussion_r2686933939
##########
airflow-core/src/airflow/dag_processing/dagbag.py:
##########
@@ -439,7 +439,20 @@ def parse(mod_name, filepath):
spec = importlib.util.spec_from_loader(mod_name, loader)
new_module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = new_module
- loader.exec_module(new_module)
+ module_dir = os.fspath(Path(filepath).parent)
+ # Insert module directory into sys.path to allow relative imports. Imp to note
+ # that this is just for the duration of `loader.exec_module(new_module)`, ensuring
+ # that helper modules located alongside the DAG are importable.
+ path_inserted = False
Review Comment:
@Nataneljpwd You're right, this is an overkill. I will remove 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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix CLI dag parsing issues during reserialization [airflow]
Posted by "kunaljubce (via GitHub)" <gi...@apache.org>.
kunaljubce commented on PR #59928:
URL: https://github.com/apache/airflow/pull/59928#issuecomment-3708879830
> Added a few comments, maybe it is worth trying to change the loader
Thanks, I will take a look and make the changes over the next few days :)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix CLI dag parsing issues during reserialization [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed pull request #59928: Fix CLI dag parsing issues during reserialization
URL: https://github.com/apache/airflow/pull/59928
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix CLI dag parsing issues during reserialization [airflow]
Posted by "kunaljubce (via GitHub)" <gi...@apache.org>.
kunaljubce commented on PR #59928:
URL: https://github.com/apache/airflow/pull/59928#issuecomment-3699781425
Hello Maintainers - This is my first PR modifying a core component of dag processing, as far as I can tell. Please feel free to suggest if I am overlooking some other point of possible failure. Thanks!
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org