I am using fileio.WriteToFiles to output stream data to google cloud but the dynamic path is not working.
Current behavior: The current behavior is the output path is always the date I ran the data pipeline on Airflow. It is not calculated dynamically by the current date.
Expected behavior:
I want to output files of my stream apache beam pipeline to google cloud based on the current date when the data is processed. For example, today is July 18. The file needs to be saved to gs://folder/7/18/file_name.txt.
The code is like this:
(input
| "Window into fixed intervals" >> beam.WindowInto(FixedWindows(self.window_size))
| "Write to GCS Bucket" >> fileio.WriteToFiles(
"/".join(['gs://folder',
DateFormat.get_now_for_timezone(date_format='%Y/%m/%d')]),
shards=1,
max_writers_per_bundle=0,
)
)