Skip to content

webknossos.client

webknossos_context

webknossos_context(
    url: str | None = None,
    token: str | None = None,
    timeout: int | None = None,
)

Bases: ContextDecorator

Creates a new WEBKNOSSOS server context manager.

Can be used as a context manager with 'with' or as a decorator.

Parameters:

  • url (str | None, default: None ) –

    Base URL for WEBKNOSSOS server, defaults to https://webknossos.org. Taken from previous context if not specified.

  • token (str | None, default: None ) –

    Authentication token from https://webknossos.org/auth/token. Must be specified explicitly.

  • timeout (int | None, default: None ) –

    Network request timeout in seconds, defaults to 1800 (30 min). Taken from previous context if not specified.

Examples:

Using as context manager:

with webknossos_context(token="my_webknossos_token"):
    # code that interacts with webknossos
    ds.download(...)

Using as decorator:

@webknossos_context(token="my_webknossos_token")
def my_func():
    # code that interacts with webknossos
    ...
Note

The url and timeout parameters will use values from the previous context (e.g. environment variables) if not specified explicitly. The token parameter must always be set explicitly.