API v2

The correlation_id context manager

firecrest.correlation_id(cid: str | None = None)

Attach a correlation ID to all the requests to FirecREST that are made inside this context. The ID is sent in the X-Correlation-ID header of every request, so all of them can be traced in the server logs as parts of the same logical operation.

with firecrest.correlation_id("my-workflow-1234"):
    client.mkdir("cluster", "/home/user/my-workflow")
    client.submit("cluster", script_local_path="script.sh")

Without this context manager, the clients generate a new correlation ID for every method call.

Parameters:

cid – the correlation ID to use. When None, a random UUID4 is generated. The ID in use is yielded, so it can be captured with as and logged by the caller.