ApiContext¶
-
class ApiContext(api, project_id=
None, dataset_id=None, project_meta=None, with_alpha_masks=True)[source]¶ Bases:
objectContext manager for the API object for optimization purposes.
Use this context manager when you need to perform a series of operations on the same project or dataset. It allows you to avoid redundant API calls to get the same project or dataset info multiple times.
- Parameters:
- Raises:
RuntimeError – if api is None.
- 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() with ApiContext( api, project_id=33333, dataset_id=99999, project_meta=project_meta, with_alpha_masks=True, ): api.annotation.upload_paths(image_ids, ann_paths, anns_progress) # another code here
Methods