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

pyiron / pysqa / 5569657923

pending completion
5569657923

Pull #206

github-actions

web-flow
Merge 7cd76d976 into 4e7f0acf5
Pull Request #206: Implement an concurrent.futures.Executor for pysqa

130 of 130 new or added lines in 5 files covered. (100.0%)

839 of 984 relevant lines covered (85.26%)

0.85 hits per line

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

67.86
/pysqa/executor/backend.py
1
import os
1✔
2
import sys
1✔
3

4
from pympipool import PoolExecutor
1✔
5
from pysqa.executor.helper import (
1✔
6
    read_from_file,
7
    deserialize,
8
    write_to_file,
9
    serialize_result,
10
)
11

12

13
def execute_files_from_list(tasks_in_progress_dict, cache_directory, executor):
1✔
14
    file_lst = os.listdir(cache_directory)
1✔
15
    for file_name_in in file_lst:
1✔
16
        key = file_name_in.split(".in.pl")[0]
1✔
17
        file_name_out = key + ".out.pl"
1✔
18
        if (
1✔
19
            file_name_in.endswith(".in.pl")
20
            and file_name_out not in file_lst
21
            and file_name_out not in tasks_in_progress_dict.keys()
22
        ):
23
            funct_dict = read_from_file(
1✔
24
                file_name=os.path.join(cache_directory, file_name_in)
25
            )
26
            apply_dict = deserialize(funct_dict=funct_dict)
1✔
27
            for k, v in apply_dict.items():
1✔
28
                tasks_in_progress_dict[k] = executor.submit(
1✔
29
                    v["fn"], *v["args"], **v["kwargs"]
30
                )
31
    for k, v in tasks_in_progress_dict.items():
1✔
32
        if v.done():
1✔
33
            write_to_file(
1✔
34
                funct_dict=serialize_result(result_dict={k: v.result()}),
35
                state="out",
36
                cache_directory=cache_directory,
37
            )
38

39

40
def execute_tasks(cores, cache_directory):
1✔
41
    tasks_in_progress_dict = {}
×
42
    with PoolExecutor(
×
43
        max_workers=cores,
44
        oversubscribe=False,
45
        enable_flux_backend=False,
46
        enable_slurm_backend=False,
47
        init_function=None,
48
        cwd=cache_directory,
49
        queue_adapter=None,
50
        queue_adapter_kwargs=None,
51
    ) as exe:
52
        while True:
×
53
            execute_files_from_list(
×
54
                tasks_in_progress_dict=tasks_in_progress_dict,
55
                cache_directory=cache_directory,
56
                executor=exe,
57
            )
58

59

60
def command_line(arguments_lst=None):
1✔
61
    if arguments_lst is None:
×
62
        arguments_lst = sys.argv[1:]
×
63
    cores_arg = arguments_lst[arguments_lst.index("--cores") + 1]
×
64
    path_arg = arguments_lst[arguments_lst.index("--path") + 1]
×
65
    execute_tasks(cores=cores_arg, cache_directory=path_arg)
×
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