DataVersion¶
- class DataVersion[source]¶
Bases:
supervisely.api.module_api.ModuleApiBase
Class for managing project versions. This class provides methods for creating, restoring, and managing project versions.
Methods
Cancel version reservation for a project.
Commit project version.
_convert_info_to_json
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_ATTEMPTS
Maximum number of attempts that will be made to wait for a certain condition to be met.
WAIT_ATTEMPT_TIMEOUT_SEC
Number of seconds for intervals between attempts.
- InfoType¶
alias of
supervisely.api.module_api.VersionInfo
-
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_info_by_id(id)¶
Get information about an entity by its ID from the Supervisely server.
- Parameters
- id : int
ID of the entity.
-
get_list(project_id, filters=
None
)[source]¶ Get list of project versions.
- Parameters
- project_id : int
Project ID
- filters : Optional[List]
Filters
- 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
-
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_page
limit. Will be automatically adjusted if thepagesCount
differs from the requested number.- semaphore :
asyncio.Semaphore
, optional Semaphore for limiting the number of simultaneous requests.
- kwargs
Additional arguments.
- Returns
List of images in dataset.
- Return type
AsyncGenerator[List[ImageInfo]]
- Usage example
import supervisely as sly import asyncio os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com' os.environ['API_TOKEN'] = 'Your Supervisely API Token' 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))
- static info_sequence()[source]¶
NamedTuple VersionInfo with API Fields containing information about Project Version.
- initialize(project_info)[source]¶
Initialize project versions.
- Parameters
- project_info : Union[ProjectInfo, int]
ProjectInfo 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.