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

ROVI-org / battery-data-toolkit / 8054533490

26 Feb 2024 07:31PM UTC coverage: 80.905% (+0.7%) from 80.231%
8054533490

Pull #46

github

WardLT
Update the name used in tests
Pull Request #46: Introduce ability to store EIS data

45 of 47 new or added lines in 4 files covered. (95.74%)

1 existing line in 1 file now uncovered.

644 of 796 relevant lines covered (80.9%)

0.81 hits per line

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

0.0
/batdata/cli.py
1
from materials_io.utils.interface import get_parser
×
2
from argparse import ArgumentParser
×
3
from tqdm import tqdm
×
4
import logging
×
5
import sys
×
6
import os
×
7

8
logger = logging.getLogger(__name__)
×
9

10

11
# List of the default parsers that are allowed to be used
12
_known_parsers = ['arbin']
×
13

14

15
def main():
×
16
    """Invokes the CLI application"""
17

18
    # Create the argument parser
19
    parser = ArgumentParser(
×
20
        description="Reads through a directory of battery data files and converts them to HDF"
21
    )
22
    parser.add_argument('--debug', action='store_true',
×
23
                        default=False, help='Print logs at the debug level')
24
    parser.add_argument('in_path', help='Path to root directory of data files', type=str)
×
25
    parser.add_argument('out_path', help='Path to root directory of output files', type=str)
×
26

27
    # Run it
28
    args = parser.parse_args()
×
29

30
    # Start the logger
31
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG if args.debug else logging.INFO,
×
32
                        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
33

34
    # Loop through all files
35
    for parser_name in _known_parsers:
×
36
        parser = get_parser(parser_name)
×
37
        logger.info(f'Started running with {parser.__class__.__name__} extractor')
×
38

39
        # File all files that are _possible_ to parse
40
        candidate_files = list(parser.identify_files(args.in_path))
×
41
        logger.info(f'Found {len(candidate_files)} files that could be read by this extractor')
×
42

43
        # Run the extractor on all files
44
        for in_file in tqdm(candidate_files):
×
45
            try:
×
46
                # Attempt to parse
47
                logger.debug(f'Attempting to extract from: {in_file}')
×
48
                data, *_ = parser.generate_dataframe(in_file)
×
49

50
                # If successful, save to HDF5 format
51
                out_dir = os.path.join(
×
52
                    args.out_path,
53
                    os.path.dirname(in_file),
54
                )
55
                os.makedirs(out_dir, exist_ok=True)
×
56
                out_path = os.path.join(
×
57
                    out_dir, '.'.join(os.path.basename(in_file).split('.')[:-1]) + '.hdf'
58
                )
59
                logger.debug(f'Writing to {out_path}')
×
60
                data.to_hdf(out_path, key='df', mode='w')
×
61
            finally:
62
                pass
×
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