Index
Cloud-synced Folders with the SDK
Get Started
- Global and US Encord Platforms
- 1. Prerequisites and Installation
- 2. Register Cloud Data
- 3. Set Up Your Project and Team
- Export Labels
General
Index
Projects
Labels
- Working with Labels
- Delete Labels/Classifications
- Label / Activity logs
- Bitmasks
- Audio Labels and Classifications
- HTML Files and Labels
- Text Files and Labels
- PDF Labels and Classifications
- Import Labels/Annotations
- Import Labels/Annotations to Consensus Branches
- Import COCO Labels/Annotations
- Copy labels between Projects
Datasets
Index
Cloud-synced Folders with the SDK
Learn how to create and sync Cloud-synced Folders with the SDK.
Cloud-synced Folders require that you have have at least one integration set up.
Create a Cloud-synced Folder
Create Cloud-synced Folder
from uuid import UUID
from encord import EncordUserClient
from encord.orm.storage import CloudSyncedFolderParams
# User input
SSH_PATH = "/Users/chris-encord/ssh-private-key.txt" # Specify the file path to your SSH key
CLOUD_SYNCED_FOLDER_NAME = "SDK Cloud-Synced Folder" # Specify a meaningful name for your Cloud-synced Folder
CLOUD_SYNCED_FOLDER_DESCRIPTION = "A folder to store my files" # Specify a meaningful description for your Cloud-synced Folder
INTEGRATION_UUID = "3b6299c3-f8c8-4755-ae26-d9144b215920" # Specify the unique id for your integration
REMOTE_URL = "gs://my-gcp-bucket/" # Specify the storage/file path to your cloud storage
# Authenticate with Encord using the path to your private key
user_client: EncordUserClient = EncordUserClient.create_with_ssh_private_key(
ssh_private_key_path=SSH_PATH,
domain="https://api.encord.com",
)
# Create cloud synced folder params
cloud_synced_folder_params = CloudSyncedFolderParams(
integration_uuid=UUID(INTEGRATION_UUID),
remote_url=REMOTE_URL,
)
# Create the storage folder
folder_name = CLOUD_SYNCED_FOLDER_NAME
folder_description = CLOUD_SYNCED_FOLDER_DESCRIPTION
folder_metadata = {"my": "folder_metadata"}
storage_folder = user_client.create_storage_folder(
name=folder_name,
description=folder_description,
client_metadata=folder_metadata,
cloud_synced_folder_params=cloud_synced_folder_params,
)
Sync Cloud-synced Folder with Cloud Storage
The following code syncs a Cloud-sync Folder with the cloud storage bucket.
The sync_private_data_with_cloud_synced_folder_get_result
time out value can be adjusted to your needs.
Sync Cloud-synced Folder
from uuid import UUID
from encord import EncordUserClient
from encord.orm.storage import SyncPrivateDataWithCloudSyncedFolderStatus
from encord.storage import FoldersSortBy
# User input
SSH_PATH = "/Users/chris-encord/ssh-private-key.txt" # Specify the file path to your SSH key
CLOUD_SYNCED_FOLDER_NAME = "SDK Cloud-Synced Folder" # Specify the name of your Cloud-synced Folder
# Authenticate with Encord
user_client: EncordUserClient = EncordUserClient.create_with_ssh_private_key(
ssh_private_key_path=SSH_PATH,
domain="https://api.encord.com",
)
# Option 1: Use UUID directly
# storage_folder = user_client.get_storage_folder(CLOUD_SYNCED_FOLDER_ID)
# Option 2: Look up folder by name
folders = list(user_client.find_storage_folders(search=CLOUD_SYNCED_FOLDER_NAME))
if not folders:
print("Folder not found")
exit()
storage_folder = folders[0]
# Start sync job
sync_job_uuid = storage_folder.sync_private_data_with_cloud_synced_folder_start()
# Wait for result
result = storage_folder.sync_private_data_with_cloud_synced_folder_get_result(
sync_job_uuid, timeout_seconds=300 # You can adjust this
)
print(f"Sync job finished with status: {result.status}")
if result.status == SyncPrivateDataWithCloudSyncedFolderStatus.DONE:
print("Sync completed successfully.")
if result.unit_errors:
print("Some items failed to sync:")
for err in result.unit_errors:
print(err.object_urls)
elif result.status == SyncPrivateDataWithCloudSyncedFolderStatus.PENDING:
print("Sync is still in progress. Try polling later.")
else:
print(f"Sync failed or cancelled. Errors: {result.errors}")
Was this page helpful?