index#

hydromodpy.index(db_path=None, *, read_only=True)[source]#

Open the machine-wide global index that federates registered projects.

One row is one project root, since a project root is what owns an index database. Registering a workspace root expands it into the project roots it holds.

Read-only by default, mirroring open(): browsing the federation index never migrates it or touches its mtime, and a reader never contends with a concurrent solve. Pass read_only=False for the writable handle used to register / unregister / prune.

Return type:

GlobalIndex

Parameters:

Parameters#

db_path

Optional path to the index DuckDB file. None uses the default machine-state location.

read_only

Open the index in read-only mode (default True). Writes (register, unregister, prune) will raise. Pure reads (search, find, list_projects) keep working while another process holds the write-lock.

Returns#

GlobalIndex

Index object exposing register, unregister, list_projects, find, search and prune.

Raises#

RuntimeError

If a mutating method is called on a read-only handle.

duckdb.IOException

If the index database cannot be opened due to non-lock I/O errors.

Examples#

>>> import hydromodpy as hmp
>>> idx = hmp.index(read_only=True)  
>>> idx.list_projects()  

See Also#

hydromodpy.core.state.global_index.GlobalIndex

Underlying federation implementation.

param db_path:

type db_path:

Any

param read_only:

type read_only:

bool