factory module¶
Factory base class¶
-
class
gemseo.core.factory.
Factory
(*args, **kwargs)[source]¶ Bases:
object
- Factory to create extensions that are known to GEMSEO:
can be a MDODiscipline, MDOFormulation… Depending on the subclass
Three types of directories are scanned :
the environment variable “GEMSEO_PATH” may contain the list of directories to scan
internal_modules_paths (such as gemseo.problems…)
a directory list may be passed to the factory
Initializes the factory.
Scans the directories to search for subclasses of MDODiscipline. Searches in “GEMSEO_PATH”, “GEMS_PATH”, and gemseo.problems
- Parameters
base_class – class to search in the modules (MDOFormulation, MDODiscipline…) depending on the subclass
internal_modules_paths – import paths (such as gemseo.problems) which are already imported
name – name of the factory to print when configuration is printed
possible_plugin_names – tuple of plugins packages names to be scanned if they can be imported. The last plugin name has the priority. For instance, if the same class MDAJacobi exists in gemseo.mda, gemseo_plugins.mda and gemseo_private.mda, the used one will be gemseo_private.mda
-
GEMSEO_PATH
= 'GEMSEO_PATH'¶
-
GEMS_PATH
= 'GEMS_PATH'¶
-
PLUGIN_PREFIX
= 'gemseo_'¶
-
property
classes
¶ Return the available classes.
:returns : the list of classes names
-
create
(class_name, **options)[source]¶ Return an instance with given class name.
:param class_name : name of the class :parma options: options to be passed to the constructor
-
get_default_options_values
(name)[source]¶ Return the options default values for the given class name.
Only addresses kwargs
:param name : name of the class :returns: the dict option name: option default value
-
get_default_sub_options_values
(class_name, **options)[source]¶ Return the default values of the sub options of a class.
- Parameters
class_name – name of the class
options – options to be passed to the class required to deduce the sub options
-
get_options_doc
(name)[source]¶ Return the options documentation for the given class name.
- Parameters
name – name of the class
- Returns
the dict of option name: option documentation
-
get_options_grammar
(name, write_schema=False, schema_file=None)[source]¶ Return the options grammar for a class.
Attempts to generate a JSONGrammar from the arguments of the __init__ method of the class
- Parameters
name – name of the class
schema_file – the output json file path. If None: input.json or output.json depending on gramamr type. (Default value = None)
write_schema – if True, writes the schema files (Default value = False)
- Returns
the json grammar for options
-
get_sub_options_grammar
(class_name, **options)[source]¶ Return the JSONGrammar of the sub options of a class.
- Parameters
class_name – name of the class
options – options to be passed to the class required to deduce the sub options