hmp.index#

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

Signature#

hmp.index(db_path=None, *, read_only=False) -> GlobalIndex

Reference#

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

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

Return type:

Any

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. Writes (register_workspace, forget, prune) will raise. Pure reads (search, find, list_workspaces) keep working while another process holds the write-lock.

Returns#

GlobalIndex

Index object exposing register_workspace, find, search, prune and forget.

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_workspaces()  

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

Example#

import hydromodpy as hmp

idx = hmp.index(read_only=True)
workspaces = idx.list_workspaces()

See Also#