diff --git a/MANIFEST.in b/MANIFEST.in index 0781bf4..238dd17 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,7 +6,7 @@ include bluepyopt/ephys/templates/acc/_json_template.jinja2 include bluepyopt/ephys/templates/acc/decor_acc_template.jinja2 include bluepyopt/ephys/templates/acc/label_dict_acc_template.jinja2 -include.txt +include README.rst include AUTHORS.txt include COPYING include COPYING.lesser diff --git a/bluepyopt/ipyp/bpopt_tasksdb.py b/bluepyopt/ipyp/bpopt_tasksdb.py index 5709209..5e960bc 100644 --- a/bluepyopt/ipyp/bpopt_tasksdb.py +++ b/bluepyopt/ipyp/bpopt_tasksdb.py @@ -29,7 +29,21 @@ import itertools import numpy as np -import matplotlib.pyplot as plt + + +def _import_pyplot(): + """Import matplotlib.pyplot, with a helpful error if it is missing. + + matplotlib is an optional dependency of bpopt_tasksdb; install it via + ``pip install bluepyopt[ipyp]``. + """ + try: + import matplotlib.pyplot as plt + except ImportError as e: + raise ImportError( + "bpopt_tasksdb requires matplotlib: pip install bluepyopt[ipyp]" + ) from e + return plt def get_engine_data(tasksdb_filename): @@ -67,6 +81,8 @@ def get_engine_data(tasksdb_filename): def plot_usage(tasks, engine_number_map): """Plot usage stats""" + plt = _import_pyplot() + plt.figure(figsize=(8, 8)) for engine_uuid, task_list in tasks.items(): engine_number = engine_number_map[engine_uuid] @@ -91,6 +107,8 @@ def plot_usage(tasks, engine_number_map): def plot_duration_histogram(tasks): """Plot duration histogram""" + plt = _import_pyplot() + plt.figure(figsize=(8, 8)) durations = np.fromiter((t['duration'] @@ -137,6 +155,7 @@ def run(arg_list): plot_usage(tasks, engine_number_map) plot_duration_histogram(tasks) + plt = _import_pyplot() plt.show() diff --git a/examples/BluePyOpt-ipyparallel.md b/examples/BluePyOpt-ipyparallel.md index ab6b04a..c7eee5e 100644 --- a/examples/BluePyOpt-ipyparallel.md +++ b/examples/BluePyOpt-ipyparallel.md @@ -12,6 +12,11 @@ The `ipcontroller` gets its work from clients that connect to it. ## Installation +> **Note:** As of recent versions, `ipyparallel` is no longer installed +> automatically with `BluePyOpt`. Install it explicitly, either on its own +> (`pip install ipyparallel`) or together with BluePyOpt via the extra: +> `pip install bluepyopt[ipyp]`. + `ipyparallel` can be installed using pip: # create and activate virtualenv diff --git a/pyproject.toml b/pyproject.toml index addb435..15fe290 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,8 +17,6 @@ dependencies = [ "pandas>=0.18", "deap>=1.3.3", "efel>=2.13", - "ipyparallel", - "pickleshare>=0.7.3", "Jinja2>=2.8", "Pebble>=4.6.0", "NEURON>=7.8", @@ -39,13 +37,15 @@ keywords = [ ] [project.optional-dependencies] -all = ["scoop>=0.7", "pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "arbor>=0.10,<0.12"] -tests = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "arbor>=0.10,<0.12"] -tests-no-arbor = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3"] +all = ["scoop>=0.7", "pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "arbor>=0.10,<0.12", "ipyparallel", "matplotlib"] +tests = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "arbor>=0.10,<0.12", "matplotlib"] +tests-no-arbor = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1", "LFPy>=2.3", "matplotlib"] scoop = ["scoop>=0.7"] neuroml = ["pyneuroml>=0.5.20", "libNeuroML>=0.3.1"] lfpy = ["LFPy>=2.3"] arbor = ["arbor>=0.10,<0.12"] +# Dependencies for the optional ipyparallel-based bpopt_tasksdb helper script. +ipyp = ["ipyparallel", "matplotlib"] [project.urls] Homepage = "https://github.com/openbraininstitute/BluePyOpt" @@ -55,7 +55,7 @@ Tracker = "https://github.com/openbraininstitute/BluePyOpt/issues" Documentation = "https://bluepyopt.readthedocs.io/en/latest" [project.scripts] -bpopt_tasksdb = "bluepyopt:ipyp.bpopt_tasksdb.main" +bpopt_tasksdb = "bluepyopt.ipyp.bpopt_tasksdb:main" [tool.setuptools] include-package-data = true @@ -72,7 +72,10 @@ bluepyopt = [ ] [tool.setuptools.packages.find] -exclude = ["examples*"] +exclude = ["examples*", "bluepyopt.tests*"] + +[tool.setuptools.exclude-package-data] +"*" = ["tests/*", "tests/**/*"] [tool.setuptools_scm] version_scheme = "python-simplified-semver"