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

pyiron / executorlib / 11766741741

10 Nov 2024 04:26PM CUT coverage: 94.813% (-0.3%) from 95.089%
11766741741

Pull #491

github

web-flow
Merge e34b5de8a into 78062fd9b
Pull Request #491: Empty cache

9 of 12 new or added lines in 2 files covered. (75.0%)

914 of 964 relevant lines covered (94.81%)

0.95 hits per line

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

90.0
/executorlib/backend/interactive_serial.py
1
import sys
1✔
2
from os.path import abspath
1✔
3
from typing import List, Optional
1✔
4

5
from executorlib.standalone.interactive.backend import call_funct, parse_arguments
1✔
6
from executorlib.standalone.interactive.communication import (
1✔
7
    interface_connect,
8
    interface_receive,
9
    interface_send,
10
    interface_shutdown,
11
)
12

13

14
def main(argument_lst: Optional[List[str]] = None):
1✔
15
    """
16
    The main function of the program.
17

18
    Args:
19
        argument_lst (Optional[List[str]]): List of command line arguments. If None, sys.argv will be used.
20

21
    Returns:
22
        None
23
    """
24
    if argument_lst is None:
1✔
25
        argument_lst = sys.argv
×
26
    argument_dict = parse_arguments(argument_lst=argument_lst)
1✔
27
    context, socket = interface_connect(
1✔
28
        host=argument_dict["host"], port=argument_dict["zmqport"]
29
    )
30

31
    memory = None
1✔
32

33
    # required for flux interface - otherwise the current path is not included in the python path
34
    cwd = abspath(".")
1✔
35
    if cwd not in sys.path:
1✔
36
        sys.path.insert(1, cwd)
×
37

38
    while True:
1✔
39
        # Read from socket
40
        input_dict = interface_receive(socket=socket)
1✔
41

42
        # Parse input
43
        if "shutdown" in input_dict.keys() and input_dict["shutdown"]:
1✔
44
            interface_send(socket=socket, result_dict={"result": True})
1✔
45
            interface_shutdown(socket=socket, context=context)
1✔
46
            break
1✔
47
        elif (
1✔
48
            "fn" in input_dict.keys()
49
            and "init" not in input_dict.keys()
50
            and "args" in input_dict.keys()
51
            and "kwargs" in input_dict.keys()
52
        ):
53
            # Execute function
54
            try:
1✔
55
                output = call_funct(input_dict=input_dict, funct=None, memory=memory)
1✔
56
            except Exception as error:
1✔
57
                interface_send(
1✔
58
                    socket=socket,
59
                    result_dict={"error": error, "error_type": str(type(error))},
60
                )
61
            else:
62
                # Send output
63
                interface_send(socket=socket, result_dict={"result": output})
1✔
64
        elif (
1✔
65
            "init" in input_dict.keys()
66
            and input_dict["init"]
67
            and "args" in input_dict.keys()
68
            and "kwargs" in input_dict.keys()
69
        ):
70
            memory = call_funct(input_dict=input_dict, funct=None)
1✔
71

72

73
if __name__ == "__main__":
1✔
74
    main(argument_lst=sys.argv)
×
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