uranusjr commented on issue #48665:
URL: https://github.com/apache/airflow/issues/48665#issuecomment-2782219494

   Hmm, this works correctly for me. I added a `print` to 
`filter_file_extension` and added a prefix to the message to tell which is 
which:
   
   ```python
   def filter_file_extension(file: str) -> str | None:
       print("filter", file)
       if file.rsplit('.', 1)[1] == 'zip':
           return None
       return file
   
   @dag
   def my_dag():
   
       @task
       def return_files() -> list[str]:
           return ["a.txt", "b.zip", "c.txt"]
   
       @task
       def print_filtered_files(files: list[str]) -> None:
           for file in files:
               print("print", file)
   
       filtered_files = return_files().map(filter_file_extension)
       print_filtered_files(filtered_files)
   
   
   my_dag()
   ```
   
   ```
   [2025-04-07, 06:51:13] INFO - filter a.txt: chan="stdout": source="task"
   [2025-04-07, 06:51:13] INFO - print a.txt: chan="stdout": source="task"
   [2025-04-07, 06:51:13] INFO - filter b.zip: chan="stdout": source="task"
   [2025-04-07, 06:51:13] INFO - print None: chan="stdout": source="task"
   [2025-04-07, 06:51:13] INFO - filter c.txt: chan="stdout": source="task"
   [2025-04-07, 06:51:13] INFO - print c.txt: chan="stdout": source="task"
   ```
   
   1. `return_files` returns a list of three items.
   2. For each item in the list, `filter_file_extension` is called.
   3. Items returns by all `filter_file_extension` calls are collected into a 
list.
   4. The `for` loop iterates over the list and prints each item in it.
   
   Not sure what I’m missing here.


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