Skip to content

Optional Extras

Tracks classes gated behind an uninstalled optional extra (deepeval/ragas/langchain).

Each gllm_evals module that guards an import behind a try/except ImportError records, via mark_unavailable, which class names required which extra. Any caller that needs to turn a class name into an actionable "pip install ..." message reads the merged view back via merge_unavailable_extras.

mark_unavailable(registry, names, extra)

Record that names are unavailable because extra isn't installed.

Parameters:

Name Type Description Default
registry dict[str, str]

The calling module's own _UNAVAILABLE_EXTRAS dict.

required
names list[str]

The class names that failed to import.

required
extra str

The optional extra that would make them available (e.g. "deepeval").

required

merge_unavailable_extras(module, submodule_names=())

Merge a module's own _UNAVAILABLE_EXTRAS with the same attribute off each named submodule.

Parameters:

Name Type Description Default
module ModuleType

The package whose own _UNAVAILABLE_EXTRAS to start from.

required
submodule_names tuple[str, ...]

Attribute names of submodules to merge in, if any.

()

Returns:

Type Description
dict[str, str]

dict[str, str]: The merged class-name -> extra(s) map.