Coverage for glotter/download.py: 24%
21 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-12 02:25 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-12 02:25 +0000
1from concurrent.futures import ThreadPoolExecutor
3from glotter.source import get_sources, filter_sources
4from glotter.settings import Settings
5from glotter.containerfactory import ContainerFactory
8def download(args):
9 sources_by_type = filter_sources(args, get_sources(Settings().source_root))
10 containers = {
11 f"{source.test_info.container_info.image}:{str(source.test_info.container_info.tag)}": source.test_info.container_info
12 for sources in sources_by_type.values()
13 for source in sources
14 }
15 if args.parallel:
16 with ThreadPoolExecutor(max_workers=4) as executor:
17 executor.map(
18 lambda source: _download_image_from_source(source, True),
19 containers.values(),
20 )
21 else:
22 for container_info in containers:
23 _download_image_from_source(container_info)
25 return containers
28def _download_image_from_source(container_info, parallel=False):
29 ContainerFactory().get_image(container_info, parallel=parallel)
32def remove_images(containers, parallel):
33 if parallel:
34 with ThreadPoolExecutor(max_workers=4) as executor:
35 executor.map(ContainerFactory().remove_image, containers.values())
36 else:
37 for container_info in containers:
38 ContainerFactory().remove_image(container_info)