Skip to content

Commit

Permalink
Merge pull request #5 from clinssen/nest_random_coco2
Browse files Browse the repository at this point in the history
fix code generator options handling
  • Loading branch information
pnbabu authored Sep 27, 2024
2 parents f1e2a20 + 62e59b3 commit 9f594f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
10 changes: 7 additions & 3 deletions pynestml/codegeneration/nest_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ def run_nest_target_specific_cocos(self, neurons: Sequence[ASTModel], synapses:
# Check if the random number functions are used in the right blocks
CoCosManager.check_co_co_nest_random_functions_legally_used(model)

if self.get_option("neuron_synapse_pairs"):
if Logger.has_errors(model):
raise Exception("Error(s) occurred during code generation")

if self.get_option("neuron_synapse_pairs"):
for model in synapses:
synapse_name_stripped = removesuffix(removesuffix(model.name.split("_with_")[0], "_"),
FrontendConfiguration.suffix)
# special case for NEST delay variable (state or parameter)
Expand All @@ -192,8 +196,8 @@ def run_nest_target_specific_cocos(self, neurons: Sequence[ASTModel], synapses:
delay_variable = self.get_option("delay_variable")[synapse_name_stripped]
CoCoNESTSynapseDelayNotAssignedTo.check_co_co(delay_variable, model)

if Logger.has_errors(model):
raise Exception("Error(s) occurred during code generation")
if Logger.has_errors(model):
raise Exception("Error(s) occurred during code generation")

def setup_printers(self):
self._constant_printer = ConstantPrinter()
Expand Down
21 changes: 12 additions & 9 deletions pynestml/frontend/pynestml_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,22 @@ def process():
Flag indicating whether errors occurred during processing
"""

# initialize and set options for transformers, code generator and builder
codegen_and_builder_opts = FrontendConfiguration.get_codegen_opts()

transformers, codegen_and_builder_opts = transformers_from_target_name(FrontendConfiguration.get_target_platform(),
options=codegen_and_builder_opts)
# initialise model transformers
transformers, unused_opts_transformer = transformers_from_target_name(FrontendConfiguration.get_target_platform(),
options=FrontendConfiguration.get_codegen_opts())

# initialise code generator
code_generator = code_generator_from_target_name(FrontendConfiguration.get_target_platform())
codegen_and_builder_opts = code_generator.set_options(codegen_and_builder_opts)
unused_opts_codegen = code_generator.set_options(FrontendConfiguration.get_codegen_opts())

_builder, codegen_and_builder_opts = builder_from_target_name(FrontendConfiguration.get_target_platform(), options=codegen_and_builder_opts)
# initialise builder
_builder, unused_opts_builder = builder_from_target_name(FrontendConfiguration.get_target_platform(),
options=FrontendConfiguration.get_codegen_opts())

if len(codegen_and_builder_opts) > 0:
raise CodeGeneratorOptionsException("The code generator option(s) \"" + ", ".join(codegen_and_builder_opts.keys()) + "\" do not exist.")
# check for unused codegen options
for opt_key in FrontendConfiguration.get_codegen_opts().keys():
if opt_key in unused_opts_transformer.keys() and opt_key in unused_opts_codegen.keys() and opt_key in unused_opts_builder.keys():
raise CodeGeneratorOptionsException("The code generator option \"" + opt_key + "\" does not exist.")

models, errors_occurred = get_parsed_models()

Expand Down

0 comments on commit 9f594f9

Please sign in to comment.