fastoad.module_management.service_registry module

Module for registering services.

class fastoad.module_management.service_registry.RegisterService(provider_id: str, desc=None, domain: Optional[fastoad.module_management.constants.ModelDomain] = None, options: Optional[dict] = None)[source]

Bases: object

Decorator class that allows to register a service, associated to a base class (or interface).

The registered class must inherit from this base class.

The definition of the base class is done by subclassing, e.g.:

class RegisterSomeService( RegisterService, base_class=ISomeService):
    "Allows to register classes that implement interface ISomeService."

Then basic registering of a class is done with:

@RegisterSomeService("my.particularservice")
class ParticularService(ISomeService):
    ...
Parameters
  • provider_id – the identifier of the service provider to register

  • desc – description of the service. If not provided, the docstring will be used.

  • domain – a category for the registered service provider

  • options – a dictionary of options that can be associated to the service provider

service_id: str
classmethod explore_folder(folder_path: str)[source]

Explores provided folder and looks for service providers to register.

Parameters

folder_path

classmethod get_provider_ids()List[str][source]
Returns

the list of identifiers of providers of the service.

classmethod get_provider(service_provider_id: str, options: Optional[dict] = None)Any[source]

Instantiates the desired service provider.

Parameters
  • service_provider_id – identifier of a registered service provider

  • options – options that should be associated to the created instance

Returns

the created instance

classmethod get_provider_description(instance_or_id: Union[str, fastoad.module_management.service_registry.T])str[source]
Parameters

instance_or_id – an identifier or an instance of a registered service provider

Returns

the description associated to given instance or identifier

classmethod get_provider_domain(instance_or_id: Union[str, openmdao.core.system.System])fastoad.module_management.constants.ModelDomain[source]
Parameters

instance_or_id – an identifier or an instance of a registered service provider

Returns

the model domain associated to given instance or identifier

class fastoad.module_management.service_registry.RegisterPropulsion(provider_id: str, desc=None, domain: Optional[fastoad.module_management.constants.ModelDomain] = None, options: Optional[dict] = None)[source]

Bases: fastoad.module_management.service_registry._RegisterOpenMDAOService

Decorator class for registering an OpenMDAO wrapper of a propulsion-dedicated model.

Parameters
  • provider_id – the identifier of the service provider to register

  • desc – description of the service. If not provided, the docstring will be used.

  • domain – a category for the registered service provider

  • options – a dictionary of options that can be associated to the service provider

service_id: str = 'fastoad.wrapper.propulsion'
class fastoad.module_management.service_registry.RegisterOpenMDAOSystem(provider_id: str, desc=None, domain: Optional[fastoad.module_management.constants.ModelDomain] = None, options: Optional[dict] = None)[source]

Bases: fastoad.module_management.service_registry._RegisterOpenMDAOService

Decorator class for registering an OpenMDAO system for use in FAST-OAD configuration.

If a variable_descriptions.txt file is in the same folder as the class module, its content is loaded (once, even if several classes are registered at the same level).

Parameters
  • provider_id – the identifier of the service provider to register

  • desc – description of the service. If not provided, the docstring will be used.

  • domain – a category for the registered service provider

  • options – a dictionary of options that can be associated to the service provider

classmethod explore_folder(folder_path: str)[source]

Explores provided folder and looks for OpenMDAO systems to register.

Also, if there is a file for variable description at root of provided folder, it is read.

Parameters

folder_path

classmethod get_system(identifier: str, options: Optional[dict] = None)openmdao.core.system.System[source]

Specialized version of RegisterService.get_provider() that allows to define OpenMDAO options on-the-fly.

Parameters
  • identifier – identifier of the registered class

  • options – option values at system instantiation

Returns

an OpenMDAO system instantiated from the registered class

service_id: str = 'fast.openmdao.system'