pauloventurab opened a new issue, #31743:
URL: https://github.com/apache/airflow/issues/31743

   ### Apache Airflow version
   
   2.6.1
   
   ### What happened
   
   Hi guys,
   
   i'm using the AwaitMessageTriggerFunctionSensor from Kafka with the 
following example on your Docs:
   
https://github.com/apache/airflow/blob/providers-apache-kafka/1.1.0/tests/system/providers/apache/kafka/example_dag_event_listener.py
   
   The issue is the apply_function. When I want to change the name of my file 
and the use "my_file_name.await_function" it says:
   
   `Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/module_loading.py",
 line 39, in import_string
       return getattr(module, class_name)
   AttributeError: module 'my_file_name' has no attribute 'listen_function'
   During handling of the above exception, another exception occurred:
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/jobs/triggerer_job_runner.py",
 line 529, in cleanup_finished_triggers
       result = details["task"].result()
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/jobs/triggerer_job_runner.py",
 line 607, in run_trigger
       async for event in trigger.run():
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/providers/apache/kafka/triggers/await_message.py",
 line 99, in run
       processing_call = import_string(self.apply_function)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/module_loading.py",
 line 41, in import_string
       raise ImportError(f'Module "{module_path}" does not define a 
"{class_name}" attribute/class')
   ImportError: Module "my_file_name" does not define a "await_function" 
attribute/class`
   
   Can you give a hand here please?
   
   My file is inside dag main folder. and I just copied the example and paste 
here, changing the name of the file and the apply_function to 
"my_file_name.await_function"
   
   Thanks
   
   ### What you think should happen instead
   
   I think it should work, and maybe also simplify the apply_function to the 
function name without the module importation, just the function inside the dag, 
could be a task as well.
   
   ### How to reproduce
   
   I don't know how to help improve it.
   
   ### Operating System
   
   Kubernetes cluster - Linux
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-apache-kafka==1.0.0
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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