Skip to content

proxystore.p2p.relay.config

Relay server configuration file parsing.

RelayAuthConfig

Bases: BaseModel

Relay authentication configuration.

Attributes:

  • method (Optional[Literal['globus']]) –

    Authentication method.

  • kwargs (Dict[str, Any]) –

    Arbitrary keyword arguments to pass to the authenticator. The kwargs are excluded from the repr() of this class because they often contain secrets.

RelayLoggingConfig

Bases: BaseModel

Relay logging configuration.

Attributes:

  • log_dir (Optional[str]) –

    Default logging directory.

  • default_level (Union[int, str]) –

    Default logging level for the root logger.

  • websockets_level (Union[int, str]) –

    Log level for the websockets logger. Websockets logs with much higher frequency so it is suggested to set this to WARNING or higher.

  • current_clients_interval (Union[int, str]) –

    Optional seconds between logging the number of currently connected clients and user.

  • current_client_limit (Optional[int]) –

    Max threshold for enumerating the detailed list of connected clients. If None, no detailed list will be logged.

RelayServingConfig

Bases: BaseModel

Relay serving configuration.

Attributes:

  • host (Optional[str]) –

    Network interface the server binds to.

  • port (int) –

    Network port the server binds to.

  • certfile (Optional[str]) –

    Certificate file (PEM format) use to enable TLS.

  • keyfile (Optional[str]) –

    Private key file. If not specified, the key will be taken from the certfile.

  • auth (RelayAuthConfig) –

    Authentication configuration.

  • logging (RelayLoggingConfig) –

    Logging configuration.

  • max_message_bytes (Optional[int]) –

    Maximum size in bytes of messages received by the relay server.

from_toml classmethod

from_toml(filepath: str | Path) -> Self

Parse an TOML config file.

Example

Minimal config without SSL and without authentication.

relay.toml
port = 8700

[logging]
log_dir = "/path/to/log/dir"
default_log_level = "INFO"
websockets_log_level = "WARNING"
connected_client_logging_interval = 60
connected_client_logging_limit = 32

from proxystore.p2p.relay.globus.config

config = RelayServingConfig.from_toml('relay.toml')
Example

Serve with SSL and Globus Auth.

relay.toml
host = "0.0.0.0"
port = 8700
certfile = "/path/to/cert.pem"
keyfile = "/path/to/privkey.pem"

[auth]
method = "globus"

[auth.kwargs]
client_id = "..."
client_secret = "..."

[logging]
log_dir = "/path/to/log/dir"
default_log_level = "INFO"
websockets_log_level = "WARNING"
connected_client_logging_interval = 60
connected_client_logging_limit = 32

Note

Omitted values will be set to their defaults (if they are an optional value with a default).

relay.toml
[serving]
certfile = "/path/to/cert.pem"

from proxystore.p2p.relay.config import RelayServingConfig

config = RelayServingConfig.from_config('relay.toml')
assert config.certfile == '/path/to/cert.pem'
assert config.keyfile is None
Source code in proxystore/p2p/relay/config.py
@classmethod
def from_toml(cls, filepath: str | pathlib.Path) -> Self:
    """Parse an TOML config file.

    Example:
        Minimal config without SSL and without authentication.
        ```toml title="relay.toml"
        port = 8700

        [logging]
        log_dir = "/path/to/log/dir"
        default_log_level = "INFO"
        websockets_log_level = "WARNING"
        connected_client_logging_interval = 60
        connected_client_logging_limit = 32
        ```

        ```python
        from proxystore.p2p.relay.globus.config

        config = RelayServingConfig.from_toml('relay.toml')
        ```

    Example:
        Serve with SSL and Globus Auth.
        ```toml title="relay.toml"
        host = "0.0.0.0"
        port = 8700
        certfile = "/path/to/cert.pem"
        keyfile = "/path/to/privkey.pem"

        [auth]
        method = "globus"

        [auth.kwargs]
        client_id = "..."
        client_secret = "..."

        [logging]
        log_dir = "/path/to/log/dir"
        default_log_level = "INFO"
        websockets_log_level = "WARNING"
        connected_client_logging_interval = 60
        connected_client_logging_limit = 32
        ```

    Note:
        Omitted values will be set to their defaults (if they are an
        optional value with a default).
        ```toml title="relay.toml"
        [serving]
        certfile = "/path/to/cert.pem"
        ```

        ```python
        from proxystore.p2p.relay.config import RelayServingConfig

        config = RelayServingConfig.from_config('relay.toml')
        assert config.certfile == '/path/to/cert.pem'
        assert config.keyfile is None
        ```
    """
    with open(filepath, 'rb') as f:
        return load(cls, f)