Skip to content

Enables the launcher to cache output #2

@Nanguage

Description

@Nanguage
  1. Cache the launcher function's output
  2. Cache the file output: check if specified output file are exist, and only start the job when file not exist.

Example:

@launcher(cache='disk')
def add(a, b):
    return a + b

res = add(1, 2)  # will start job
res = add(1, 2)  # will directly load result from cache

# cache file output
from executor.engine.launcher import file_output

@launcher(cache='disk')
@file_output('{name}.txt')
def generate_hellos(name: str, times: int):
    with open(name + '.txt', 'w') as f:
        for _ in range(times):
            f.write(f"Hello {name}\n")

generate_hellos('Tom', 10)  # will start job
generate_hellos('Tom', 10)  # will not start job
generate_hellos('Mike', 10) # will start job

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions