Skip to main content

Dataset

class datasetversion.Dataset()#

A dataset representation.

Used to manage a dataset and it’s versions

warning

Do not instantiate directly. Use Dataset.get or Dataset.create methods instead.


id#

property id

The dataset’s id.

  • Return type

    str


name#

property name

The dataset’s name.

  • Return type

    str


Dataset.create#

classmethod create(dataset_name, comment=None, tags=None, raise_if_exists=False)

Create a new dataset in the system and return a Dataset object for it.

  • Parameters

    • dataset_name (str ) – The name of the new dataset.

    • comment (str ) – A free text to describe the dataset

    • tags (list ) – A list of tags (short strings) to classify the dataset

    • raise_if_exists (bool ) – If False (the default) and there is a dataset with the name :paramref:`~.create.dataset_name`, return the existing Dataset. If True and there is a dataset with the name :paramref:`~.create.dataset_name`, raise ValueError exception.

  • Return type

    ForwardRef

  • Returns

    A new Dataset object for the newly created dataset.


Dataset.get#

classmethod get(dataset_id=None, dataset_name=None)

Return a Dataset object for an existing dataset.

  • Parameters

    • dataset_id (Optional[str]) – The ID of the dataset.

    • dataset_name (Optional[str]) – The name of the dataset.

  • Return type

    Dataset

info

:paramref:~.Dataset.get.dataset_id and :paramref:~.Dataset.get.dataset_name are mutually exclusive, setting both to non-None values will raise a UsageError exception.

  • Return type

    ForwardRef

  • Returns

    A new Dataset object for the dataset. If :paramref:`~.Dataset.get.dataset_name` is set and there are several datasets with that name, return an arbitrary one.

  • Parameters

    • dataset_id (Optional [ str ] ) –

    • dataset_name (Optional [ str ] ) –


Dataset.delete#

classmethod delete(dataset_id=None, dataset_name=None, delete_all_versions=False, force=False)

Delete a dataset from the system

If several datasets with the name dataset_name exists, delete an arbitrary one.

  • Parameters

    • dataset_id (str ) – The ID of the dataset.

    • dataset_name (str ) – The name of the dataset.

    • delete_all_versions (bool ) – If True, delete the dataset with all of it’s versions. If False, expect the dataset to have no versions. If there are raise an exception. Default: False.

    • force (bool ) – If True, and :paramref:`~.delete.delete_all_versions` is True, delete also published versions. If False, and :paramref:`~.delete.delete_all_versions` is True, raise an exception if there is a published version in the dataset. If :paramref:`~.delete.delete_all_versions` is False, this has no effect. Default: False

  • Return type

    None

info

:paramref:~.delete.dataset_id and :paramref:~.delete.dataset_name are mutually exclusive, setting both to non-None values will raise a UsageError exception.

  • Return type

    None

  • Parameters

    • dataset_id (Optional [ str ] ) –

    • dataset_name (Optional [ str ] ) –

    • delete_all_versions (bool ) –

    • force (bool ) –


create_version#

create_version(version_name, description=None, parent_version_ids=None, parent_version_names=None, raise_if_exists=False, auto_upload_destination=None, local_dataset_root_path=None)

Create and return a new DatasetVersion for this Dataset.

  • Parameters

    • version_name (str ) – The new version name.

    • description (str ) – A free text to describe the version.

    • parent_version_ids (list ) – A list of the new version parents IDs. All ID’s must be existing version’s IDs in this dataset. Currently support only a single parent for version. This is a list for future compatibility.

    • parent_version_names (list ) – A list of the new version parents names. All names must be existing version’s names in this dataset. Currently support only a single parent for version. This is a list for future compatibility.

    • raise_if_exists (bool ) – If False (the default) and a version with the name :paramref:`~.create_version.version_name` exists in this dataset, return that version. If True, raise a ValueError exception.

    • auto_upload_destination (str ) – If specified any local file linked by a SingleFrame/FrameGroup, will be automatically uploaded to the destination storage.

    • Path ] local_dataset_root_path (Union [ str , ) – Required if auto_upload_destination is provided. It should point to the common folder for all local source files

    • local_dataset_root_path (Optional [ Union [ str , pathlib2.Path ] ] ) –

  • Return type

    DatasetVersion

info

:paramref:~.create_version.parent_version_ids and :paramref:~.create_version.parent_version_names are mutually exclusive, setting both to non-None values will raise a UsageError exception.

  • Return type

    ForwardRef

  • Returns

    A new DatasetVersion object with the name :paramref:`~.create_version.version_name` in this Dataset.

  • Parameters

    • version_name (str ) –

    • description (Optional [ str ] ) –

    • parent_version_ids (Optional [ List [ str ] ] ) –

    • parent_version_names (Optional [ List [ str ] ] ) –

    • raise_if_exists (bool ) –

    • auto_upload_destination (Optional [ str ] ) –

    • local_dataset_root_path (Optional [ Union [ str , pathlib2.Path ] ] ) –


get_version#

get_version(version_id=None, version_name=None, auto_upload_destination=None, local_dataset_root_path=None)

Return a DatasetVersion object of a version in this dataset.

  • Parameters

    • version_id (str ) – The id of the version to get.

    • version_name (str ) – The name of the version to get. If several versions exist with that name return an arbitrary one.

    • auto_upload_destination (str ) – If specified any local file linked by a SingleFrame/FrameGroup, will be automatically uploaded to the destination storage.

    • Path ] local_dataset_root_path (Union [ str , ) – Required if auto_upload_destination is provided. It should point to the common folder for all local source files

    • local_dataset_root_path (Optional [ Union [ str , pathlib2.Path ] ] ) –

  • Return type

    allegroai.datasetversion.DatasetVersion

info

:paramref:~.get_version.version_id and :paramref:~.get_version.version_name are mutually exclusive, setting both to non-None values will raise a UsageError exception.

  • Return type

    DatasetVersion

  • Returns

    A DatasetVersion object of the desired version from this dataset.

  • Parameters

    • version_id (Optional [ str ] ) –

    • version_name (Optional [ str ] ) –

    • auto_upload_destination (Optional [ str ] ) –

    • local_dataset_root_path (Optional [ Union [ str , pathlib2.Path ] ] ) –


get_versions#

get_versions(only_published=False)

Return a list of all the versions of a Dataset

  • Parameters

    only_published (bool ) – If True, return only published versions. If False, return all versions.

  • Return type

    List[DatasetVersion]

  • Returns

    A list of DatasetVersion objects for all the versions in this dataset.


delete_version#

delete_version(version_id=None, version_name=None, force=False)

Delete a version from this dataset.

  • Parameters

    • version_id (str ) – The id of the version to delete.

    • version_name (str ) – The name of the version to delete. If several versions with this name exists in this dataset, delete an arbitrary one.

    • force (bool ) – If True, delete even if version is published. Default: False.

  • Return type

    None

info

:paramref:~.get_version.version_id and :paramref:~.get_version.version_name are mutually exclusive, setting both to non-None values will raise a UsageError exception.

  • Return type

    None

  • Parameters

    • version_id (Optional [ str ] ) –

    • version_name (Optional [ str ] ) –

    • force (bool ) –