Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update benchmarks CLI #413

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bash/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DATASET="/workdir/dataset/"
# -v : mount a volume from host machine at $MOUNT_POINT to container's /root/mne_data/
# "${TAG}" : use the image with the tag 'moabb'
# /usr/bin/python : use python command
# /workdir/moabb/run.py : run the script 'run.py' located at '/workdir/moabb/'
# /workdir/moabb/benchmark.py : run the script 'benchmark.py' located at '/workdir/moabb/'
# --pipeline $PIPELINE : use pipelines located at $PIPELINE
# --results $RESULTS : store results in $RESULTS
# --output $OUTPUTS : store outputs in $OUTPUTS
Expand All @@ -30,7 +30,7 @@ docker run -it \
-v "${MOUNT_POINT}/output/:/workdir/output" \
"$TAG" \
/usr/bin/python \
/workdir/moabb/run.py \
/workdir/moabb/benchmark.py \
--pipeline "$PIPELINE" \
--results "$RESULTS" \
--output "$OUTPUTS" \
Expand Down
39 changes: 27 additions & 12 deletions moabb/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import os
import os.path as osp
from pathlib import Path
from typing import List, Union

import mne
import pandas as pd
import yaml

from moabb import paradigms as moabb_paradigms
from moabb.analysis import analyze
from moabb.datasets.base import BaseDataset
from moabb.evaluations import (
CrossSessionEvaluation,
CrossSubjectEvaluation,
Expand All @@ -19,6 +21,7 @@
generate_param_grid,
parse_pipelines_from_directory,
)
from moabb.utils import set_download_dir


try:
Expand All @@ -32,18 +35,19 @@


def benchmark( # noqa: C901
pipelines="./pipelines/",
evaluations=None,
paradigms=None,
results="./results/",
overwrite=False,
output="./benchmark/",
n_jobs=-1,
n_jobs_evaluation=1,
plot=False,
contexts=None,
include_datasets=None,
exclude_datasets=None,
pipelines: str = "./pipelines/",
evaluations: List[str] = None,
paradigms: List[str] = None,
results: str = "./results/",
overwrite: bool = False,
output: str = "./benchmark/",
n_jobs: int = -1,
n_jobs_evaluation: int = 1,
plot: bool = False,
contexts: str = None,
include_datasets: List[Union[str, BaseDataset]] = None,
exclude_datasets: List[Union[str, BaseDataset]] = None,
mne_data: str = None,
):
"""Run benchmarks for selected pipelines and datasets

Expand Down Expand Up @@ -100,6 +104,8 @@ def benchmark( # noqa: C901
and exclude_datasets are specified, raise an error.
exclude_datasets: list of str or Dataset object
Datasets to exclude from the benchmark run
mne_data: str
Folder where to save and load the datasets with mne structure.

Returns
-------
Expand All @@ -123,6 +129,9 @@ def benchmark( # noqa: C901
mne.set_log_level(False)
# logging.basicConfig(level=logging.WARNING)

if mne_data is not None:
set_download_dir(mne_data)

output = Path(output)
if not osp.isdir(output):
os.makedirs(output)
Expand Down Expand Up @@ -324,3 +333,9 @@ def _inc_exc_datasets(datasets, include_datasets, exclude_datasets):
else:
d = list(datasets)
return d


if __name__ == "__main__":
import fire

fire.Fire(benchmark)
124 changes: 0 additions & 124 deletions moabb/run.py

This file was deleted.

15 changes: 15 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ tdlda = { git = "https://github.com/jsosulski/tdlda.git", rev = "0.1.0" }
sphinx-design = "^0.3.0"
sphinx-rtd-theme = "^1.2.0"

[tool.poetry.group.benchmark]
optional = true

[tool.poetry.group.benchmark.dependencies]
fire = "^0.5.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
Loading