Support custom tmp dir location in prefect_test_harness
First check
- I added a descriptive title to this issue.
- I used the GitHub search to find a similar request and didn't find it.
- I searched the Prefect documentation for this feature.
Prefect Version
2.x
Describe the current behavior
prefect_test_harness sets up a temporary database under /tmp (or whichever tmp directory is configured when the process starts). When running under pytest it would be useful to be able to set the location of the temp directory so that the test database generated is automatically cleaned up by pytest whenever necessary (typically it keeps 10 test runs).
The implementation could be quite simple - just pass optional keywords from prefect_test_harness into TemporaryDirectory.
Describe the proposed behavior
Either a tmp main directory, or a folder where the prefect data (including the db ) should be stored can be provided to the test harness.
Example Use
A pytest fixture could be set up like this
@fixture(scope='session', autouse=True)
def prefect_harness(tmpdir):
wd = tmp_path_factory.mktemp(".prefect")
with prefect_test_harness(path=str(wd)):
yieldThe database would be stored as <PYTEST_TMP_DIR/.prefect/prefect-test.db
Additional context
No response
Source: PrefectHQ/prefect