factory module¶
Scalable model factory¶
This module contains the ScalableModelFactory
which is a factory
to create a ScalableModel
from its class name by means of the
ScalableModelFactory.create()
method. It is also possible to get a list
of available scalable models
(see ScalableModelFactory.scalable_models
method)
and to check is a type of scalable model is available
(see ScalableModelFactory.is_available()
method)
- class gemseo.problems.scalable.data_driven.factory.ScalableModelFactory[source]¶
Bases:
BaseFactory
This factory instantiates a class:.ScalableModel from its class name.
The class can be internal to GEMSEO or located in an external module whose path is provided to the constructor.
- Return type:
- create(model_name, data, sizes=None, **parameters)[source]¶
Create a scalable model.
- Parameters:
model_name (str) – name of the scalable model (its class name)
data (Dataset) – learning dataset.
sizes (dict) – sizes of input and output variables. If
None
, use the original sizes. Default: None.parameters – model parameters
class_name – The name of the class.
**args – The positional arguments to be passed to the class constructor.
**kwargs – The keyword arguments to be passed to the class constructor.
- Returns:
model_name scalable model
- Returns:
The instance of the class.
- Raises:
TypeError – If the class cannot be instantiated.
- get_class(name)¶
Return a class from its name.
- Parameters:
name (str) – The name of the class.
- Returns:
The class.
- Raises:
ImportError – If the class is not available.
- Return type:
- get_default_option_values(name)¶
Return the constructor kwargs default values of a class.
- get_default_sub_option_values(name, **options)¶
Return the default values of the sub options of a class.
- Parameters:
- Returns:
The JSON grammar.
- Return type:
- get_library_name(name)¶
Return the name of the library related to the name of a class.
- get_options_doc(name)¶
Return the constructor documentation of a class.
- get_options_grammar(name, write_schema=False, schema_path=None)¶
Return the options JSON grammar for a class.
Attempt to generate a JSONGrammar from the arguments of the __init__ method of the class.
- Parameters:
- Returns:
The JSON grammar.
- Return type:
- get_sub_options_grammar(name, **options)¶
Return the JSONGrammar of the sub options of a class.
- Parameters:
- Returns:
The JSON grammar.
- Return type:
- is_available(name)¶
Return whether a class can be instantiated.
- update()¶
Search for the classes that can be instantiated.
- The search is done in the following order:
The fully qualified module names
The plugin packages
The packages from the environment variables
- Return type:
None