11from __future__ import annotations
22
3- from typing import Optional , TypeVar , Type
3+ from typing import Optional , Type , TypeVar
44
55import cinnamon .configuration
66import cinnamon .registry
77
8- C = TypeVar ('C' , bound = ' Component' )
8+ C = TypeVar ("C" , bound = " Component" )
99
1010__all__ = [
11- ' Component' ,
11+ " Component" ,
1212]
1313
1414
1515class Component :
1616 """
17- A component defines any logic of a program, including data loading, data visualization, and model training.
17+ A component defines any logic of a program, including data loading,
18+ data visualization, and model training.
1819 """
1920
2021 @classmethod
2122 def instantiate (
22- cls : Type [C ],
23- registration_key : Optional [cinnamon .registry .Registration ] = None ,
24- name : Optional [str ] = None ,
25- namespace : Optional [str ] = None ,
26- tags : cinnamon .configuration .Tags = None ,
27- ** build_args
23+ cls : Type [C ],
24+ registration_key : Optional [cinnamon .registry .Registration ] = None ,
25+ name : Optional [str ] = None ,
26+ namespace : Optional [str ] = None ,
27+ tags : cinnamon .configuration .Tags = None ,
28+ ** build_args ,
2829 ) -> C :
2930 """
30- Syntactic sugar for instantiating a ``Component`` from a ``RegistrationKey`` in implicit format.
31+ Syntactic sugar for instantiating a ``Component`` from a
32+ ``RegistrationKey`` in implicit format.
3133
3234 Args:
33- registration_key: the ``RegistrationKey`` used to register the ``Configuration`` class.
35+ registration_key: the ``RegistrationKey`` used to register the
36+ ``Configuration`` class.
3437 name: the ``name`` field of ``RegistrationKey``
3538 tags: the ``tags`` field of ``RegistrationKey``
3639 namespace: the ``namespace`` field of ``RegistrationKey``
@@ -40,18 +43,26 @@ def instantiate(
4043 A ``Component`` instance
4144
4245 Raises:
43- ``InvalidConfigurationTypeException``: if there's a mismatch between the ``Configuration`` class used
44- during registration and the type of the built ``Configuration`` instance using the registered
46+ ``InvalidConfigurationTypeException``: if there's a mismatch
47+ between the ``Configuration`` class used
48+ during registration and the type of the built ``Configuration``
49+ instance using the registered
4550 ``constructor`` method (see ``ConfigurationInfo`` arguments).
4651
47- ``NotBoundException``: if the ``Configuration`` is not bound to any ``Component``.
52+ ``NotBoundException``: if the ``Configuration`` is not bound
53+ to any ``Component``.
4854 """
49- component = cinnamon .registry .Registry .instantiate_component (registration_key = registration_key ,
50- name = name ,
51- tags = tags ,
52- namespace = namespace ,
53- ** build_args )
55+ component = cinnamon .registry .Registry .instantiate_component (
56+ registration_key = registration_key ,
57+ name = name ,
58+ tags = tags ,
59+ namespace = namespace ,
60+ ** build_args ,
61+ )
5462 if not isinstance (component , cls ):
55- raise RuntimeError (f'The instantiated component is not an instance of { cls } . Got { type (component )} ' )
63+ raise RuntimeError (
64+ f"The instantiated component is not an instance of { cls } ."
65+ f" Got { component .__class__ .__name__ } "
66+ )
5667
57- return component
68+ return component
0 commit comments