def generate_target(input_path: Union[str, Sequence[str]], target_platform: str, target_path=None, install_path: str = None, logging_level="ERROR", module_name=None, store_log=False, suffix="", dev=False, codegen_opts: Optional[Mapping[str, Any]] = None): r"""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. """ args = list() args.append(qualifier_input_path_arg) if type(input_path) is str: args.append(str(input_path)) else: for s in input_path: args.append(s) if target_path is not None: args.append(qualifier_target_path_arg) args.append(str(target_path)) args.append(qualifier_target_platform_arg) args.append(target_platform) args.append(qualifier_logging_level_arg) args.append(str(logging_level)) if module_name is not None: args.append(qualifier_module_name_arg) args.append(str(module_name)) if store_log: args.append(qualifier_store_log_arg) if suffix: args.append(qualifier_suffix_arg) args.append(suffix) if install_path is not None: args.append(qualifier_install_path_arg) args.append(str(install_path)) if dev: args.append(qualifier_dev_arg) FrontendConfiguration.parse_config(args) if codegen_opts: FrontendConfiguration.set_codegen_opts(codegen_opts) if not process() == 0: raise Exception("Error(s) occurred while processing the model")
def to_nest(input_path: Union[str, Sequence[str]], target_path=None, logging_level='ERROR', module_name=None, store_log=False, suffix="", dev=False, codegen_opts: Optional[Mapping[str, Any]] = None): '''Translate NESTML files into their equivalent C++ code for the 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: "") Suffix which will be appended to the model's name (internal use to avoid naming conflicts with existing NEST 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. ''' # if target_path is not None and not os.path.isabs(target_path): # print('PyNestML: Please provide absolute target path!') # return args = list() args.append(qualifier_input_path_arg) if type(input_path) is str: args.append(str(input_path)) else: for s in input_path: args.append(s) if target_path is not None: args.append(qualifier_target_path_arg) args.append(str(target_path)) args.append(qualifier_target_arg) args.append(str("NEST")) args.append(qualifier_logging_level_arg) args.append(str(logging_level)) if module_name is not None: args.append(qualifier_module_name_arg) args.append(str(module_name)) if store_log: args.append(qualifier_store_log_arg) if suffix: args.append(qualifier_suffix_arg) args.append(suffix) if dev: args.append(qualifier_dev_arg) FrontendConfiguration.parse_config(args) if codegen_opts: FrontendConfiguration.set_codegen_opts(codegen_opts) if not process() == 0: raise Exception("Error(s) occurred while processing the model")