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

maurergroup / dfttoolkit / 13360600347

17 Feb 2025 12:54AM UTC coverage: 27.421% (+5.7%) from 21.747%
13360600347

Pull #45

github

b9a790
web-flow
Merge 4b6418e02 into 8f2f01da9
Pull Request #45: Bump ruff from 0.9.4 to 0.9.6

855 of 3118 relevant lines covered (27.42%)

0.27 hits per line

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

90.0
dfttoolkit/utils/run_utils.py
1
import os.path
1✔
2
from functools import wraps
1✔
3

4

5
def no_repeat(
1✔
6
    original_func=None,
7
    *,
8
    output_file: str = "aims.out",
9
    calc_dir: str = "./",
10
    force: bool = False,
11
):
12
    """
13
    Don't repeat the calculation if aims.out exists in the calculation directory.
14

15
    Parameters
16
    ----------
17
    output_file : str, default='aims.out'
18
        The name of the output file to check for.
19
    calc_dir : str, default="./"
20
        The directory where the calculation is performed
21
    force : bool, default=False
22
        If True, the calculation is performed even if aims.out exists in the calculation
23
        directory.
24

25
    Raises
26
    -------
27
    ValueError
28
        if the `calc_dir` kwarg is not a directory
29
    """
30

31
    def _no_repeat(func):
1✔
32
        @wraps(func)
1✔
33
        def wrapper(*args, **kwargs):
1✔
34
            # Override calc_dir in decorator call if given in func
35
            if "calc_dir" in kwargs:
1✔
36
                check_dir = kwargs["calc_dir"]
×
37
            else:
38
                check_dir = calc_dir
1✔
39

40
            if not os.path.isdir(check_dir):
1✔
41
                raise ValueError(f"{check_dir} is not a directory.")
1✔
42
            if force:
1✔
43
                return func(*args, **kwargs)
1✔
44
            if not os.path.isfile(f"{check_dir}/{output_file}"):
1✔
45
                return func(*args, **kwargs)
1✔
46
            else:
47
                print(f"aims.out already exists in {check_dir}. Skipping calculation.")
1✔
48

49
        return wrapper
1✔
50

51
    if original_func:
1✔
52
        return _no_repeat(original_func)
×
53

54
    return _no_repeat
1✔
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

© 2025 Coveralls, Inc