diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index ef33fc23..c781bb0b 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -2,10 +2,12 @@ Changelog ========= +* Rename run_analsis to run_analysis +* Move `-nt` to base args (Fixes #109) * set `long-description` to single file * remove Py3.8 * Fixing codecov upload -* Translate ```setup.py`` into ``pyproject.toml`` +* Translate ``setup.py`` into ``pyproject.toml`` v0.1.24 (2023-01-27) ------------------------------------------ diff --git a/src/mdacli/cli.py b/src/mdacli/cli.py index 7b9c4b21..248bad66 100644 --- a/src/mdacli/cli.py +++ b/src/mdacli/cli.py @@ -19,7 +19,7 @@ from .libcli import ( find_cls_members, init_base_argparse, - run_analsis, + run_analysis, setup_clients, split_argparse_into_groups, ) @@ -130,12 +130,12 @@ def cli(name, arg_grouped_dict.setdefault("Output Parameters", {}) with threadpool_limits(limits=args.num_threads): - run_analsis(analysis_callable, - arg_grouped_dict["Mandatory Parameters"], - arg_grouped_dict["Optional Parameters"], - arg_grouped_dict["Reference Universe Parameters"], - arg_grouped_dict["Analysis Run Parameters"], - arg_grouped_dict["Output Parameters"]) + run_analysis(analysis_callable, + arg_grouped_dict["Mandatory Parameters"], + arg_grouped_dict["Optional Parameters"], + arg_grouped_dict["Reference Universe Parameters"], + arg_grouped_dict["Analysis Run Parameters"], + arg_grouped_dict["Output Parameters"]) except Exception as e: if args.debug: traceback.print_exc() diff --git a/src/mdacli/libcli.py b/src/mdacli/libcli.py index e24525bb..c93ff1e4 100644 --- a/src/mdacli/libcli.py +++ b/src/mdacli/libcli.py @@ -203,13 +203,6 @@ def add_run_group(analysis_class_parser): help="step or time step for evaluation (default: %(default)s)" ) - run_group.add_argument( - "-nt", - dest="num_threads", - type=int, - default=0, - help="Total number of threads to start (0 is guess)") - run_group.add_argument( "-v", dest="verbose", @@ -375,8 +368,8 @@ def create_cli(sub_parser, interface_name, parameters): formatter_class=argparse.RawDescriptionHelpFormatter, ) - # Add run_analsis function as the default func parameter. - # this is possible because the run_analsis function is equal to all + # Add run_analysis function as the default func parameter. + # this is possible because the run_analysis function is equal to all # Analysis Classes analysis_class_parser.set_defaults( analysis_callable=parameters["callable"]) @@ -550,12 +543,12 @@ def create_universe(topology, return universe -def run_analsis(analysis_callable, - mandatory_analysis_parameters, - optional_analysis_parameters=None, - reference_universe_parameters=None, - run_parameters=None, - output_parameters=None): +def run_analysis(analysis_callable, + mandatory_analysis_parameters, + optional_analysis_parameters=None, + reference_universe_parameters=None, + run_parameters=None, + output_parameters=None): """Perform main client logic. Parameters @@ -786,6 +779,13 @@ def init_base_argparse(name, version, description): help="Run with debug options.", ) + ap.add_argument( + "-nt", + dest="num_threads", + type=int, + default=0, + help="Total number of threads to start (0 is guess)") + ap.add_argument('--logfile', dest='logfile', action='store', diff --git a/tests/test_cli.py b/tests/test_cli.py index 4220c5a4..4e18bb95 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -10,6 +10,7 @@ import subprocess import pytest +from MDAnalysisTests.datafiles import TPR, XTC def test_required_args(): @@ -34,3 +35,9 @@ def test_extra_options(args): def test_case_insensitive(args): """Test for beeing case insensitive.""" subprocess.check_call(['mda', args, "-h"]) + + +def test_running_analysis(): + """Test running a complete analysis.""" + subprocess.check_call( + ['mda', "rmsf", "-s", TPR, "-f", XTC, "-atomgroup", "all"]) diff --git a/tests/test_libcli.py b/tests/test_libcli.py index 5bd582a0..d950acfa 100644 --- a/tests/test_libcli.py +++ b/tests/test_libcli.py @@ -39,7 +39,7 @@ find_classes_in_modules, find_cls_members, init_base_argparse, - run_analsis, + run_analysis, setup_clients, split_argparse_into_groups, ) @@ -478,7 +478,7 @@ def test_multi_atomgroup_None(self, universe): assert analysis_parameters["p0"] is None -class Test_run_analsis: +class Test_run_analysis: """Test class for analyze_data.""" @pytest.fixture() @@ -506,7 +506,7 @@ def test_default(self, tmpdir): """Test with default arguments.""" with tmpdir.as_cwd(): - run_analsis( + run_analysis( analysis_callable=InterRDF, reference_universe_parameters=reference_universe_parameters, mandatory_analysis_parameters=mandatory_parameters) @@ -518,7 +518,7 @@ def test_optional_paramaters(self, """Test with optional parameters given.""" opt_params = {"nbins": 100} with tmpdir.as_cwd(): - a = run_analsis( + a = run_analysis( analysis_callable=InterRDF, reference_universe_parameters=reference_universe_parameters, mandatory_analysis_parameters=mandatory_parameters, @@ -535,7 +535,7 @@ def test_verbose(self, run_parameters = {"verbose": True} caplog.set_level(logging.INFO) with tmpdir.as_cwd(): - run_analsis( + run_analysis( analysis_callable=InterRDF, reference_universe_parameters=reference_universe_parameters, mandatory_analysis_parameters=mandatory_parameters, @@ -552,7 +552,7 @@ def test_custom_output(self, with tmpdir.as_cwd(): os.mkdir("foo") - run_analsis( + run_analysis( analysis_callable=InterRDF, reference_universe_parameters=reference_universe_parameters, mandatory_analysis_parameters=mandatory_parameters, @@ -569,7 +569,7 @@ def test_output_directory(self, output_parameters = {"output_directory": "foo"} with tmpdir.as_cwd(): os.mkdir("foo") - run_analsis( + run_analysis( analysis_callable=InterRDF, reference_universe_parameters=reference_universe_parameters, mandatory_analysis_parameters=mandatory_parameters, @@ -585,7 +585,7 @@ def test_output_prefix(self, output_parameters = {"output_prefix": "foo"} with tmpdir.as_cwd(): os.mkdir("foo") - run_analsis( + run_analysis( analysis_callable=InterRDF, reference_universe_parameters=reference_universe_parameters, mandatory_analysis_parameters=mandatory_parameters,