Skip to content

Commit

Permalink
Add more verbosity for thalamus protocols (#86)
Browse files Browse the repository at this point in the history
* set default CLI verbosity to 1, logger.INFO

* add extra verbosity with progress bars to thalamus RatSSCxMainProtocol

* update unit test: test_get_parser_args

* fix unit test: test_get_parser_args

* update argparse to store int for verbosity with default=1
  • Loading branch information
anilbey committed Apr 12, 2023
1 parent f1ad31a commit 2ccc3f4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion emodelrunner/parsing_utilities.py
Expand Up @@ -30,7 +30,7 @@ def get_parser_args():
default=None,
help="the path to the config file.",
)
parser.add_argument("-v", "--verbose", action="count", dest="verbosity", default=0)
parser.add_argument("-v", "--verbose", type=int, dest="verbosity", default=1)
return parser.parse_args()


Expand Down
13 changes: 11 additions & 2 deletions emodelrunner/protocols/thalamus_protocols.py
Expand Up @@ -20,7 +20,9 @@
import copy
import logging
import numpy as np

from bluepyopt import ephys
from tqdm import tqdm

from emodelrunner.protocols.protocols_func import CurrentOutputKeyMixin

Expand Down Expand Up @@ -124,12 +126,14 @@ def run(self, cell_model, param_values, sim=None, isolate=None):
cell_model.freeze(param_values)

# Find resting membrane potential
logger.info("Running RMP protocol")
rmp_response = self.rmp_protocol.run(cell_model, {}, sim=sim)
responses.update(rmp_response)
rmp = self.rmp_efeature.calculate_feature(rmp_response)

# Find Rin and holding current
if hasattr(self, "rinhold_protocol_dep"):
logger.info("Running Rinhold protocol (depolarizing)")
rinhold_response_dep = self.rinhold_protocol_dep.run(
cell_model, {}, sim=sim, rmp=rmp
)
Expand All @@ -138,6 +142,7 @@ def run(self, cell_model, param_values, sim=None, isolate=None):
rin_dep = self.rin_efeature_dep.calculate_feature(rinhold_response_dep)
responses.update(rinhold_response_dep)

logger.info("Running Rinhold protocol (hyperpolarizing)")
rinhold_response_hyp = self.rinhold_protocol_hyp.run(
cell_model, {}, sim=sim, rmp=rmp
)
Expand All @@ -148,6 +153,7 @@ def run(self, cell_model, param_values, sim=None, isolate=None):
responses.update(rinhold_response_hyp)

if hasattr(self, "thdetect_protocol_dep"):
logger.info("Running threshold detection protocol (depolarizing)")
responses.update(
self.thdetect_protocol_dep.run(
cell_model,
Expand All @@ -159,6 +165,7 @@ def run(self, cell_model, param_values, sim=None, isolate=None):
)
)

logger.info("Running threshold detection protocol (hyperpolarizing)")
responses.update(
self.thdetect_protocol_hyp.run(
cell_model,
Expand All @@ -180,13 +187,15 @@ def run(self, cell_model, param_values, sim=None, isolate=None):

def _run_pre_protocols(self, cell_model, sim, responses):
"""Runs the pre_protocols and updates responses dict."""
for pre_protocol in self.pre_protocols:
logger.info("Running pre-protocols")
for pre_protocol in tqdm(self.pre_protocols):
response = pre_protocol.run(cell_model, {}, sim=sim)
responses.update(response)

def _run_other_protocols(self, cell_model, sim, responses):
"""Runs the other_protocols and updates responses dict."""
for other_protocol in self.other_protocols:
logger.info("Running other protocols")
for other_protocol in tqdm(self.other_protocols):
response = other_protocol.run(cell_model, {}, sim=sim)
responses.update(response)

Expand Down
4 changes: 0 additions & 4 deletions emodelrunner/run.py
Expand Up @@ -31,10 +31,6 @@

logger = logging.getLogger(__name__)

# if logger.level is unset, then set it to INFO
if logger.level == logging.NOTSET:
logger.setLevel(logging.INFO)


def main(config_path):
"""Main.
Expand Down
3 changes: 0 additions & 3 deletions emodelrunner/run_pairsim.py
Expand Up @@ -31,9 +31,6 @@

# Configure logger
logger = logging.getLogger(__name__)
# if logger.level is unset, then set it to INFO
if logger.level == logging.NOTSET:
logger.setLevel(logging.INFO)


def run(
Expand Down
3 changes: 0 additions & 3 deletions emodelrunner/run_synplas.py
Expand Up @@ -31,9 +31,6 @@

# Configure logger
logger = logging.getLogger(__name__)
# if logger.level is unset, then set it to INFO
if logger.level == logging.NOTSET:
logger.setLevel(logging.INFO)


# taken from glusynapse.simulation.simulator
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -50,6 +50,7 @@
"schema",
"Pebble>=4.3.10",
"importlib_metadata; python_version<'3.8'",
"tqdm>=4.65.0",
],
packages=find_packages(exclude=["tests"]),
python_requires=">=3.7",
Expand Down
16 changes: 8 additions & 8 deletions tests/unit_tests/test_parsing_utilities.py
Expand Up @@ -28,25 +28,25 @@ def test_get_parser_args():
args = get_parser_args()

assert args.config_path == "mock/config/path"
assert args.verbosity == 0
assert args.verbosity == 1

# --verbose case
sys.argv = "run.py --config_path mock/config/path --verbose".split()
sys.argv = "run.py --config_path mock/config/path --verbose=0".split()
args = get_parser_args()

assert args.verbosity == 1
assert args.verbosity == 0

# -v case
sys.argv = "run.py --config_path mock/config/path -v".split()
sys.argv = "run.py --config_path mock/config/path -v=2".split()
args = get_parser_args()

assert args.verbosity == 1
assert args.verbosity == 2

# -vv case
sys.argv = "run.py --config_path mock/config/path -vv".split()
# space separated case
sys.argv = "run.py --config_path mock/config/path --verbose 3".split()
args = get_parser_args()

assert args.verbosity == 2
assert args.verbosity == 3


@patch("logging.basicConfig")
Expand Down

0 comments on commit 2ccc3f4

Please sign in to comment.