molfeat.plugins
¶
BaseFactory(group, name, load=True)
¶
Return the plugin class registered under a given entry point group and name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
entry point group |
required |
name |
str
|
entry point name |
required |
load |
bool
|
if True, load the matched entry point and return the loaded resource instead of the entry point itself. |
True
|
Return: the plugin class Raises: MissingEntryPointError: entry point was not registered MultipleEntryPointError: entry point could not be uniquely resolved LoadingEntryPointError: entry point could not be loaded
Source code in molfeat/plugins/factories.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
CalculatorFactory(entry_point_name, load=True, entry_point_group=None)
¶
Return the SerializableCalculator
sub class registered under the given entry point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point_name |
str
|
the entry point name. |
required |
load |
bool
|
if True, load the matched entry point and return the loaded resource instead of the entry point itself. |
True
|
entry_point_group |
Optional[str]
|
the optional entry point group to use |
None
|
Return
sub class of class:~molfeat.calc.SerializableCalculator
Source code in molfeat/plugins/factories.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
DefaultFactory(entry_point_name, load=True, entry_point_group=None)
¶
Return the Default factory for extending capabilities given a specific module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point_name |
str
|
the entry point name. |
required |
load |
bool
|
if True, load the matched entry point and return the loaded resource instead of the entry point itself. |
True
|
entry_point_group |
str
|
the optional entry point group to use |
None
|
Returns:
Type | Description |
---|---|
Union[EntryPoint, Type[PretrainedMolTransformer], Callable]
|
sub class or module of |
Raise
InvalidEntryPointTypeError: if the type of the loaded entry point is invalid.
Source code in molfeat/plugins/factories.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
PretrainedTransformerFactory(entry_point_name, load=True, entry_point_group=None)
¶
Return the PretrainedMolTransformer sub class registered under the given entry point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point_name |
str
|
the entry point name. |
required |
load |
bool
|
if True, load the matched entry point and return the loaded resource instead of the entry point itself. |
True
|
entry_point_group |
Optional[str]
|
the optional entry point group to use |
None
|
Returns:
Type | Description |
---|---|
Union[EntryPoint, Type[PretrainedMolTransformer], Callable]
|
sub class of class: |
Raise
InvalidEntryPointTypeError: if the type of the loaded entry point is invalid.
Source code in molfeat/plugins/factories.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
TransformerFactory(entry_point_name, load=True, entry_point_group=None)
¶
Return the MoleculeTransformer
sub class registered under the given entry point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point_name |
str
|
the entry point name. |
required |
load |
bool
|
if True, load the matched entry point and return the loaded resource instead of the entry point itself. |
True
|
entry_point_group |
Optional[str]
|
the optional entry point group to use |
None
|
Returns:
Type | Description |
---|---|
Union[EntryPoint, Type[MoleculeTransformer], Callable]
|
sub class of class: |
Raise
InvalidEntryPointTypeError: if the type of the loaded entry point is invalid.
Source code in molfeat/plugins/factories.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
raise_invalid_type_error(entry_point_name, entry_point_group, valid_classes)
¶
Raise an InvalidEntryPointTypeError
with formatted message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point_name |
str
|
name of the entry point |
required |
entry_point_group |
str
|
name of the entry point group |
required |
valid_classes |
Tuple[Any, ...]
|
tuple of valid classes for the given entry point group |
required |
Raises:
Type | Description |
---|---|
InvalidEntryPointTypeError
|
always |
Source code in molfeat/plugins/factories.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
get_entry_point(group, name)
¶
Return an entry point with a given name within a specific group Args: group: the entry point group name: the name of the entry point
Source code in molfeat/plugins/entry_point.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
get_entry_points(group)
¶
Return a list of all the entry points within a specific group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
the entry point group |
required |
Returns:
Type | Description |
---|---|
a list of entry points |
Source code in molfeat/plugins/entry_point.py
74 75 76 77 78 79 80 81 82 83 84 |
|
is_registered_entry_point(class_module, class_name, groups=None)
cached
¶
Verify whether the class with the given module and class name is a registered entry point.
Note
This function only checks whether the class has a registered entry point. It does explicitly not verify
if the corresponding class is also importable. Use load_entry_point
for this purpose instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_module |
str
|
the module of the class |
required |
class_name |
str
|
the name of the class |
required |
groups |
Optional[Sequence[str]]
|
optionally consider only these entry point groups to look for the class |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if the class is a registered entry point, False otherwise. |
Source code in molfeat/plugins/entry_point.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
load_entry_point(group, name)
¶
Load the class registered under the entry point for a given name and group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
the entry point group |
required |
name |
str
|
the name of the entry point |
required |
Returns:
Type | Description |
---|---|
Any
|
class registered at the given entry point |
Raises:
Type | Description |
---|---|
MissingEntryPointError
|
if the entry point was not registered |
MultipleEntryPointError
|
if the entry point could not be uniquely resolved |
LoadingEntryPointError
|
if the entry point could not be loaded |
Source code in molfeat/plugins/entry_point.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
load_registered_plugins(add_submodules=True, groups=None, plugins=None, verbose=True)
¶
Load all registered entry points by loading them with the corresponding factory and adding them to the corresponding module attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
add_submodules |
bool
|
if True, add the loaded entry point to the corresponding module attribute. |
True
|
groups |
Optional[List[str]]
|
if provided, only load entry points from the given groups. |
None
|
plugins |
Optional[List[str]]
|
if provided, only load entry points or modules/classes that matches entry in the plugins list. |
None
|
verbose |
bool
|
if True, log a warning if an entry point cannot be loaded. |
True
|
Raises:
Type | Description |
---|---|
EntryPointError
|
if any of the registered entry points cannot be loaded. This can happen if: * The entry point cannot uniquely be resolved * The resource registered at the entry point cannot be imported * The resource's type is incompatible with the entry point group that it is defined in. |
Source code in molfeat/plugins/entry_point.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
validate_registered_entry_points()
¶
Validate all registered entry points by loading them with the corresponding factory.
Raises:
Type | Description |
---|---|
EntryPointError
|
if any of the registered entry points cannot be loaded. This can happen if: * The entry point cannot uniquely be resolved * The resource registered at the entry point cannot be imported * The resource's type is incompatible with the entry point group that it is defined in. |
Source code in molfeat/plugins/entry_point.py
131 132 133 134 135 136 137 138 139 140 141 142 143 |
|