Skip to content

Commit

Permalink
Update NEST version detection for v3.4 (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbabu authored Mar 1, 2023
1 parent 4ac15e9 commit 4ff6ee1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nestml-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
nest_branch: ["v2.20.2", "v3.0", "v3.1", "v3.2", "v3.3", "master"]
nest_branch: ["v2.20.2", "v3.0", "v3.1", "v3.2", "v3.3", "v3.4", "master"]
fail-fast: false
steps:
# Checkout the repository contents
Expand Down
6 changes: 4 additions & 2 deletions doc/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,14 @@ For a full example, please see `iaf_psc_exp_multisynapse_vectors.nestml <https:/
Compatibility with different versions of NEST
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To generate code that is compatible with particular release versions of NEST Simulator, the code generator option ``nest_version`` can be used. It takes a string as its value that corresponds to a git tag or git branch name. The following values are supported:
To generate code that is compatible with particular versions of NEST Simulator, the code generator option ``nest_version`` can be used. The option value is given as a string that corresponds to a git tag or git branch name. The following values are supported:

- The default is the empty string, which causes the NEST version to be automatically identified from the ``nest`` Python module.
- ``"v2.20.2"``: Latest NEST 2 release.
- ``"master"``: Latest NEST GitHub master branch version (https://github.com/nest/nest-simulator/).
- ``"v2.20.2"``: Latest NEST 2 release.
- ``"v3.0"``, ``"v3.1"``, ``"v3.2"``, ``"v3.3"``, ``"v3.4"``: NEST 3 release versions.

For a list of the corresponding NEST Simulator repository tags, please see https://github.com/nest/nest-simulator/tags.

Python-standalone target
------------------------
Expand Down
10 changes: 8 additions & 2 deletions pynestml/codegeneration/nest_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ def detect_nest_version(cls) -> str:
vt = nest.Create("volume_transmitter")
try:
neuron = nest.Create('hh_psc_alpha_clopath')
neuron = nest.Create("hh_psc_alpha_clopath")
neurons = nest.Create("iaf_psc_exp", 2)
nest.Connect(neurons[0], neurons[1], syn_spec={"synapse_model": "stdp_synapse",
"weight": 1., "delay": 1.})
syn = nest.GetConnections(target=neurons[1], synapse_model="stdp_synapse")
except Exception:
pass
if "DataConnect" in dir(nest):
nest_version = "v2.20.2"
elif "kernel_status" not in dir(nest): # added in v3.1
nest_version = "v3.0"
elif "prepared" in nest.GetKernelStatus().keys(): # "prepared" key was added after v3.3 release
elif "Kplus" in syn.get().keys(): # "Kplus" trace variable is made accessible via get_status() in master
nest_version = "master"
elif "prepared" in nest.GetKernelStatus().keys(): # "prepared" key was added after v3.3 release
nest_version = "v3.4"
elif "tau_u_bar_minus" in neuron.get().keys(): # added in v3.3
nest_version = "v3.3"
elif "tau_Ca" in vt.get().keys(): # removed in v3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ public:

typedef Connection< targetidentifierT > ConnectionBase;

{%- if not (nest_version.startswith("v2") or nest_version.startswith("v3.0") or nest_version.startswith("v3.1") or nest_version.startswith("v3.2") or nest_version.startswith("v3.3")) %}
{#- NEST 3.4 and higher only #}
{%- if not (nest_version.startswith("v2") or nest_version.startswith("v3.0") or nest_version.startswith("v3.1") or nest_version.startswith("v3.2") or nest_version.startswith("v3.3") or nest_version.startswith("v3.4")) %}
static constexpr ConnectionModelProperties properties = ConnectionModelProperties::HAS_DELAY
| ConnectionModelProperties::IS_PRIMARY | ConnectionModelProperties::SUPPORTS_HPC
| ConnectionModelProperties::SUPPORTS_LBL;
Expand Down Expand Up @@ -797,8 +796,7 @@ std::cout << "\tFacilitating from c = " << S_.c << " (using trace = " << S_.pre_
{%- endif %}
};

{%- if not (nest_version.startswith("v2") or nest_version.startswith("v3.0") or nest_version.startswith("v3.1") or nest_version.startswith("v3.2") or nest_version.startswith("v3.3")) %}
{#- NEST 3.4 and higher only #}
{%- if not (nest_version.startswith("v2") or nest_version.startswith("v3.0") or nest_version.startswith("v3.1") or nest_version.startswith("v3.2") or nest_version.startswith("v3.3") or nest_version.startswith("v3.4")) %}
template < typename targetidentifierT >
constexpr ConnectionModelProperties {{synapseName}}< targetidentifierT >::properties;

Expand Down

0 comments on commit 4ff6ee1

Please sign in to comment.