diff --git a/.gitignore b/.gitignore index f5dca0a..7b414a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ build/ -*~ \ No newline at end of file +*~ +*.egg-info diff --git a/README.md b/README.md index db932d7..6df7325 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ The client can either be installed using `python3 setup.py install --user` or, as the client is implemented in a single file, by just copying the file `nest_client/nest_client.py` to your project. -The directory `examples` holds some examples that demostrate the +The directory `examples` holds some examples that demonstrate the usage of the client. diff --git a/examples/NESTClient_example.py b/examples/NESTClient_example.py index a8b709e..1d6a127 100644 --- a/examples/NESTClient_example.py +++ b/examples/NESTClient_example.py @@ -19,46 +19,46 @@ # You should have received a copy of the GNU General Public License # along with NEST. If not, see . -from NESTServerClient import NESTServerClient +from nest_client import NESTClient -print('Running client examples using NEST via NEST Server') +print("Running client examples using NEST via NEST Server") -# Load NEST Server client -nestsc = NESTServerClient() +# Load NEST client +nest = NESTClient() # # Use NEST Server API # -print('\n') -print('Execute script code with NEST Server API') -print('-' * 20) +print("\n") +print("Execute script code with NEST Server API") +print("-" * 20) # Reset kernel -nestsc.ResetKernel() +nest.ResetKernel() # Create nodes -pg = nestsc.Create("poisson_generator", params={"rate": 6500.}) -neurons = nestsc.Create("iaf_psc_alpha", 100) -sr = nestsc.Create("spike_recorder") +pg = nest.Create("poisson_generator", params={"rate": 6500.0}) +neurons = nest.Create("iaf_psc_alpha", 100) +sr = nest.Create("spike_recorder") # Connect nodes -nestsc.Connect(pg, neurons, syn_spec={'weight': 10.}) -nestsc.Connect(neurons[::10], sr) +nest.Connect(pg, neurons, syn_spec={"weight": 10.0}) +nest.Connect(neurons[::10], sr) # Simulate -nestsc.Simulate(1000.0) +nest.Simulate(1000.0) # Get events -n_events = nestsc.GetStatus(sr, 'n_events')[0] -print('Number of events:', n_events) +n_events = nest.GetStatus(sr, "n_events")[0] +print("Number of events:", n_events) # # Use NEST Server exec # -print('\n') -print('Execute script code from file') -print('-' * 20) +print("\n") +print("Execute script code from file") +print("-" * 20) -n_events = nestsc.from_file('NESTClient_script.py', 'n_events')['data'] -print('Number of events:', n_events) +n_events = nest.from_file("NESTClient_script.py", "n_events")["data"] +print("Number of events:", n_events) diff --git a/examples/__init__.py b/examples/__init__.py index 1a2f534..2f830f2 100644 --- a/examples/__init__.py +++ b/examples/__init__.py @@ -18,6 +18,3 @@ # # You should have received a copy of the GNU General Public License # along with NEST. If not, see . - - -from .NESTServerClient import * diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8465ef0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,66 @@ +[project] +name = "nest-client" +version = "0.1.1" +description = "NEST Client sends JSON requests to NEST Server." +readme = "README.md" +requires-python = ">=3.9" +license-files = ["LICENSE"] +authors = [ + {name = "Dennis Terhorst"}, + {name = "Jochen M. Eppler"}, + {name = "Sebastian Spreizer"}, +] +maintainers = [ + {name = "Dennis Terhorst", email = "d.terhorst@fz-juelich.de"} +] +# keywords = [] +classifiers = [ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + "Development Status :: 5 - Stable", + + # Indicate who your project is intended for + "Intended Audience :: Science/Research", + + "Topic :: Scientific/Engineering", + + # Specify the Python versions you support here. + "Programming Language :: Python :: 3", +] +dependencies = [ + "requests", + "werkzeug", +] + +[project.urls] +homepage = "https://nest-simulator.org" +repository = "https://github.com/nest/nest-client" +documentation = "https://nest-simulator.readthedocs.io" + +[tool.black] +line-length = 120 + +[tool.flake8] +# This is ignored +# see discussions around https://github.com/PyCQA/flake8/issues/234 + +[tool.isort] +atomic = true +line_length = 120 +multi_line_output = 3 +profile = "black" +skip_gitignore = true + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = "--mypy --pylint --pydocstyle --cov --ignore=conda --ignore=venv --ignore=.git --ignore=__pycache__" +norecursedirs = ".git _build venv tmp*" + +[tool.mypy] +exclude = ".git/, .pytest_cache/, conda/, venv/" + +[tool.pydocstyle] +convention = "numpy" +add-ignore = "D300" diff --git a/setup.py b/setup.py deleted file mode 100644 index 1cdf933..0000000 --- a/setup.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# -# setup.py -# -# This file is part of NEST. -# -# Copyright (C) 2004 The NEST Initiative -# -# NEST is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# NEST is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with NEST. If not, see . - -# NEST Client -- A client for the NEST Server - -from distutils.core import setup - -setup(name='NEST Client', - version='0.1', - description=('NEST Client sends JSON requests to NEST Server.'), - author='Sebastian Spreizer', - author_email='spreizer@web.de', - url='https://www.nest-simulator.org', - license='GNU Public License v2 or later', - packages=['nest_client'], - ) diff --git a/nest_client/__init__.py b/src/nest_client/__init__.py similarity index 79% rename from nest_client/__init__.py rename to src/nest_client/__init__.py index c1d9f38..0f62637 100644 --- a/nest_client/__init__.py +++ b/src/nest_client/__init__.py @@ -20,4 +20,12 @@ # along with NEST. If not, see . -from .nest_client import * +from importlib import metadata # noqa +from .nest_client import * # noqa + +try: + __version__ = metadata.version("nest-client") +except metadata.PackageNotFoundError: + pass + +del metadata diff --git a/nest_client/nest_client.py b/src/nest_client/nest_client.py similarity index 96% rename from nest_client/nest_client.py rename to src/nest_client/nest_client.py index d30cc94..925ba80 100644 --- a/nest_client/nest_client.py +++ b/src/nest_client/nest_client.py @@ -19,8 +19,8 @@ # You should have received a copy of the GNU General Public License # along with NEST. If not, see . -import requests -from werkzeug.exceptions import BadRequest +import requests # noqa +from werkzeug.exceptions import BadRequest # noqa __all__ = [