check_model_dependencies

verta.registry.check_model_dependencies(model_cls: Type[VertaModelBase], environment: Python, raise_for_missing: bool = False) bool

Scan for missing dependencies in a model’s environment.

This function attempts to scan the provided model class for 3rd-party (not python standard library) dependencies and identify any missing packages in the provided environment.

Note

This function is not guaranteed to detect all dependencies in all cases, and should be considered a fast sanity check rather than a test.

New in version 0.22.2.

Parameters:
  • model_cls (subclass of VertaModelBase) – Model class (not an instance) to be scanned.

  • environment (Python) – Environment against which to validate pip dependencies.

  • raise_for_missing (bool, default False) – If True, raises an exception if any dependencies detected in the model class are missing from the environment. Defaults to printing a warning.

Returns:

boolTrue if all 3rd-party dependencies detected in the model class have corresponding packages in the environment. False if any are missing.

Raises:

RuntimeError – If raise_for_missing is True and any dependencies are missing.

Examples

 from verta.registry import check_model_dependencies
 from verta.environment import Python

 env = Python(["numpy", "pandas"])
 check_model_dependencies(model_cls=MyModelClass, environment=env)