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

kit-data-manager / tomo_mapper / 21946156830

12 Feb 2026 12:13PM UTC coverage: 86.453%. Remained the same
21946156830

push

github

GGoetzelmann
Configure pyright to ignore test and codegen folder and

Type safety is not important for tests
codegen folder may not be directly fixable

add exception for false positive type error on custom exception exit

0 of 3 new or added lines in 1 file covered. (0.0%)

2425 of 2805 relevant lines covered (86.45%)

0.86 hits per line

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

45.45
/mapping_cli.py
1
import argparse
1✔
2
import json
1✔
3
import logging
1✔
4
import os
1✔
5
from sys import exit
1✔
6

7
from src.IO.MappingAbortionError import MappingAbortionError
1✔
8
from src.IO.sem.InputReader import InputReader as InputReader_SEM
1✔
9
from src.IO.tomo.InputReader import InputReader as InputReader_TOMO
1✔
10
from src.IO.tomo.OutputWriter import OutputWriter
1✔
11
from src.resources.maps.parsing import map_from_flag
1✔
12

13
# make log level configurable from ENV, defaults to info level
14
logging.basicConfig(
1✔
15
    level=os.environ.get('LOGLEVEL', 'INFO').upper()
16
)
17

18
def add_tomo_parser(subparsers):
1✔
19
    parser_t = subparsers.add_parser(
×
20
        "tomo",
21
        help="Tomography mapping functionality",
22
        description='Extracting of SEM FIB Tomography metadata to unified json format'
23
    )
24
    # Add arguments for input, output, and map
25
    parser_t.add_argument('-i', '--input', help='Input zip file or folder as path', required=True)
×
26
    parser_t.add_argument('-o', '--output', help='Path to output json file', required=True)
×
27

28
    # Create a group for the mutually exclusive map options
29
    map_group = parser_t.add_mutually_exclusive_group(required=True)
×
30

31
    # Add the map file option to the group
32
    map_group.add_argument('-m', '--map', help='Map file as path or remote URI')
×
33

34
    # Add the default map option to the group with the allowed values
35
    map_group.add_argument('-dm', '--default-map', help='Use a default map for a vendor', choices=map_from_flag.keys(), type=str.lower)
×
36

37
    parser_t.set_defaults(func=run_tomo_mapper)
×
38

39

40
def add_sem_parser(subparsers):
1✔
41
    parser_s = subparsers.add_parser(
×
42
        "sem",
43
        help="SEM mapping functionality",
44
        description='Extracting of SEM metadata to unified json format'
45
    )
46
    parser_s.add_argument('-i','--input', help='Input file as file path', required=True)
×
47
    parser_s.add_argument('-m', '--map', help='Map file as path or remote URI', required=True)
×
48
    parser_s.add_argument('-o', '--output', help='Path to output json file', required=True)
×
49
    parser_s.set_defaults(func=run_sem_mapper)
×
50

51
def run_cli():
1✔
52
    main_parser = argparse.ArgumentParser(prog="SEM-FIB-TOMO Mapper")
×
53
    subparsers = main_parser.add_subparsers(dest='command', help="Choose one of the subcommands to use mapper")
×
54
    add_tomo_parser(subparsers)
×
55
    add_sem_parser(subparsers)
×
56

57
    args = main_parser.parse_args()
×
58
    if args.command:
×
59
        args.func(args)
×
60
    else:
61
        main_parser.print_help()
×
62

63
def run_tomo_mapper(args):
1✔
64
    argdict = vars(args)
1✔
65
    INPUT_SOURCE = argdict.get('input')
1✔
66
    MAP_SOURCE = argdict.get('map') or str(map_from_flag.get(argdict.get('default_map')))
1✔
67
    OUTPUT_PATH = argdict.get('output')
1✔
68

69
    reader = None
1✔
70
    try:
1✔
71
        reader = InputReader_TOMO(MAP_SOURCE, INPUT_SOURCE)
1✔
72
        tmpdir = reader.temp_dir_path
1✔
73
    except MappingAbortionError as e:
×
74
        if reader:
×
75
            reader.clean_up()
×
NEW
76
        exit(e)  # pyright: ignore[reportArgumentType]
×
77

78
    output = None
1✔
79
    try:
1✔
80
        setup_infos = reader.retrieve_setup_info()
1✔
81

82
        run_infos = reader.retrieve_run_info()
1✔
83

84
        imgs = reader.retrieve_image_info()
1✔
85

86
        # Now all cases are taken into account
87
        #si = setup_infos if len(setup_infos) >= 1 else None
88
        #ri = run_infos if len(run_infos) >= 1 else None
89

90
        output = OutputWriter.stitch_together(setup_infos, run_infos, imgs)
1✔
91
        OutputWriter.writeOutput(output, OUTPUT_PATH)
1✔
92
    except MappingAbortionError as e:
×
93
        reader.clean_up()
×
NEW
94
        exit(e) # pyright: ignore[reportArgumentType]
×
95

96
    logging.info("Tomography mapping completed.")
1✔
97
    reader.clean_up()
1✔
98
    return output
1✔
99

100
def run_sem_mapper(args):
1✔
101
    argdict = vars(args)
×
102
    INPUT_SOURCE = argdict.get('input')
×
103
    MAP_SOURCE = argdict.get('map')
×
104
    OUTPUT_PATH = argdict.get('output')
×
105

106
    try:
×
107
        reader = InputReader_SEM(MAP_SOURCE, INPUT_SOURCE)
×
108

109
        img_info = reader.retrieve_image_info(INPUT_SOURCE)
×
110
        if not img_info:
×
111
            logging.error('Could not retrieve image information due to unknown error. Aborting.')
×
112
            exit(1)
×
113
        with open(OUTPUT_PATH, 'w', encoding="utf-8") as f:
×
114
            json.dump(img_info, f, indent=4, ensure_ascii=False)
×
115
    except MappingAbortionError as e:
×
NEW
116
        exit(e) # pyright: ignore[reportArgumentType]
×
117

118

119
if __name__ == '__main__':
1✔
120
    run_cli()
×
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