Why is one of my parameters None on retry?

I’m having an issue with a subclassed Task where the initial execution gets a parameter, but subsequent retries supply None instead.

Essentially what I have is

class TaskWithCommand(ShellTask):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def run(self, command, folder_1, folder_2, folder_3):
        to_run = f"{command} '{folder_1}' '{folder_2}' '{folder_3}'"
        output_lines = super().run(command=to_run)
        return output_lines[-1]

run_command_task = TaskWithCommand(
    log_stderr=True, 
    return_all=True,
    max_retries=1,
    retry_delay=datetime.timedelta(minutes=30),
)


with Flow("example_flow",) as flow:
    
    folder_1 = Parameter("folder_1", DEFAULT_1)
    folder_2 = Parameter("folder_2", DEFAULT_2)
    folder_3 = generate_folder()

    command_output = run_command_task(
        f"script.sh",
        folder_1,
        folder_2,
        folder_3,
    )

Interestingly, folder_1 and folder_2 come through fine, but folder_3 is None on subsequent retries, and I don’t see this when my retry interval is on the order of minutes, but only on the order of 30 minutes.

1 Like

Wow, this is really interesting! It’s likely some issue between build-time vs run-time. It could be an issue in flow serialization. This docs page explains it more

Basically, when you use flow.register() it will by default use pickle storage, and when you use the CLI
prefect register, then it will use script storage.

Script storage would be beneficial for you to avoid that build-time vs. run-time nuances.

If this doesn’t help you can:

  • try switching to functional API instead of imperative API and see if the issue persists
  • share a full example (e.g. with a simple ls command) I can reproduce and I could try to see if I get the same error or can give you more details.