config
Utilities for parsing a [tool.nnbench]
config block out of a pyproject.toml file.
ContextProviderDef
dataclass
¶
A POD struct representing a custom context provider definition in a pyproject.toml table.
Source code in src/nnbench/config.py
classpath
instance-attribute
¶
Full path to the class or callable returning the context dict.
arguments
class-attribute
instance-attribute
¶
Arguments needed to instantiate the context provider class, given as key-value pairs in the table. If the class path points to a function, no arguments may be given.
NNBenchConfig
dataclass
¶
Source code in src/nnbench/config.py
context
instance-attribute
¶
context: list[ContextProviderDef]
A list of context provider definitions found in pyproject.toml.
from_toml
classmethod
¶
Returns an nnbench CLI config by processing fields obtained from parsing a [tool.nnbench] block in a pyproject.toml file.
PARAMETER | DESCRIPTION |
---|---|
d
|
Mapping containing the [tool.nnbench] table contents,
as obtained by
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An nnbench config instance with the values from pyproject.toml, and defaults for values that were not set explicitly. |
Source code in src/nnbench/config.py
locate_pyproject ¶
Locate a pyproject.toml file by walking up from the current directory,
and checking for file existence, stopping at stop
(by default, the
current user home directory).
If no pyproject.toml file can be found at any level, returns None.
RETURNS | DESCRIPTION |
---|---|
PathLike[str] | None
|
The path to pyproject.toml. |
Source code in src/nnbench/config.py
parse_nnbench_config ¶
parse_nnbench_config(pyproject_path: str | PathLike[str] | None = None) -> NNBenchConfig
Load an nnbench config from a given pyproject.toml file.
If no path to the pyproject.toml file is given, an attempt at autodiscovery will be made. If that is unsuccessful, an empty config is returned.
PARAMETER | DESCRIPTION |
---|---|
pyproject_path
|
Path to the current project's pyproject.toml file, optional.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
NNBenchConfig
|
The loaded config if found, or a default config. |