Copying a Project creates another Project with the same Ontology and settings. You also have the option to copy over the same users, datasets and models (which are not copied over by default).
The copy_project() method takes the following parameters, all of which are optional:
Copy_datasets: when set to True, the datasets from the original Project will be copied over and new tasks will be created from them.
Copy_collaborators: when set to True, the collaborators from the original Project will be copied over with their existing roles.
Copy_models: when set to True, the models and their training data from the original Project will be copied over.
The parameters above are set to False by default, which means that they don’t need to be included if a given feature shouldn’t be copied to the new Project.
The copy_project() method returns the <project_hash> of the new project.
If collaborators are not copied, reviewer and label mapping settings are not copied over either.
The project hash can be found within the URL once a project has been selected:
The sample code below demonstrates how to copy a Project in the most simple way.
# Import dependenciesfrom encord import EncordUserClient, Project#Authenticate using the path to your private keyuser_client = EncordUserClient.create_with_ssh_private_key(ssh_private_key_path="<private_key_path>")# Specify the project you'd like to copy using its Project hashproject = user_client.get_project("<project_hash>")# Copy the project with attached datasets and collaboratorsnew_project_hash = project.copy_project( copy_datasets=True, copy_collaborators=True, copy_models=False,# Not strictly needed)# Print the new project's hashprint(new_project_hash)
The sample code below demonstrates how to copy a project in a more advanced way.
# Import dependenciesfrom encord import EncordUserClientfrom encord.orm.project import( CopyDatasetAction, CopyDatasetOptions, CopyLabelsOptions, ReviewApprovalState)#Authenticate using the path to your private keyuser_client = EncordUserClient.create_with_ssh_private_key(ssh_private_key_path="<private_key_path>")# Specify the project to be copiedproject = user_client.get_project("<project_hash>")# Copy the projectproject.copy_project( new_title="foo",#specify the new project's title new_description="bar",#specify the new project's description copy_collaborators=True,# specify whether project collaborators should be copied to the new project copy_datasets=CopyDatasetOptions( action=CopyDatasetAction.CLONE,# This will also create a new dataset dataset_title="baz",#specify the new dataset's title dataset_description="quz",# Specify the new dataset's description datasets_to_data_hashes_map={"<dataset_hash>":["<data_hash_1","<data_hash_2"]},), copy_labels=CopyLabelsOptions( accepted_label_statuses=[ReviewApprovalState.APPROVED],# Copy over all labels in the 'Approved' state. accepted_label_hashes=["<label_hash_1>","<label_hash_2>"],# Copy over labels with the listed hashes.),)