Skip to content

declearn.test_utils.setup_client_argparse

Set up an ArgumentParser to be used in a client-side script.

Arguments

usage: str or None, default=None Optional usage string to add to the ArgumentParser. default_uri: str, default="wss://localhost:8765" Default value for the 'uri' argument. default_ptcl: str, default="websockets" Default value for the 'protocol' argument. default_cert: str, default="./ca-cert.pem" Default value for the 'certificate' argument.

Returns:

Name Type Description
parser argparse.ArgumentParser

ArgumentParser with pre-set optional arguments required to configure network communications on the client side.

Source code in declearn/test_utils/_argparse.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def setup_client_argparse(
    usage: Optional[str] = None,
    default_uri: str = "wss://localhost:8765",
    default_ptcl: str = "websockets",
    default_cert: str = "./ca-cert.pem",
) -> argparse.ArgumentParser:
    """Set up an ArgumentParser to be used in a client-side script.

    Arguments
    ---------
    usage: str or None, default=None
        Optional usage string to add to the ArgumentParser.
    default_uri: str, default="wss://localhost:8765"
        Default value for the 'uri' argument.
    default_ptcl: str, default="websockets"
        Default value for the 'protocol' argument.
    default_cert: str, default="./ca-cert.pem"
        Default value for the 'certificate' argument.

    Returns
    -------
    parser: argparse.ArgumentParser
        ArgumentParser with pre-set optional arguments required
        to configure network communications on the client side.
    """
    parser = argparse.ArgumentParser(
        usage=usage,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument(
        "--uri",
        dest="uri",
        type=str,
        help="server URI to which to connect",
        default=default_uri,
    )
    parser.add_argument(
        "--protocol",
        dest="protocol",
        type=str,
        help="name of the communication protocol to use",
        default=default_ptcl,
    )
    parser.add_argument(
        "--cert",
        dest="certificate",
        type=str,
        help="path to the client-side ssl certificate authority file",
        default=default_cert,
    )
    return parser