Hi everyone, I have a question regarding writing t...
# prefect-community
n
Hi everyone, I have a question regarding writing tests. I have a flow that uses LocalResult to store some data, however by default it uses ~/.prefect folder, I want to test the execution, but do not want the results when running the test to be stored there, but to some dedicated test folder. How can I change the config.home_dir during the test? I've tried it in such a way
Copy code
from prefect.utilities.configuration import set_temporary_config

def test_prefect(input_folder, output_folder):
    with set_temporary_config({"home_dir": output_folder}):  
        exec_config = ExecutionConfig(dataset_location=os.path.join(get_path('parquet'), 'pq-dataset'),
                                      save_location=os.path.join(output_folder, 'mean_ndvi_results'))

        status = flow.run(executor=LocalExecutor(), flow_config=asdict(exec_config))

        assert status.is_successful()
(took a look at some tests in the prefect source), but it doesnt work at still writes LocalResult results to ~/.prefect
c
Hi @Nejc Vesel and apologies for the delay; I recommended updating the
LocalResult
itself to use your test directory. The
LocalResult
accepts a
dir
keyword at initialization that allows you to specify alternate directories
n
Hi, sorry I realized was not clear with my question. I have a task that persists some data through a checkpoint.
Copy code
@task(target="{flow_run_name}/chunk/{map_index}.json", checkpoint=True, log_stdout=True, result=RESULT)
def do_something() -> str:
    return chunk_id
How can I make the test so the default target location is not ~/.prefect but a specified test folder. Thank you so much for the help. Best, Nejc