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

maurergroup / dfttoolkit / 15077298886

16 May 2025 08:57PM UTC coverage: 28.848% (+7.1%) from 21.747%
15077298886

Pull #59

github

b0d5e4
web-flow
Merge 473bfe91e into e895278a4
Pull Request #59: Vibrations refactor

1162 of 4028 relevant lines covered (28.85%)

0.29 hits per line

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

95.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
            check_dir = kwargs.get("calc_dir", calc_dir)
1✔
36

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

47
        return wrapper
1✔
48

49
    if original_func:
1✔
50
        return _no_repeat(original_func)
×
51

52
    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