Engine Extensions

Base class and tools for loading extension metadata into SimPhoNy.

For information on engine entry points, see Extending SimPhoNy

Classes

ABCEngineExtension Base class for all engine extensions.
EngineInterface Represents an available interface to an engine.
EngineMetadata Data structure to represent engine metadata.
EngineFeatureMetadata Represents a set of engine features.
EngineManager Controller class to keep track of engine extensions.
EngineManagerError Any exception related to engine manager.

Functions

create_wrapper(cuds, engine_name[, ...]) Create a wrapper to the given engine.
register(cls) Register an engine extension metadata.
get_supported_engine_names() Show a list of supported engine names.
get_supported_engines() Show a list of supported engines.

Implementation

Simphony engine module

This module is dynamically populated at import with the registered plugins modules. Plugins modules need to be registered at the ‘simphony.engine’ entry point.

simphony.engine.create_wrapper(cuds, engine_name, engine_interface=None)[source]

Create a wrapper to the given engine.

Parameters:
  • cuds (CUDS) – a cuds object which contains model information
  • engine_name (str) – name of the underlying engine to launch the simulation with
  • engine_interface (engine.EngineInterface) – the interface to the engine, internal or fileio
Returns:

wrapper – an engine wrapper instance

Return type:

engine.ABCEngineExtension

simphony.engine.get_supported_engines()[source]

Show a list of supported engines.

Returns:metadata – a list of engine metadata objects
Return type:list
simphony.engine.get_supported_engine_names()[source]

Show a list of supported engine names.

Returns:names – a list of engine names
Return type:list
class simphony.engine.ABCEngineExtension[source]

Bases: object

Base class for all engine extensions.

static create_engine_metadata(name, features, interfaces)[source]

Factory method to create engine metadata.

Parameters:
  • name (str) – fixed name of a support engine to be used in user’s data, i.e. key
  • features (list) – features of this engine as a list of EngineFeatureMetadata objects
  • interfaces (list) – supported engine interfaces as a list of engine.EngineInterface enums
Returns:

EngineMetadata

Return type:

a loaded engine metadata object

static create_engine_metadata_feature(physics_equation, methods)[source]

Factory method to create engine metadata feature.

Parameters:
  • physics_equation (PhysicsEquation) – represents a physics equation
  • methods (list) – ComputationalMethod objects to solve the equation
Returns:

EngineFeatureMetadata

Return type:

a loaded engine metadata feature object

create_wrapper(cuds, engine_name, engine_interface)[source]

Creates a wrapper to the requested engine.

Parameters:
  • cuds (CUDS) – CUDS computational model data
  • engine_name (str) – name of the engine, must be supported by this extension
  • engine_interface (engine.EngineInterface) – the interface to interact with engine
Returns:

ABCEngineExtension

Return type:

A wrapper configured with cuds and ready to run

get_supported_engines()[source]

Get metadata about supported engines.

Returns:list
Return type:a list of EngineMetadata objects
class simphony.engine.EngineInterface[source]

Bases: enum.Enum

Represents an available interface to an engine.

An interface is either internal or fileio. Internal interfaces use a python package or a shared library to talk to the underlying engine. FileIO, on the other hand, uses input/output files to interact with an engine executable.

FileIO = <EngineInterface.FileIO: 'fileio'>
Internal = <EngineInterface.Internal: 'internal'>

Engine extension tools and classes.

class simphony.engine.extension.EngineFeatureMetadata(physics_equation, methods)[source]

Bases: object

Represents a set of engine features.

A feature provides a set of methods to solve a physics equation.

Parameters:
  • physics_equation (PhysicsEquation) – represents a physics equation
  • methods (list) – methods to solve the equation as a list of ComputationalMethod objects
class simphony.engine.extension.EngineMetadata(name, features, interfaces)[source]

Bases: object

Data structure to represent engine metadata.

This class represents one supported engine along with its features.

Parameters:
  • name (str) – fixed name of a support engine to be used in user’s data, i.e. key
  • features (list) – features of this engine as a list of EngineFeatureMetadata objects
  • interfaces (list) – supported engine interfaces as a list of engine.EngineInterface enums
class simphony.engine.extension.EngineManager[source]

Bases: object

Controller class to keep track of engine extensions.

create_wrapper(cuds, engine_name, engine_interface=None)[source]

Create a wrapper to the given engine.

Parameters:
  • cuds (CUDS) – a cuds object which contains model information
  • engine_name (str) – name of the underlying engine to launch the simulation with
  • engine_interface (engine.EngineInterface) – the interface to the engine, internal or fileio
get_supported_engine_names()[source]

Show a list of supported engines.

Returns:names – a list of engine names
Return type:list
get_supported_engines()[source]

Get metadata about supported engines.

Returns:metadata – a list of EngineMetadata objects
Return type:list
register_extension(cls)[source]

Register an engine extension class.

Parameters:cls (ABCEngineExtension) – a subclass of base extension metadata type

Engine related exceptions.

exception simphony.engine.exceptions.EngineManagerError[source]

Bases: exceptions.Exception

Any exception related to engine manager.

Engine related decorators.

simphony.engine.decorators.register(cls)[source]

Register an engine extension metadata.

Parameters:cls (ABCEngineExtension) – a subclass of base extension metadata type