Skip to content

How to parallelize assets testing in pytest ? #17930

Answered by alangenfeld
louistransfer asked this question in Q&A
Discussion options

You must be logged in to vote

Materialize to memory approach

If the assets are independent and I/O bound instead of compute bound, you can run the materialize_to_memory calls for each asset in threads for concurrency. Something like this:

def test_all_apis(load_env):
    api_client = APIClient()

    def _run_asset(a) -> bool:
        result = materialize_to_memory(
            [a],
            resources={"api_client": api_client},
        )
        return result.success

    with ThreadPoolExecutor() as executor:
        results = executor.map(_run_asset, [orders_api, sales_api, category_api])
        assert all(results)

Temporary reconstructable job approach

So the rules for reconstructable are just that it has to …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@louistransfer
Comment options

Answer selected by louistransfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants