snorkelflow.sdk.Slice
- class snorkelflow.sdk.Slice(dataset, slice_uid, name, description=None)
Bases:
object
- __init__(dataset, slice_uid, name, description=None)
Create a Slice object in-memory with necessary properties. This constructor should not be called directly, and should instead be accessed through the
create()
andget()
methods- Parameters:
dataset (
Union
[str
,int
]) – The UID or name for the dataset within Snorkel Flowslice_uid (
int
) – The UID for the slice within Snorkel Flowname (
str
) – The name of the slicedescription (
Optional
[str
], default:None
) – The description of the slice
Methods
__init__
(dataset, slice_uid, name[, description])Create a Slice object in-memory with necessary properties.
add_x_uids
(x_uids)Add datapoints to a slice.
create
(dataset, name[, description])Create a slice for a dataset.
get
(dataset, slice)Retrieve a slice by UID.
Retrieve the UIDs of the datapoints in the slice.
list
(dataset)Retrieve all slices for a dataset.
remove_x_uids
(x_uids)Remove datapoints from a slice.
Attributes
Return the UID of the dataset that the slice belongs to
Return the description of the slice
Return the name of the slice
Return the UID of the slice
- add_x_uids(x_uids)
Add datapoints to a slice.
- Parameters:
x_uids (
List
[str
]) – List of UIDs of the datapoints you want to add to the slice- Return type:
None
- classmethod create(dataset, name, description='')
Create a slice for a dataset.
- Parameters:
dataset (
Union
[str
,int
]) – The UID or name for the dataset within Snorkel Flowname (
str
) – The name of the slicedescription (
str
, default:''
) – A description of the slice, by default the empty string
- Returns:
The slice object
- Return type:
- classmethod get(dataset, slice)
Retrieve a slice by UID.
- Parameters:
dataset (
Union
[str
,int
]) – The UID or name for the dataset within Snorkel Flowslice (
Union
[str
,int
]) – The UID or name of the slice
- Returns:
The slice object
- Return type:
- Raises:
ValueError – If no slice is found with the given UID
- get_x_uids()
Retrieve the UIDs of the datapoints in the slice.
- Returns:
List of UIDs of the datapoints in the slice
- Return type:
List[str]
- classmethod list(dataset)
Retrieve all slices for a dataset.
- Parameters:
dataset (
Union
[str
,int
]) – The UID or name for the dataset within Snorkel Flow- Returns:
A list of all the slices available for that dataset
- Return type:
List[Slice]
- Raises:
ValueError – If no dataset is found with the given id
- remove_x_uids(x_uids)
Remove datapoints from a slice.
- Parameters:
x_uids (
List
[str
]) – List of UIDs of the datapoints you want to remove from the slice- Return type:
None
- property dataset_uid: int
Return the UID of the dataset that the slice belongs to
- property description: str | None
Return the description of the slice
- property name: str
Return the name of the slice
- property slice_uid: int
Return the UID of the slice