snorkelai.sdk.client.ctx.SnorkelSDKContext
- class snorkelai.sdk.client.ctx.SnorkelSDKContext(tdm_client, storage_client=None, workspace_name=None, set_global=True, debug=False)
Bases:
objectThe 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 & Storage API) via user-provided parameters, a YAML config file, or a Snorkel Flow API key.
Examples
import snorkelai.sdk.client as sai
ctx = sai.SnorkelSDKContext.from_endpoint_url(...)- __init__(tdm_client, storage_client=None, workspace_name=None, set_global=True, debug=False)
Initialize a SnorkelSDKContext.
\_\_init\_\_
__init__
Methods
__init__(tdm_client[, storage_client, ...])Initialize a SnorkelSDKContext. from_endpoint_url([endpoint, api_key, ...])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_clientworkspace_nameSnorkelSDKContext objects are only scoped to work in a particular workspace. - classmethod from_endpoint_url(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 sai
ctx = sai.SnorkelSDKContext.from_endpoint_url("https://edge.k8s.g498.io/")# Instantiate with custom kwargs
import snorkelai.sdk.client as sai
ctx = sai.SnorkelSDKContext.from_endpoint_url(
endpoint="https://edge.k8s.g498.io/",
workspace_name="my-workspace",
)# Instantiate with an API key
import snorkelai.sdk.client as sai
ctx = sai.SnorkelSDKContext.from_endpoint_url(
endpoint="https://edge.k8s.g498.io/",
api_key="my-api-key",
)Parameters
Parameters
Returns
Returns
A SnorkelSDKContext object that can be used to interact with the TDM and Storage API clients directly.
Return type
Return type
Name Type Default Info endpoint Optional[str]NoneThe baseurl to a snorkelflow instance. workspace_name Optional[str]NoneThe workspace name, which determines the workspace a dataset and application will be created in and queried from. api_key Optional[str]NoneThe API key to use for the TDM and Storage API. set_global boolTrueWhether to set the context as the global context, accessible across all notebooks. debug boolFalseWhether to enable debug mode. Debug mode will print more verbose errors to the screen inside of the Python notebook.
from\_endpoint\_url
from_endpoint_url
- classmethod get_global()
Retrieve the global SnorkelSDKContext object.
Examples
import snorkelai.sdk.client as sai
ctx = sai.SnorkelSDKContext.get_global()
get\_global
get_global
- set_debug(debug)
Set the verbosity of warnings, details, and stacktraces
set\_debug
set_debug
- 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 sai
ctx = sai.SnorkelSDKContext.from_endpoint_url(...)
sai.SnorkelSDKContext.set_global(ctx)
set\_global
set_global
- property storage_client: StorageClient