-
copy_datasets: when set to True, the Datasets from the original Project are attached to the new Project and new tasks are created from them. To choose how Datasets are handled, passCopyDatasetOptionsinstead. See Datasets, Files, and custom metadata in copied Projects. - 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.
Datasets, Files, and custom metadata in copied Projects
Copying a Project never copies your Files. Every Project, whether it is the original or a copy, uses the same Files in your Folders. Custom metadata (clientMetadata) is stored on each File. This means that custom metadata is shared between the original Project and the copy, whichever option you choose. If you update the custom metadata of a File, both Projects show the change. You never need to update custom metadata in two places.
copy_datasets accepts True or a CopyDatasetOptions object. The action field of CopyDatasetOptions decides what happens to Datasets:
CopyDatasetAction.ATTACH(default, same ascopy_datasets=True): The Datasets of the original Project are attached to the new Project. No new Dataset is created. Both Projects share the same Datasets and the same data units.CopyDatasetAction.CLONE: A new Dataset is created and attached to the new Project. Only the data units you list indatasets_to_data_hashes_mapare added to the new Dataset, as new data units. Each new data unit points to the same File as the data unit it was cloned from. You can clone up to 10,000 data units in one copy.
Folder IDs: Projects do not have Folder IDs. A Dataset only has a Folder ID (
backing_folder_uuid) if it is a mirrored Dataset. Each File has its own ID (uuid) and the ID of the Folder it is in (parent).- With
ATTACH, both Projects use the same Dataset, so the Dataset has the samebacking_folder_uuidin both Projects. - With
CLONE, the new Dataset has no backing Folder, so itsbacking_folder_uuidisNone. The Files behind it still sit in their original Folders, and their custom metadata is the same as in the original Project.
backing_item_uuid values.Copying a Project in the Encord app attaches the original Datasets (
ATTACH). To clone data units into a new Dataset, use the SDK.Copy a Project
app.encord.com/projects/view/<project_hash>/summary
app.us.encord.com/projects/view/<project_hash>/summaryThe sample code below demonstrates how to copy a Project in the most simple way.
Copy a Project Asynchronously
Asynchronous copying requires version 0.2.2 or later of the
encord SDK. It works only for Projects that support workflow_v3. To check, use project.has_workflow_v3. To copy other Projects, use copy_project().copy_project_start() starts a copy in the background and returns a ProjectCopyJob at once. To wait for the copy to finish and get the new Project, call wait_for_project() on the job. You can access the new Project only after the copy succeeds.
copy_project_start() takes the following parameters:
copy_project_start() does not copy models, and copy_labels does not filter labels. To copy only labels with a certain status or ID, use copy_project() with CopyLabelsOptions.Choose the data to copy
Pass one of the following asdata. As with copy_project(), Files are never copied. See Datasets, Files, and custom metadata in copied Projects.
All three classes, and
ProjectCopyFile, are imported from encord.project_copy.
Wait for a copy
wait_for_project() waits for up to 1 hour by default. To change this, pass timeout_seconds. To wait with no time limit, pass timeout_seconds=None.
wait_for_project() raises the following errors. All of them are imported from encord.project_copy.
Each error has a
job_id attribute, so you can check on the copy later.
Check on a copy or resume later
A copy keeps running after your script exits. To check on it later, save the job ID (job.job_id). Then get the job again with user_client.get_project_copy_job(). Use the same user that started the copy.
job.get_status() returns a ProjectCopyResult. Its status is one of:
ProjectCopyStatus.PENDING: The copy is still running.ProjectCopyStatus.DONE: The copy succeeded.project_idholds the new Project’s ID.ProjectCopyStatus.FAILED: The copy failed.errorholds the reason.ProjectCopyStatus.UNKNOWN: The SDK does not recognize the status.raw_statusholds the status that Encord returned. Upgrade the SDK.
get_status() checks once and returns at once. To wait up to a set time for the copy to finish, pass timeout_seconds. If the wait ends first, get_status() returns PENDING. The copy is not cancelled.
A job returned by
copy_project_start() has the new Project’s ID in job.project_id. A job returned by get_project_copy_job() does not: job.project_id is None. Read the ID from the result of get_status() instead.
