Skip to content

Config

Helpers for producing and validating Valhalla configuration JSON. The result of get_config can be passed directly to Actor or written to a file for valhalla_service.

get_config

get_config(tile_extract: Union[str, Path] = 'valhalla_tiles.tar', tile_dir: Union[str, Path] = 'valhalla_tiles', verbose: bool = False) -> dict

Returns a default Valhalla configuration.

PARAMETER DESCRIPTION
tile_extract

The file path (with .tar extension) of the tile extract (mjolnir.tile_extract), if present. Preferred over tile_dir.

TYPE: Union[str, Path] DEFAULT: 'valhalla_tiles.tar'

tile_dir

The directory path where the graph tiles are stored (mjolnir.tile_dir), if present.

TYPE: Union[str, Path] DEFAULT: 'valhalla_tiles'

verbose

Whether you want to see Valhalla's logs on stdout (mjolnir.logging). Default False.

TYPE: bool DEFAULT: False

get_help

get_help() -> Dict[str, Union[Dict[str, str], str]]

Returns the help dictionary with the same keys as the config JSON.

parse_and_validate_config

parse_and_validate_config(config: Union[Path, str, dict]) -> Tuple[str, TypingOptional[str]]

Parse and validate Valhalla configuration.

Accepts configuration as Path, str (file path or JSON), or dict. Validates that required mjolnir settings exist and tile data is accessible.

PARAMETER DESCRIPTION
config

Valhalla configuration as Path, string, or dict

TYPE: Union[Path, str, dict]

RETURNS DESCRIPTION
Tuple[str, Optional[str]]

(config_path, temp_file_path) where temp_file_path is None for non-dict configs

RAISES DESCRIPTION
AttributeError

Invalid config type or missing mjolnir.tile_extract/tile_dir

FileNotFoundError

Config file not found, invalid JSON, or tile data doesn't exist

json.JSONDecodeError

Invalid JSON in string