Skip to content

Commit

Permalink
Add simulation validation as click command
Browse files Browse the repository at this point in the history
  • Loading branch information
Joni Herttuainen committed Nov 17, 2023
1 parent e4f4770 commit 715a715
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bluepysnap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import click

from bluepysnap import circuit_validation
from bluepysnap import circuit_validation, simulation_validation

CLICK_EXISTING_FILE = click.Path(exists=True, file_okay=True, dir_okay=False)


@click.group()
Expand All @@ -19,7 +21,7 @@ def cli(verbose):


@cli.command()
@click.argument("config_file", type=click.Path(exists=True, file_okay=True, dir_okay=False))
@click.argument("config_file", type=CLICK_EXISTING_FILE)
@click.option(
"--skip-slow/--no-skip-slow",
default=True,
Expand All @@ -30,11 +32,22 @@ def cli(verbose):
)
@click.option("--only-errors", is_flag=True, help="Only print fatal errors (ignore warnings)")
def validate(config_file, skip_slow, only_errors):
"""Validate of Sonata circuit based on config file.
"""Validate Sonata circuit based on config file.
Args:
config_file (str): path to Sonata circuit config file
skip_slow (bool): skip slow tests
only_errors (bool): only print fatal errors
"""
circuit_validation.validate(config_file, skip_slow, only_errors)


@cli.command()
@click.argument("config_file", type=CLICK_EXISTING_FILE)
def validate_simulation(config_file):
"""Validate Sonata simulation based on config file.
Args:
config_file (str): path to Sonata simulation config file
"""
simulation_validation.validate(config_file)
8 changes: 8 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ def test_cli_no_config():
result = runner.invoke(cli, ["validate"])
assert result.exit_code == 2
assert "Missing argument 'CONFIG_FILE'" in result.stdout


def test_cli_validate_simulation_correct():
runner = CliRunner()
result = runner.invoke(
cli, ["validate-simulation", str(TEST_DATA_DIR / "simulation_config.json")]
)
assert result.exit_code == 0

0 comments on commit 715a715

Please sign in to comment.