configure
configure
#
The active scratch: a process-wide default, or one scoped to the current context.
configure installs the default every thread shares (an explicit path, else
CG_SCRATCH); temporary overrides it for one with block in the calling
thread or task only, so a throwaway scratch in one worker never redirects another.
scoped_scratch = ContextVar('cg_scoped_scratch', default=None)
module-attribute
#
The scratch overriding the default in the current context, if any.
active_scratch()
#
The scratch in effect: the context's override, else the default.
The default is configured from CG_SCRATCH on first use.
Raises:
| Type | Description |
|---|---|
ScratchNotConfigured
|
If none is configured and |
Source code in capturegraph-lib/capturegraph/recipes/scratch/configure.py
configure(path=None, *, max_size_gb=None, free_space_ratio=None)
#
Open (or initialize) the process-wide default scratch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | None
|
The scratch root. Defaults to |
None
|
max_size_gb
|
float | None
|
Hard cap on the cache's byte budget, in gigabytes. |
None
|
free_space_ratio
|
float | None
|
Fraction of releasable disk the cache may claim. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The configured scratch's root directory. |
Raises:
| Type | Description |
|---|---|
ScratchNotConfigured
|
If no |