Skip to main content
Version: 25.5

snorkelai.sdk.client.ctx.SnorkelSDKContext

class snorkelai.sdk.client.ctx.SnorkelSDKContext(tdm_client, minio_url=None, studio_client=None, storage_client=None, workspace_name=None, set_global=True, debug=False)

Bases: object

The SnorkelSDKContext object provides client context for the Snorkel Flow SDK. It allows the Snorkel Flow SDK to recognize a Snorkel Flow instance by identifying Snorkel Flow’s essential API services (TDM, Studio, MinIO) via user-provided parameters, a YAML config file, or a Snorkel Flow API key.

Examples

import snorkelai.sdk.client as sf
ctx = sf.SnorkelSDKContext.from_endpoint_url(...)

__init__

__init__(tdm_client, minio_url=None, studio_client=None, storage_client=None, workspace_name=None, set_global=True, debug=False)

Initialize a SnorkelSDKContext.

Methods

__init__(tdm_client[, minio_url, ...])Initialize a SnorkelSDKContext.
from_endpoint_url([endpoint, ...])Initialize a SnorkelSDKContext from keyword arguments.
get_global()Retrieve the global SnorkelSDKContext object.
set_debug(debug)Set the verbosity of warnings, details, and stacktraces
set_global([ctx])Set a SnorkelSDKContext object globally.

Attributes

storage_client
workspace_nameSnorkelSDKContext objects are only scoped to work in a particular workspace.

from_endpoint_url

classmethod from_endpoint_url(endpoint=None, minio_endpoint=None, api_key=None, workspace_name=None, set_global=True, debug=False, *args, **kwargs)

Initialize a SnorkelSDKContext from keyword arguments.

Examples

# Instantiate with default kwargs and a custom url
import snorkelai.sdk.client as sf
ctx = sf.SnorkelSDKContext.from_endpoint_url("https://edge.k8s.g498.io/")
# Instantiate with custom kwargs
import snorkelai.sdk.client as sf
ctx = sf.SnorkelSDKContext.from_endpoint_url(
endpoint="https://edge.k8s.g498.io/",
minio_endpoint="https://edge-minio-api.k8s.g498.io",
workspace_name="my-workspace",
)
# Instantiate with an API key
import snorkelai.sdk.client as sf
ctx = sf.SnorkelSDKContext.from_endpoint_url(
endpoint="https://edge.k8s.g498.io/",
api_key="my-api-key",
)

Parameters

NameTypeDefaultInfo
endpointOptional[str]NoneThe baseurl to a snorkelflow instance.
minio_endpointOptional[str]NoneThe url to a minio service.
workspace_nameOptional[str]NoneThe workspace name, which determines the workspace a dataset and application will be created in and queried from.
api_keyOptional[str]NoneThe API key to use for the TDM, Studio, and Storage APIs.
set_globalboolTrueWhether to set the context as the global context, accessible across all notebooks in-platform.
debugboolFalseWhether to enable debug mode. Debug mode will print more verbose errors to the screen inside of the Python notebook.

Returns

A SnorkelSDKContext object that can be used to interact with the MinIO, TDM, and Studio clients directly.

Return type

SnorkelSDKContext

get_global

classmethod get_global()

Retrieve the global SnorkelSDKContext object.

Examples

import snorkelai.sdk.client as sf
ctx = sf.SnorkelSDKContext.get_global()

Returns

A SnorkelSDKContext object that can be used to interact with the MinIO, TDM, and Studio clients directly.

Return type

SnorkelSDKContext

Raises

AttributeError – If no global context has been set.

set_debug

set_debug(debug)

Set the verbosity of warnings, details, and stacktraces

Parameters

NameTypeDefaultInfo
debugboolIf True, SDK operations will print more verbose errors to the screen inside of the Python notebook.

Return type

None

set_global

classmethod set_global(ctx=None)

Set a SnorkelSDKContext object globally. This context object will be used by all Snorkel Platform SDK functions.

Examples

import snorkelai.sdk.client as sf
ctx = sf.SnorkelSDKContext.from_endpoint_url(...)
sf.SnorkelSDKContext.set_global(ctx)

Parameters

NameTypeDefaultInfo
ctxOptional[SnorkelSDKContext]NoneA context to set as global. If no context is provided, will attempt to create one with default parameters.

Return type

None

property storage_client: StorageClient
property workspace_name: str

SnorkelSDKContext objects are only scoped to work in a particular workspace.

Returns

The name of the workspace belonging to this context object.

Return type

str