• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WenjieDu / PyPOTS / 25324645821

04 May 2026 02:25PM UTC coverage: 79.831% (-0.3%) from 80.104%
25324645821

push

github

web-flow
Replace HPO framework NNI with Optuna and update CLI (#852)

1343 of 1869 new or added lines in 20 files covered. (71.86%)

6 existing lines in 2 files now uncovered.

16569 of 20755 relevant lines covered (79.83%)

1.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.55
/pypots/cli/dev.py
1
"""
2
CLI tools to help the development team build PyPOTS.
3
"""
4

5
# Created by Wenjie Du <wenjay.du@gmail.com>
6
# License: BSD-3-Clause
7

8
import os
2✔
9
import shutil
2✔
10

11
import click
2✔
12

13
from .base import execute_command, check_if_under_root_dir
2✔
14

15
IMPORT_ERROR_MESSAGE = (
2✔
16
    "`pypots-cli dev` command is for PyPOTS developers to run tests easily. "
17
    "Therefore, you need a complete PyPOTS development environment. However, you are missing some dependencies. "
18
    "Please refer to https://github.com/WenjieDu/PyPOTS/blob/main/environment-dev.yml for dependency details. "
19
)
20

21

22
@click.command(name="dev", help="CLI tools helping develop PyPOTS code")
2✔
23
@click.option(
2✔
24
    "--build",
25
    is_flag=True,
26
    help="Build PyPOTS into a wheel and package the source code into a .tar.gz file for distribution",
27
)
28
@click.option(
2✔
29
    "-c", "--cleanup",
30
    is_flag=True,
31
    help="Delete all caches and building files",
32
)
33
@click.option(
2✔
34
    "--run_tests", "--run-tests",
35
    is_flag=True,
36
    help="Run all test cases",
37
)
38
@click.option(
2✔
39
    "-k", "k",
40
    default=None,
41
    type=str,
42
    help="The -k option of pytest. Description of -k option in pytest: "
43
    "only run tests which match the given substring expression. An expression is a python evaluatable "
44
    "expression where all names are substring-matched against test names and their parent classes. "
45
    "Example: -k 'test_method or test_other' matches all test functions and classes whose name contains "
46
    "'test_method' or 'test_other', while -k 'not test_method' matches those that don't contain "
47
    "'test_method' in their names. -k 'not test_method and not test_other' will eliminate the matches. "
48
    "Additionally keywords are matched to classes and functions containing extra names in their "
49
    "'extra_keyword_matches' set, as well as functions which have names assigned directly to them. The "
50
    "matching is case-insensitive.",
51
)
52
@click.option(
2✔
53
    "--show-coverage", "--show_coverage",
54
    is_flag=True,
55
    help="Show the code coverage report after running tests",
56
)
57
@click.option(
2✔
58
    "--lint-code", "--lint_code",
59
    is_flag=True,
60
    help="Run Black and Flake8 to lint code",
61
)
62
def dev(build, cleanup, run_tests, k, show_coverage, lint_code):
2✔
63
    """Execute the dev command."""
64
    from ..utils.logging import logger
2✔
65

66
    # run checks
67
    check_if_under_root_dir(strict=True)
2✔
68

69
    if k is not None:
2✔
70
        assert run_tests, (
2✔
71
            "Argument `-k` should combine the use of `--run_tests`. "
72
            "Try `pypots-cli dev --run_tests -k your_pattern`"
73
        )
74

75
    if show_coverage:
2✔
NEW
76
        assert run_tests, (
×
77
            "Argument `--show_coverage` should combine the use of `--run_tests`. "
78
            "Try `pypots-cli dev --run_tests --show_coverage`"
79
        )
80

81
    if cleanup:
2✔
82
        assert (
2✔
83
            not run_tests and not lint_code
84
        ), "Argument `--cleanup` should be used alone. Try `pypots-cli dev --cleanup`"
85

86
    try:
2✔
87
        if cleanup:
2✔
88
            shutil.rmtree("build", ignore_errors=True)
2✔
89
            shutil.rmtree("dist", ignore_errors=True)
2✔
90
            shutil.rmtree("pypots.egg-info", ignore_errors=True)
2✔
91
        elif build:
2✔
92
            execute_command("python -m build")
2✔
93
        elif run_tests:
2✔
94
            pytest_command = f"pytest -k {k}" if k is not None else "pytest"
2✔
95
            command_to_run_test = f"coverage run -m {pytest_command}" if show_coverage else pytest_command
2✔
96
            execute_command(command_to_run_test)
2✔
NEW
97
            if show_coverage and os.path.exists(".coverage"):
×
NEW
98
                execute_command("coverage report -m")
×
NEW
99
        elif lint_code:
×
NEW
100
            logger.info("Reformatting with Black...")
×
NEW
101
            execute_command("black .")
×
NEW
102
            logger.info("Linting with Flake8...")
×
NEW
103
            execute_command("flake8 .")
×
104
    except ImportError:
2✔
NEW
105
        raise ImportError(IMPORT_ERROR_MESSAGE)
×
106
    except Exception as e:
2✔
107
        raise e
2✔
108
    finally:
109
        shutil.rmtree(".pytest_cache", ignore_errors=True)
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc