Below is a format of the DAG used, I am using for loop over input files in the DAG and rename the output files using the
CurrentDateTime = datetime.datetime.today().strftime("%Y%m%d%H%M%S")
#if currentDateTIme = 20210406010203
outputfile = ''
outputfile1 = ''
outputfile2 = ''
inputfiles = ['input1', 'input2']
API_CALL_TASK1 = {
source : inputfile1
filename : outputfile1 #20210406010513
}
API_CALL_TASK2 = {
source : inputfile2
filename : outputfile2
}
for file in inputfiles:
if file == 'input1'
outputfile1 = f'inputFileName_{CurrentDateTime}' #20210406010303
outputfile = f'inputFileName_{CurrentDateTime}' #20210406010303
if file == 'input2'
outputfile2 = f'inputFileName_{CurrentDateTime}'
outputfile = f'inputFileName_{CurrentDateTime}'
MOVE_OUTPUT_TO_BUCKET_TASK = (
filename = f{outputfile} #20210406010423
)
MOVE_OUTPUT_TO_BUCKET_TASK >> API_CALL_TASK1 >> API_CALL_TASK1
Here in the tasks - API_CALL_TASK1, API_CALL_TASK2 and to the MOVE_OUTPUT_TO_BUCKET_TASK the datetime in the filename is different as there is difference in time when each task is triggered.
How to get the uniform datetime for each file?
I want to pass the same filename from the loop to the MOVE_OUTPUT_TO_BUCKET_TASK and API_CALL_TASK1 or API_CALL_TASK2