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__(tdm_client, minio_url=None, studio_client=None, storage_client=None, workspace_name=None, set_global=True, debug=False)
Initialize a SnorkelSDKContext.
\_\_init\_\_
__init__
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_name
SnorkelSDKContext objects are only scoped to work in a particular workspace. - 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
Parameters
Returns
Returns
A SnorkelSDKContext object that can be used to interact with the MinIO, TDM, and Studio clients directly.
Return type
Return type
Name Type Default Info endpoint Optional[str]
None
The baseurl to a snorkelflow instance. minio_endpoint Optional[str]
None
The url to a minio service. workspace_name Optional[str]
None
The workspace name, which determines the workspace a dataset and application will be created in and queried from. api_key Optional[str]
None
The API key to use for the TDM, Studio, and Storage APIs. set_global bool
True
Whether to set the context as the global context, accessible across all notebooks in-platform. debug bool
False
Whether 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 sf
ctx = sf.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 sf
ctx = sf.SnorkelSDKContext.from_endpoint_url(...)
sf.SnorkelSDKContext.set_global(ctx)
set\_global
set_global
- property storage_client: StorageClient