0

I have a simple DAG which goes like this:

start >> create_cluster >> run_code >> delete_cluster >> end

The run_code runs a python script which is stored in Google Cloud Storage. This python script runs multiple functions to produce the output.

I would like to know if the runtime of these functions can be fetched.

1 Answers1

0

Assuming you are using the PythonOperator for the run_code task:

For your run_code task's function, you can simply add the following:

import time

def run_code_function():
    # Starting the function.
    start_time = time.time() 

    # Business Code Logic...

    # You can log it as well
    print("--- %s seconds ---" % (time.time() - start_time))
    return important_stuff

To investigate more about it, check here.

Printing these values will give you the result at the log file where you initialized your DAG.