pynestml.frontend package

Submodules

pynestml.frontend.frontend_configuration module

class pynestml.frontend.frontend_configuration.FrontendConfiguration

Bases: object

This class encapsulates all settings as handed over to the frontend at start of the toolchain.

DEFAULT_TARGET_PATH_: str = 'target'
argument_parser = None
codegen_opts: Mapping[str, Any] = {}
codegen_opts_fn = ''
classmethod get_codegen_opts()

Get the code generator options dictionary

classmethod get_files()

Returns a list of all files to process. :return: a list of paths to files as str. :rtype: list(str)

classmethod get_install_path() str

Path to the directory where the generated code will be installed. :return: the install path.

classmethod get_is_dev()

Returns whether the development mode has been enabled. :return: True if development mode is enabled, otherwise False. :rtype: bool

classmethod get_logging_level()

Returns the set logging level. :return: the logging level :rtype: LoggingLevel

classmethod get_module_name()

Returns the name of the module. :return: the name of the module. :rtype: str

classmethod get_provided_input_path() Sequence[str]

Returns the list of file and directory names as supplied by the user. :return: a list of file and directory names

classmethod get_target_path() str

Returns the path to which models shall be generated to. :return: the target path.

classmethod get_target_platform()

Get the name of the target platform. :return: None or “” in case no code needs to be generated :rtype: str

classmethod handle_codegen_opts_fn(codegen_opts_fn)

If a filename of a JSON file containing code generator options is passed on the command line, read it into a Python dictionary

classmethod handle_input_path(path) None

Sets cls.paths_to_compilation_units with a list of absolute paths to NESTML files.

Use glob to search directories recursively.

classmethod handle_install_path(path: str | None) None

Process the installation path parameter.

Create the installation path directory if it is specified as a string, but does not exist. Its parent directory has to exist already. The path will not be created if path is None.

classmethod handle_module_name(module_name)

parse or compose the module name

classmethod handle_target_path(path: str | None) None

Process the target path parameter.

Create the target path directory if it is specified as a string, but does not exist. Its parent directory has to exist already.

If the path is None, it will default to FrontendConfiguration.DEFAULT_TARGET_PATH_ in the current working directory.

classmethod handle_target_platform(target_platform: str | None)
install_path = None
is_dev = False
logging_level = None
module_name = None
classmethod parse_config(args)

Standard constructor. This method parses the :param args: a set of arguments as handed over to the frontend :type args: list(str)

paths_to_compilation_units = None
provided_input_path = None
classmethod set_codegen_opts(codegen_opts)

Set the code generator options dictionary

store_log = False
suffix = ''
target = None
target_path = None
target_platform = ''

pynestml.frontend.pynestml_frontend module

pynestml.frontend.pynestml_frontend.builder_from_target_name(target_name: str, options: Mapping[str, Any] | None = None) Tuple[Builder, Dict[str, Any]]

Static factory method that returns a new instance of a child class of Builder

pynestml.frontend.pynestml_frontend.code_generator_from_target_name(target_name: str, options: Mapping[str, Any] | None = None) CodeGenerator

Static factory method that returns a new instance of a child class of CodeGenerator

pynestml.frontend.pynestml_frontend.configure_front_end(input_path: str | Sequence[str], target_platform: str, target_path=None, install_path: str | None = None, logging_level='ERROR', module_name=None, store_log=False, suffix='', dev=False, codegen_opts: Mapping[str, Any] | None = None)
pynestml.frontend.pynestml_frontend.create_report_dir()
pynestml.frontend.pynestml_frontend.generate_code(code_generators, models)
pynestml.frontend.pynestml_frontend.generate_nest_compartmental_target(input_path: str | Sequence[str], target_path: str | None = None, install_path: str | None = None, logging_level='ERROR', module_name=None, store_log: bool = False, suffix: str = '', dev: bool = False, codegen_opts: Mapping[str, Any] | None = None)

Generate and build compartmental model code for NEST Simulator.

Parameters:
  • input_path (str or Sequence[str]) – Path to the NESTML file(s) or to folder(s) containing NESTML files to convert to NEST code.

  • target_path (str, optional (default: append “target” to input_path)) – Path to the generated C++ code and install files.

  • install_path – Path to the directory where the generated code will be installed.

  • logging_level (str, optional (default: "ERROR")) – Sets which level of information should be displayed duing code generation (among “ERROR”, “WARNING”, “INFO”, or “NO”).

  • module_name (str, optional (default: "nestmlmodule")) – The name of the generated Python module.

  • store_log (bool, optional (default: False)) – Whether the log should be saved to file.

  • suffix (str, optional (default: "")) – A suffix string that will be appended to the name of all generated models.

  • dev (bool, optional (default: False)) – Enable development mode: code generation is attempted even for models that contain errors, and extra information is rendered in the generated code.

  • codegen_opts (Optional[Mapping[str, Any]]) – A dictionary containing additional options for the target code generator.

pynestml.frontend.pynestml_frontend.generate_nest_target(input_path: str | Sequence[str], target_path: str | None = None, install_path: str | None = None, logging_level='ERROR', module_name=None, store_log: bool = False, suffix: str = '', dev: bool = False, codegen_opts: Mapping[str, Any] | None = None)

Generate and build code for NEST Simulator.

Parameters:
  • input_path (str or Sequence[str]) – Path to the NESTML file(s) or to folder(s) containing NESTML files to convert to NEST code.

  • target_path (str, optional (default: append “target” to input_path)) – Path to the generated C++ code and install files.

  • logging_level (str, optional (default: "ERROR")) – Sets which level of information should be displayed duing code generation (among “ERROR”, “WARNING”, “INFO”, or “NO”).

  • module_name (str, optional (default: "nestmlmodule")) – Name of the module, which will be used to import the model in NEST via nest.Install(module_name).

  • store_log (bool, optional (default: False)) – Whether the log should be saved to file.

  • suffix (str, optional (default: "")) – A suffix string that will be appended to the name of all generated models.

  • install_path – Path to the directory where the generated NEST extension module will be installed into. If the parameter is not specified, the module will be installed into the NEST Simulator installation directory, as reported by nest-config.

  • dev (bool, optional (default: False)) – Enable development mode: code generation is attempted even for models that contain errors, and extra information is rendered in the generated code.

  • codegen_opts (Optional[Mapping[str, Any]]) – A dictionary containing additional options for the target code generator.

pynestml.frontend.pynestml_frontend.generate_python_standalone_target(input_path: str | Sequence[str], target_path: str | None = None, logging_level='ERROR', module_name: str = 'nestmlmodule', store_log: bool = False, suffix: str = '', dev: bool = False, codegen_opts: Mapping[str, Any] | None = None)

Generate and build code for the standalone Python target.

Parameters:
  • input_path (str or Sequence[str]) – Path to the NESTML file(s) or to folder(s) containing NESTML files to convert to NEST code.

  • target_path (str, optional (default: append “target” to input_path)) – Path to the generated C++ code and install files.

  • logging_level (str, optional (default: "ERROR")) – Sets which level of information should be displayed duing code generation (among “ERROR”, “WARNING”, “INFO”, or “NO”).

  • module_name (str, optional (default: "nestmlmodule")) – The name of the generated Python module.

  • store_log (bool, optional (default: False)) – Whether the log should be saved to file.

  • suffix (str, optional (default: "")) – A suffix string that will be appended to the name of all generated models.

  • dev (bool, optional (default: False)) – Enable development mode: code generation is attempted even for models that contain errors, and extra information is rendered in the generated code.

  • codegen_opts (Optional[Mapping[str, Any]]) – A dictionary containing additional options for the target code generator.

pynestml.frontend.pynestml_frontend.generate_spinnaker_target(input_path: str | Sequence[str], target_path: str | None = None, install_path: str | None = None, logging_level='ERROR', module_name: str = 'nestmlmodule', store_log: bool = False, suffix: str = '', dev: bool = False, codegen_opts: Mapping[str, Any] | None = None)

Generate and build code for the SpiNNaker target.

Parameters:
  • input_path (str or Sequence[str]) – Path to the NESTML file(s) or to folder(s) containing NESTML files to convert to NEST code.

  • target_path (str, optional (default: append “target” to input_path)) – Path to the generated C++ code and install files.

  • install_path – Path to the directory where the generated code will be installed.

  • logging_level (str, optional (default: "ERROR")) – Sets which level of information should be displayed duing code generation (among “ERROR”, “WARNING”, “INFO”, or “NO”).

  • module_name (str, optional (default: "nestmlmodule")) – The name of the generated Python module.

  • store_log (bool, optional (default: False)) – Whether the log should be saved to file.

  • suffix (str, optional (default: "")) – A suffix string that will be appended to the name of all generated models.

  • dev (bool, optional (default: False)) – Enable development mode: code generation is attempted even for models that contain errors, and extra information is rendered in the generated code.

  • codegen_opts (Optional[Mapping[str, Any]]) – A dictionary containing additional options for the target code generator.

pynestml.frontend.pynestml_frontend.generate_target(input_path: str | Sequence[str], target_platform: str, target_path=None, install_path: str | None = None, logging_level='ERROR', module_name=None, store_log=False, suffix='', dev=False, codegen_opts: Mapping[str, Any] | None = None)

Generate and build code for the given target platform.

Parameters:
  • input_path (str or Sequence[str]) – One or more input path(s). Each path is a NESTML file, or a directory containing NESTML files. Directories will be searched recursively for files matching *.nestml.

  • target_platform (str) – The name of the target platform to generate code for.

  • target_path (str, optional (default: append “target” to input_path)) – Path to target directory where generated code will be written into. Default is target, which will be created in the current working directory if it does not yet exist.

  • logging_level (str, optional (default: "ERROR")) – Sets the logging level, i.e., which level of messages should be printed. Default is ERROR, available are: DEBUG, INFO, WARNING, ERROR, NO.

  • module_name (str, optional (default: "nestmlmodule")) – Sets the name of the module which shall be generated. Default is the name of the directory containing the models. The name has to end in module. Default is nestmlmodule.

  • store_log (bool, optional (default: False)) – Stores a log.txt containing all messages in JSON notation. Default is OFF.

  • suffix (str, optional (default: "")) – A suffix string that will be appended to the name of all generated models.

  • install_path – Path to the directory where the generated code will be installed.

  • dev (bool, optional (default: False)) – Enable development mode: code generation is attempted even for models that contain errors, and extra information is rendered in the generated code.

  • codegen_opts (Optional[Mapping[str, Any]]) – A dictionary containing additional options for the target code generator.

pynestml.frontend.pynestml_frontend.get_known_targets()
pynestml.frontend.pynestml_frontend.get_parsed_models()

Handle the parsing and validation of the NESTML files

models: Sequence[ASTModel]

List of correctly parsed models

errors_occurredbool

Flag indicating whether errors occurred during processing

pynestml.frontend.pynestml_frontend.init_predefined()
pynestml.frontend.pynestml_frontend.main() int

Entry point for the command-line application.

Returns:

The process exit code

Return type:

0 for success, > 0 for failure

pynestml.frontend.pynestml_frontend.process()

The main toolchain workflow entry point. For all models: parse, validate, transform, generate code and build.

Returns:

errors_occurred – Flag indicating whether errors occurred during processing

Return type:

bool

pynestml.frontend.pynestml_frontend.store_log_to_file()
pynestml.frontend.pynestml_frontend.transform_models(transformers, models)
pynestml.frontend.pynestml_frontend.transformers_from_target_name(target_name: str, options: Mapping[str, Any] | None = None) Tuple[Transformer, Dict[str, Any]]

Static factory method that returns a list of new instances of a child class of Transformers