paths
paths
Resolution of the data root, the optional shared cache, and offline mode.
The data root is resolved in this order:
- An explicit path passed by the caller.
- The
FWL_DATAenvironment variable.
There is deliberately no silent fallback: the FWL ecosystem treats
FWL_DATA as required, and inventing a default location would hide
misconfiguration (on clusters it would quietly download gigabytes into a
per-user directory instead of the shared tree). An unset root raises
:class:MissingDataRootError with instructions.
FWL_DATA_CACHE may point at a read-only, pre-populated copy of the data
tree (for example a group-shared directory on a cluster). It is searched
before any download is attempted and is never written to.
FWL_IO_OFFLINE disables all network access when set to a truthy value
(1, true, yes, on). In offline mode a missing or corrupt file
raises an error instead of triggering a download.
MissingDataRootError
Bases: RuntimeError
No data root is configured: FWL_DATA is unset and no path was given.
is_offline()
Return True when FWL_IO_OFFLINE requests fully offline operation.
Source code in src/fwl_io/paths.py
82 83 84 | |
resolve_cache_root()
Return the read-only shared cache root, or None if not configured.
The cache is configured through the FWL_DATA_CACHE environment
variable and is only used when the directory actually exists.
Source code in src/fwl_io/paths.py
67 68 69 70 71 72 73 74 75 76 77 78 79 | |
resolve_data_root(explicit=None)
Return the writable root of the FWL data tree, creating it if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
explicit
|
str | Path | None
|
Caller-supplied override. When None, |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to the data root directory. |
Raises:
| Type | Description |
|---|---|
MissingDataRootError
|
When neither an explicit path nor |
Source code in src/fwl_io/paths.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |