DataVersion¶
- class DataVersion(api)[source]¶
Bases:
ModuleApiBaseClass for managing project versions. This class provides methods for creating, restoring, and managing project versions.
Class for managing project versions.
Methods
Cancel version reservation for a project.
Commit project version.
Convert information about an entity to a dictionary.
Create a new project version.
Get version ID by version number.
Get information about an entity by its ID from the Supervisely server.
Get list of project versions.
Get list of all or limited quantity entities from the Supervisely server.
This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
Get the list of items for a given page number.
Yields list of images in dataset asynchronously page by page.
Get project versions map from storage.
NamedTuple VersionInfo with API Fields containing information about Project Version.
NamedTuple name - VersionInfo.
Initialize project versions.
Reserve project version.
Restore project to a specific version.
Save project versions map to storage.
Attributes
MAX_WAIT_ATTEMPTSMaximum number of attempts that will be made to wait for a certain condition to be met.
PROJECT_DESC_TEMPLATEPROJECT_NAME_TEMPLATEWAIT_ATTEMPT_TIMEOUT_SECNumber of seconds for intervals between attempts.
project_cls- InfoType¶
alias of
VersionInfo
- static info_sequence()[source]¶
NamedTuple VersionInfo with API Fields containing information about Project Version.
- cancel_reservation(version_id, commit_token)[source]¶
Cancel version reservation for a project.
-
commit(version_id, commit_token, updated_at, file_id, title=
None, description=None)[source]¶ Commit project version. This method is used to finalize the version creation process. Requires active reservation. You must call this method after creating project version backup and setting version map
-
create(project_info, version_title=
None, version_description=None)[source]¶ Create a new project version. Returns the ID of the new version. If the project is already on the latest version, returns the latest version ID. If the project version cannot be created, returns None.
- get_id_by_number(project_id, version_num)[source]¶
Get version ID by version number.
-
get_list(project_id, filters=
None)[source]¶ Get list of project versions.
- Parameters:
- Returns:
List of project versions
- Return type:
List[
VersionInfo]
-
get_list_all_pages(method, data, progress_cb=
None, convert_json_info_cb=None, limit=None, return_first_response=False)¶ Get list of all or limited quantity entities from the Supervisely server.
- Parameters:
- method : str¶
Request method name
- data : dict¶
Dictionary with request body info
- progress_cb : Progress, optional¶
Function for tracking download progress.
- convert_json_info_cb : Callable, optional¶
Function for convert json info
- limit : int, optional¶
Number of entity to retrieve
- return_first_response : bool, optional¶
Specify if return first response
- Returns:
List of entities.
- Return type:
List[dict]
-
get_list_all_pages_generator(method, data, progress_cb=
None, convert_json_info_cb=None, limit=None, return_first_response=False)¶ This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
- Parameters:
- method : str¶
Request method name
- data : dict¶
Dictionary with request body info
- progress_cb : Progress, optional¶
Function for tracking download progress.
- convert_json_info_cb : Callable, optional¶
Function for convert json info
- limit : int, optional¶
Number of entity to retrieve
- return_first_response : bool, optional¶
Specify if return first response
- async get_list_idx_page_async(method, data)¶
Get the list of items for a given page number. Page number is specified in the data dictionary.
-
async get_list_page_generator_async(method, data, pages_count=
None, semaphore=None)¶ Yields list of images in dataset asynchronously page by page.
- Parameters:
- method : str¶
Method to call for listing items.
- data : dict¶
Data to pass to the API method.
- pages_count : int, optional¶
Preferred number of pages to retrieve if used with a
per_pagelimit. Will be automatically adjusted if thepagesCountdiffers from the requested number.- semaphore=
None¶ Semaphore for limiting the number of simultaneous requests.
- Returns:
List of images in dataset.
- Return type:
AsyncGenerator[List[
ImageInfo]]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() method = 'images.list' data = {'datasetId': 123456} loop = sly.utils.get_or_create_event_loop() images = loop.run_until_complete(api.image.get_list_generator_async(method, data))
-
get_map(project_info, do_initialization=
True)[source]¶ Get project versions map from storage.
- initialize(project_info)[source]¶
Initialize project versions.
- Parameters:
- project_info¶
Project info object or project ID
-
reserve(project_id, retries=
6)[source]¶ Reserve project version. This method is used before backing up a version to prevent another attempt to create a version at the same time. The first delay of retry is 2 seconds, which doubles with each subsequent attempt.
-
restore(project_info, version_id=
None, version_num=None, skip_missed_entities=False)[source]¶ Restore project to a specific version. Version can be specified by ID or number.
-
set_map(project_info, initialize=
True)[source]¶ Save project versions map to storage.