rpeden / prefect-docker-compose

A repository that makes it easy to get up and running with Prefect 2 using Docker Compose.
115 stars 23 forks source link

Skip State Implementation in prefect #7

Closed NonlinearNimesh closed 1 year ago

NonlinearNimesh commented 1 year ago

Hi Everyone, sorrect me if i am wrong but prefect 2 does not has a skip state feature, so i was trying to implement the same using conditional flow using if else. for example here is my snipped of flow

@flow(name="Inferencing")
def start_inferencing(my_param, file_path):
    job_id = my_param
    algo_id = "402"
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>")
    print(algo_id, job_id, file_path)
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>")
    res_1 = generate_jobID.submit(algo_id, job_id)
    print("\n\n\n\n ***************************\n\n\n\n ", res_1, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_1)
    res_2 = get_file.submit(file_path)
    print("\n\n\n\n ***************************\n\n\n\n ", res_2, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_2)
    res_4 = choose_valid_file.submit(prev_task=res_2)
    print("\n\n\n\n ***************************\n\n\n\n ", res_4, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_4)
    res_5 = prepare_request_upload.submit(prev_task=res_4)
    print("\n\n\n\n ***************************\n\n\n\n ", res_5, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_5)
    res_6 = send_data_request.submit(prev_task=res_5)
    print("\n\n\n\n ***************************\n\n\n\n ", res_6, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_6)
    res_7 = prepare_predict_request.submit(prev_task=res_6)
    print("\n\n\n\n ***************************\n\n\n\n ", res_7, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_7)
    res_8 = send_predict_request.submit(prev_task=res_7)
    print("\n\n\n\n ***************************\n\n\n\n ", res_8, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_8)
    res_9 = extract_lunit_jobid.submit(prev_task=res_8)
    print("\n\n\n\n ***************************\n\n\n\n ", res_9, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_9)
    res_10 = prepare_fetch.submit(prev_task=res_9)
    print("\n\n\n\n ***************************\n\n\n\n ", res_10, "\n\n\n\n ****************************\n\n\n\n")
    call_on_failure_if_failed(res_10)
    res_11 = fetch_request.submit(prev_task=res_10)
    call_on_failure_if_failed(res_11)
    print("\n\n\n\n ***************************\n\n\n\n ", res_11, "\n\n\n\n ****************************\n\n\n\n")
    if res_11:
        res_12 = convert_output.submit(prev_task=res_11)
        call_on_failure_if_failed(res_12)
        res_13 = zip_file.submit(prev_task=res_12)
        call_on_failure_if_failed(res_13)
        res_14 = send_to_HGW.submit(prev_task=res_13)
        call_on_failure_if_failed(res_14)
    else:
        send_log()

if name == "main": start_inferencing402(parameters=dict) the function res_12, res_13, res_14 i want to execute only if the res_11 gives True, By the way every function returns either true or false, Problem: Not even one print statement is execuiting, Also even if the res_11 is false then also res_12, res_13, res_14 is getting executed, Can anyone please tell me what i am doing wrong

NonlinearNimesh commented 1 year ago

There was the version issue in my code, i was pulling the older version of code that is why i was not able to see prints.