Adding Datasets to a Project

To add an existing Dataset to a Project, use the <dataset_hash>.

ℹ️

Note

You need to be an admin of the Datasets that you want to add.


from encord import EncordUserClient, Project

user_client: EncordUserClient = EncordUserClient.create_with_ssh_private_key(
    "<your_private_key>"
)
project: Project = user_client.get_project("<project_hash>")

success: bool = project.add_datasets(
    [
        "<dataset_hash1>",
        "<dataset_hash2>",
        # ...
    ]
)
print(success)
# True or False depending on whether job was successful
True  

ℹ️

Note

[add_datasets()] (https://docs.encord.com/reference/sdk-ref-project#add_datasets) throws an error if it is unable to add a dataset to a project. See the doc-string documentation for further details.

Removing Patasets from a project

You can remove existing Datasets from a Project, using the dataset <dataset_hash> for every Dataset that needs to be removed. To get those hashes, you can follow the example in Listing existing Datasets.

ℹ️

Note

You need to be an admin of the datasets that you want to add.


from encord import EncordUserClient, Project

user_client: EncordUserClient = EncordUserClient.create_with_ssh_private_key(
    "<your_private_key>"
)
project: Project = user_client.get_project("<project_hash>")


success: bool = project.remove_datasets(
    [
        "<dataset_hash1>",
        "<dataset_hash2>",
        # ...
    ]
)
print(success)

# True or False depending on whether job was successful
True

ℹ️

Note

[remove_datasets()] (https://docs.encord.com/reference/sdk-ref-project#remove_datasets) throws an error if it is unable to remove a dataset from a project. See the doc-string documentation for further details.