Before you start
To access any datasets, make sure the app has the right accesses. Read more about managing Identity.
How do I...?
Create a dataset
To add a dataset to an already existing asset, call create_dataset
with the required information.
This method returns the dataset id as a string.
dataset_id = unity_cloud.assets.create_dataset( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_name = "your-new-dataset-name" )
Update a dataset
To update a dataset name, description, tags, or file order, follow these steps:
- Create a
DatasetUpdate
object. - Call the
update_dataset
method.
dataset_update = DatasetUpdate( name = "your-dataset-name", description = "your-dataset-description", tags = ["your-tag-1", "your-tag-2", "your-tag-3"], file_order = ["your_file_1.ext", "your_file_2.ext", "your_file_3.ext"] ) unity_cloud.assets.update_dataset( dataset_update = dataset_update, org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef" )
Get a dataset
To fetch a specific dataset, call the get_dataset
method.
dataset = unity_cloud.assets.get_dataset( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef" )
Get a list of all datasets within an asset
To fetch all datasets contained in a given asset, call the get_dataset_list
method.
datasets = unity_cloud.assets.get_dataset_list( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef" )
Upload a local file to a dataset
To add a file to any dataset contained in your asset, follow these steps:
- Create an
AssetFileUploadInformation
object. - Call the
upload_file
method. - (Optional) Pass the
upload_file
method to track the progress via callback.
from pathlib import PurePath, PurePosixPath def show_upload_progress(progress): print(progress) upload_asset = FileUploadInformation( organization_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef", upload_file_path = PurePath("computer/path/to/file.ext"), cloud_file_path = PurePosixPath("path/to/file.ext") ) unity_cloud.assets.upload_file( asset_upload_information = upload_asset, progress_callback = show_progress )
Update a file's metadata
To update the description and the tags of a file, follow these steps:
- Create an
AssetFileUpdate
object. - Call the
update_file
method.
The file_path
argument in the update_file
method must correspond with the cloud file path used when uploading the file.
from pathlib import PurePosixPath asset_file_update = FileUpdate( description = "your-file-description", tags = ["your-tag-1", "your-tag-2", "your-tag-3"] ) unity_cloud.assets.update_file( asset_file_update = asset_file_update, org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef", cloud_file_path = PurePosixPath("path/to/file.ext") )
Download a file contained in a dataset
To download a file, follow these steps:
- Create an
AssetFileDownloadInformation
object withFilePath
.FilePath
indicates the file the path in Asset Manager andDownloadFolderPath
indicates the destination for the downloaded on your computer. - Call the
download_file
method. - (Optional) Pass the
download_file
method to track the progress via callback.
def show_download_progress(progress): print(progress) asset_file_download_infos = FileDownloadInformation( organization_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef", cloud_file_path = PurePosixPath("path/to/file.ext"), download_folder_path = PurePath("path/to/folder") ) unity_cloud.assets.download_file( asset_download_information = asset_file_download_infos, progress_callback = show_download_progress )
Get a file
To fetch a specific file, call get_file
.
files = unity_cloud.assets.get_file_list( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef", cloud_file_path = PurePosixPath("path/to/file.ext") )
Get a list of all files within a dataset
To fetch all files contained in a given dataset, call get_file_list
.
files = unity_cloud.assets.get_file_list( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef" )
Remove a file from a dataset
To remove a file from a dataset, call unity_cloud.assets.remove_file
.
from pathlib import PurePosixPath unity_cloud.assets.remove_file( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef", file_path = PurePosixPath("path/to/file.ext") )
Get a list of suggested generated tags for a picture file
To get a list of suggested tags for a picture file, call get_suggested_tags
. They are generated based on the content of the image.
suggested_tags = unity_cloud.assets.generate_suggested_file_tags( org_id = "012345678912", project_id = "1234abcd-ab12-cd34-ef56-123456abcdef", asset_id = "0123456789abcdefghijklmn", asset_version = "1234abcd-ab12-cd34-ef56-123456abcdef", dataset_id = "1234abcd-12ab-34cd-56ef-123456abcdef", file_path = PurePosixPath("path/to/file.ext") )