martinbikandi commented on issue #56295:
URL: https://github.com/apache/airflow/issues/56295#issuecomment-3384968640

   I tried moving the function definitions to a separate file, an with that the 
DAG works.
   
   When the function definition is inside the same file as the DAG, this line 
is executed:
   
   ```python
               if inspect.getfile(self.python_callable) == self.dag.fileloc:
                   jinja_context["modified_dag_module_name"] = 
get_unique_dag_module_name(self.dag.fileloc)
   
   ```
   
   Which changes the name of the module to `unusual_prefix_X`. This causes dill 
to fail loading the serialized data when two tasks are present and the callable 
functions are defined inside the dag definition file.
   
   I'm not sure exactly as to why it fails loading when the second task is 
introduced.
   
   Some more tests:
   - When I move the definition of run_arg to a separate file, but keep 
run_kwarg in the same file as the dag, it works.
   - When I keep run_arg but move run_kwarg to a separate file, it fails with 
the same error `ModuleNotFoundError: No module named 'unusual_prefix_`.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to