ebonite.core.analyzer package

class ebonite.core.analyzer.Hook[source]

Bases: abc.ABC

Base class for Hooks

can_process(obj) → bool[source]

Must return True if obj can be processed by this hook

Parameters:obj – object to analyze
Returns:True or False
must_process(obj) → bool[source]

Must return True if obj must be processed by this hook. “must” means you sure that no other hook should handle this object, for example this hook is for sklearn objects and obj is exactly that.

Parameters:obj – object to analyze
Returns:True or False
process(obj, **kwargs)[source]

Analyzes obj and returns result. Result type is determined by specific Hook class sub-hierarchy

Parameters:
  • obj – object to analyze
  • kwargs – additional information to be used for analysis
Returns:

analysis result

ebonite.core.analyzer.analyzer_class(hook_type: type, return_type: type)[source]

Function to create separate hook hierarchies for analyzing different objects

Parameters:
  • hook_type – Subtype of Hook
  • return_type – Type that this hierarchy will use as analysis result
Returns:

Analyzer type

class ebonite.core.analyzer.CanIsAMustHookMixin[source]

Bases: ebonite.core.analyzer.base.Hook

Mixin for cases when can_process equals to must_process

can_process(obj) → bool[source]

Returns same as Hook.must_process()

class ebonite.core.analyzer.BaseModuleHookMixin[source]

Bases: ebonite.core.analyzer.base.CanIsAMustHookMixin, ebonite.core.analyzer.base.Hook

Mixin for cases when hook must process all objects with certain base modules

is_valid_base_module_name(module_name: str) → bool[source]

Must return True if module_name is valid for this hook

Parameters:module_name – module name
Returns:True or False
is_valid_base_module(base_module: module) → bool[source]

Returns True if module is valid

Parameters:base_module – module object
Returns:True or False
must_process(obj)[source]

Returns True if obj has valid base module

class ebonite.core.analyzer.TypeHookMixin[source]

Bases: ebonite.core.analyzer.base.CanIsAMustHookMixin

Mixin for cases when hook must process objects of certain types

valid_types = None
must_process(obj) → bool[source]

Returns True if obj is instance of one of valid types