aip_sdk.sdg
SDG (Synthetic Data Generation) Adapter Registry SDK.
aip_sdk.sdg.SdgAdapter
aip_sdk.sdg.SdgAdapter
SDG Adapter Registry top-level access.
Examples
>>> import aip_sdk as aip
>>> from mypackage import MyPipeline # subclass of SDGPipeline
>>> aip.init(base_url, api_key=api_key)
>>> adapter = aip.SdgAdapter.register(
... name="adversarial-gen",
... pipeline=MyPipeline,
... version="1.0",
... )
>>> print(adapter.id, adapter.name)
>>> adapters = aip.SdgAdapter.list()
>>> for a in adapters:
... print(a.name, a.version)
aip_sdk.sdg.SdgAdapter.aget
async aip_sdk.sdg.SdgAdapter.aget(adapter_id: str, client: AsyncAPIClient | None = None) -> SdgAdapterInstance
Async variant of get().
Parameters
adapter_idstr: Adapter registration ID.clientAsyncAPIClient | None: Optional async API client.
Returns
SdgAdapterInstance: SdgAdapterInstance.
Raises
AdapterNotFoundError: If the adapter doesn't exist.
aip_sdk.sdg.SdgAdapter.alist
async aip_sdk.sdg.SdgAdapter.alist(page: int = 1, per_page: int = 100, *, workspace_id: str | None = None, client: AsyncAPIClient | None = None, all_workspaces: bool = False) -> list[SdgAdapterInstance]
Async variant of list().
Reads your session's workspace unless you name one, and raises if none is set.
Pass all_workspaces=True to read across every workspace you can access.
Parameters
pageint: Page number (1-indexed).per_pageint: Results per page.workspace_idstr | None: Filter to adapters registered in this workspace.clientAsyncAPIClient | None: Optional async API client.all_workspacesbool: Read across every workspace you can access.
Returns
list[SdgAdapterInstance]: List of SdgAdapterInstance objects.
Raises
ForbiddenError: Ifworkspace_idnames a workspace you cannot access.InvalidArgumentError: If bothworkspace_idandall_workspacesare given.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas not set.
aip_sdk.sdg.SdgAdapter.aregister
async aip_sdk.sdg.SdgAdapter.aregister(name: str, pipeline: Any | None = None, job_config: Any | None = None, version: str = '1.0', owner: str | None = None, *, workspace_id: str | None = None, client: AsyncAPIClient | None = None) -> SdgAdapterInstance
Async variant of register().
Exactly one of pipeline and job_config must be provided.
Parameters
namestr: Adapter name.pipelineAny | None: Pipeline class — legacy dotted-path registration. Must implement the SDGPipeline interface (run,validate_chain). Usesissubclasswhenaip_sdg_coreis installed, otherwise falls back to duck-typing. Adapters registered this way are not runnable viarun_sdg()— they only round-trip metadata.job_configAny | None:aip_sdg_core.JobConfiginstance — the runnable path. Adapters registered this way can be run viarun_sdg().versionstr: Version identifier (default:"1.0").ownerstr | None: Owner/team identifier.workspace_idstr | None: Workspace to register the adapter in. Falls back toclient.config.workspace_id(set viainit()orAIP_WORKSPACE_ID) when not provided. With neither, the registration is refused rather than landing somewhere you did not choose.clientAsyncAPIClient | None: Optional async API client.
Returns
SdgAdapterInstance: SdgAdapterInstance.
Raises
NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.InvalidArgumentError: If neither or both ofpipeline/job_configprovided.InterfaceValidationError: Ifpipelinedoes not subclassSDGPipelineor is missing required interface members.DuplicateAdapterError: If an adapter with this name already exists in the target workspace.AuthError: If no credentials are configured.
aip_sdk.sdg.SdgAdapter.get
aip_sdk.sdg.SdgAdapter.get(adapter_id: str, client: APIClient | None = None) -> SdgAdapterInstance
Fetch a registered SDG adapter by ID.
Parameters
adapter_idstr: Adapter registration ID.clientAPIClient | None: Optional pre-configured API client.
Returns
SdgAdapterInstance: SdgAdapterInstance.
Raises
AdapterNotFoundError: If the adapter doesn't exist.
aip_sdk.sdg.SdgAdapter.list
aip_sdk.sdg.SdgAdapter.list(page: int = 1, per_page: int = 100, *, workspace_id: str | None = None, client: APIClient | None = None, all_workspaces: bool = False) -> list[SdgAdapterInstance]
List registered SDG adapters.
Reads your session's workspace unless you name one, and raises if none is set.
Pass all_workspaces=True to read across every workspace you can access.
Parameters
pageint: Page number (1-indexed).per_pageint: Results per page.workspace_idstr | None: Filter to adapters registered in this workspace.clientAPIClient | None: Optional pre-configured API client.all_workspacesbool: Read across every workspace you can access.
Returns
list[SdgAdapterInstance]: List of SdgAdapterInstance objects.
Raises
ForbiddenError: Ifworkspace_idnames a workspace you cannot access.InvalidArgumentError: If bothworkspace_idandall_workspacesare given.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas not set.
aip_sdk.sdg.SdgAdapter.register
aip_sdk.sdg.SdgAdapter.register(name: str, pipeline: Any | None = None, job_config: Any | None = None, version: str = '1.0', owner: str | None = None, *, workspace_id: str | None = None, client: APIClient | None = None) -> SdgAdapterInstance
Register a custom SDG adapter.
Exactly one of pipeline and job_config must be provided.
Parameters
namestr: Adapter name.pipelineAny | None: Pipeline class — legacy dotted-path registration. Must implement the SDGPipeline interface (run,validate_chain). Usesissubclasswhenaip_sdg_coreis installed, otherwise falls back to duck-typing. Adapters registered this way are not runnable viarun_sdg()— they only round-trip metadata.job_configAny | None:aip_sdg_core.JobConfiginstance — the runnable path. Adapters registered this way can be run viarun_sdg().versionstr: Version identifier (default:"1.0").ownerstr | None: Owner/team identifier.workspace_idstr | None: Workspace to register the adapter in. Falls back toclient.config.workspace_id(set viainit()orAIP_WORKSPACE_ID) when not provided. With neither, the registration is refused rather than landing somewhere you did not choose.clientAPIClient | None: Optional pre-configured API client.
Returns
SdgAdapterInstance: SdgAdapterInstance.
Raises
NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.InvalidArgumentError: If neither or both ofpipeline/job_configprovided.InterfaceValidationError: Ifpipelinedoes not subclassSDGPipelineor is missing required interface members.DuplicateAdapterError: If an adapter with this name already exists in the target workspace.AuthError: If no credentials are configured.
aip_sdk.sdg.SdgAdapterInstance
aip_sdk.sdg.SdgAdapterInstance(id: str, name: str, version: str, owner: str | None, workspace_id: str, created_at: datetime | None, updated_at: datetime | None)
A registered SDG adapter.
Attributes
idstr: Adapter registration IDnamestr: Adapter nameversionstr: Version stringownerstr | None: Owner/team identifierworkspace_idstr: Workspace the adapter is registered increated_atdatetime | None: When this adapter was registeredupdated_atdatetime | None: Last update timestamp
aip_sdk.sdg.SdgAdapterInstance.created_at
aip_sdk.sdg.SdgAdapterInstance.created_at: datetime | None
No docstring is defined in the source.
aip_sdk.sdg.SdgAdapterInstance.id
aip_sdk.sdg.SdgAdapterInstance.id: str
No docstring is defined in the source.
aip_sdk.sdg.SdgAdapterInstance.name
aip_sdk.sdg.SdgAdapterInstance.name: str
No docstring is defined in the source.
aip_sdk.sdg.SdgAdapterInstance.owner
aip_sdk.sdg.SdgAdapterInstance.owner: str | None
No docstring is defined in the source.
aip_sdk.sdg.SdgAdapterInstance.updated_at
aip_sdk.sdg.SdgAdapterInstance.updated_at: datetime | None
No docstring is defined in the source.
aip_sdk.sdg.SdgAdapterInstance.version
aip_sdk.sdg.SdgAdapterInstance.version: str
No docstring is defined in the source.
aip_sdk.sdg.SdgAdapterInstance.workspace_id
aip_sdk.sdg.SdgAdapterInstance.workspace_id: str
No docstring is defined in the source.
aip_sdk.sdg.SdgRun
aip_sdk.sdg.SdgRun(id: str, adapter_id: str, pipeline: str, status: str, created_at: datetime | None)
A triggered SDG run.
Returned by run_sdg(). Carries enough state to poll status via
refresh() against GET /runs/{id}.
aip_sdk.sdg.SdgRun.adapter_id
aip_sdk.sdg.SdgRun.adapter_id: str
No docstring is defined in the source.
aip_sdk.sdg.SdgRun.created_at
aip_sdk.sdg.SdgRun.created_at: datetime | None
No docstring is defined in the source.
aip_sdk.sdg.SdgRun.id
aip_sdk.sdg.SdgRun.id: str
No docstring is defined in the source.
aip_sdk.sdg.SdgRun.pipeline
aip_sdk.sdg.SdgRun.pipeline: str
No docstring is defined in the source.
aip_sdk.sdg.SdgRun.refresh
aip_sdk.sdg.SdgRun.refresh(client: APIClient | None = None) -> SdgRun
Re-fetch this run's status from the API and return an updated instance.
aip_sdk.sdg.SdgRun.status
aip_sdk.sdg.SdgRun.status: str
No docstring is defined in the source.
aip_sdk.sdg.alist_sdg_adapters
async aip_sdk.sdg.alist_sdg_adapters(page: int = 1, per_page: int = 100, *, workspace_id: str | None = None, client: AsyncAPIClient | None = None, all_workspaces: bool = False) -> list[SdgAdapterInstance]
Async variant of list_sdg_adapters().
Reads your session's workspace unless you name one, and raises if none is set.
Pass all_workspaces=True to read across every workspace you can access.
Parameters
pageint: Page number (1-indexed).per_pageint: Results per page.workspace_idstr | None: Filter to adapters registered in this workspace.clientAsyncAPIClient | None: Optional pre-configured async API client.all_workspacesbool: Read across every workspace you can access.
Returns
list[SdgAdapterInstance]: List of SdgAdapterInstance objects.
Raises
ForbiddenError: Ifworkspace_idnames a workspace you cannot access.InvalidArgumentError: If bothworkspace_idandall_workspacesare given.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas not set.
aip_sdk.sdg.aregister_sdg_adapter
async aip_sdk.sdg.aregister_sdg_adapter(name: str, pipeline: Any | None = None, job_config: Any | None = None, version: str = '1.0', owner: str | None = None, *, workspace_id: str | None = None, client: AsyncAPIClient | None = None) -> SdgAdapterInstance
Async variant of register_sdg_adapter().
Parameters
namestr: Adapter name.pipelineAny | None: Pipeline class — must implement the SDGPipeline interface (runandvalidate_chainmethods). UsesissubclassagainstSDGPipelinewhenaip_sdg_coreis installed, otherwise falls back to duck-typing.job_configAny | None:aip_sdg_core.JobConfiginstance.versionstr: Version string.ownerstr | None: Owner/team identifier.workspace_idstr | None: Workspace to register the adapter in. Falls back toclient.config.workspace_idwhen not provided — seeregister_sdg_adapter()for why to pass this explicitly on multi-workspace accounts.clientAsyncAPIClient | None: Optional pre-configured async API client.
Returns
SdgAdapterInstance: SdgAdapterInstance.
Raises
NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.InterfaceValidationError: Ifpipelinedoes not satisfy the SDGPipeline interface.DuplicateAdapterError: If an adapter with this name already exists in the target workspace.AuthError: If no credentials are configured.
Example:
adapter = await aip.aregister_sdg_adapter(
name="adversarial-gen",
pipeline=MyPipeline,
)
aip_sdk.sdg.arun_sdg
async aip_sdk.sdg.arun_sdg(adapter_id: str, project_id: str | None = None, client: AsyncAPIClient | None = None) -> SdgRun
Async variant of run_sdg().
aip_sdk.sdg.list_sdg_adapters
aip_sdk.sdg.list_sdg_adapters(page: int = 1, per_page: int = 100, *, workspace_id: str | None = None, client: APIClient | None = None, all_workspaces: bool = False) -> list[SdgAdapterInstance]
List registered SDG adapters.
Reads your session's workspace unless you name one, and raises if none is set.
Pass all_workspaces=True to read across every workspace you can access.
Parameters
pageint: Page number (1-indexed).per_pageint: Results per page.workspace_idstr | None: Filter to adapters registered in this workspace.clientAPIClient | None: Optional pre-configured API client.all_workspacesbool: Read across every workspace you can access.
Returns
list[SdgAdapterInstance]: List of SdgAdapterInstance objects.
Raises
ForbiddenError: Ifworkspace_idnames a workspace you cannot access.InvalidArgumentError: If bothworkspace_idandall_workspacesare given.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas not set.
Example:
adapters = aip.list_sdg_adapters()
for a in adapters:
print(a.name, a.version)
aip_sdk.sdg.register_sdg_adapter
aip_sdk.sdg.register_sdg_adapter(name: str, pipeline: Any | None = None, job_config: Any | None = None, version: str = '1.0', owner: str | None = None, *, workspace_id: str | None = None, client: APIClient | None = None) -> SdgAdapterInstance
Register a custom SDG adapter in a single call.
Validates the pipeline class locally against the SDGPipeline interface before calling the registration API.
Parameters
namestr: Adapter name.pipelineAny | None: Pipeline class — must implement the SDGPipeline interface (runandvalidate_chainmethods). UsesissubclassagainstSDGPipelinewhenaip_sdg_coreis installed, otherwise falls back to duck-typing.job_configAny | None:aip_sdg_core.JobConfiginstance.versionstr: Version string (default:"1.0").ownerstr | None: Owner/team identifier.workspace_idstr | None: Workspace to register the adapter in. Falls back toclient.config.workspace_id(set viainit()orAIP_WORKSPACE_ID) when not provided. With neither, the registration is refused rather than landing somewhere you did not choose.clientAPIClient | None: Optional pre-configured API client.
Returns
SdgAdapterInstance: SdgAdapterInstance.
Raises
NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.InterfaceValidationError: Ifpipelinedoes not satisfy the SDGPipeline interface.DuplicateAdapterError: If an adapter with this name already exists in the target workspace.AuthError: If no credentials are configured.
Example:
import aip_sdk as aip
from mypackage import MyPipeline # subclass of SDGPipeline
aip.init("https://aip.example.com", api_key="...")
project = aip.Project.get("my-project-id")
adapter = aip.register_sdg_adapter(
name="adversarial-gen",
pipeline=MyPipeline,
version="1.0",
workspace_id=project.workspace_id,
)
print(adapter.id, adapter.name)
aip_sdk.sdg.run_sdg
aip_sdk.sdg.run_sdg(adapter_id: str, project_id: str | None = None, *, target_dataset_id: str | None = None, source_dataset_version_id: str | None = None, client: APIClient | None = None) -> SdgRun
Trigger an SDG run against a previously registered adapter.
The adapter must have been registered with pipeline_config; adapters
registered with the legacy pipeline_class dotted-path slot are not
runnable and are rejected with 400.
The call returns immediately (HTTP 202 Accepted) once the run has been
enqueued; processing happens asynchronously. Use SdgRun.refresh()
to poll status, or aip.get_run() to attach a full Run handle.
Parameters
adapter_idstr: ID of the registered SDG adapter to run.project_idstr | None: Optional project to attach the resulting run to. Must belong to the adapter's workspace. Strongly recommended: without it non-admin callers cannot fetch the run back viaGET /runs/{id}and the run is invisible to project-scoped run lists.target_dataset_idstr | None: Optional dataset to write the generated samples into.source_dataset_version_idstr | None: Optional dataset version to read seed samples from.clientAPIClient | None: Optional pre-configured API client.
Returns
SdgRun: SdgRun withid,status,created_at.
Raises
AdapterNotFoundError: If the adapter doesn't exist.APIError: If the adapter was registered withoutpipeline_config, or ifproject_idis unknown / not in the adapter's workspace.AuthError: If no credentials are configured.
Example:
# Authoring a JobConfig requires the SDG extra: pip install 'aip-sdk[sdg]'
import aip_sdk as aip
from aip_sdg_core import JobConfig
from aip_sdg_core.schemas.object_detection.augmentation.brightness_contrast import (
BrightnessContrastConfig,
)
aip.init("https://aip.example.com", api_key="...")
job_config = JobConfig(storage_root="/tmp/sdg")
job_config.add_node("seed", ...)
job_config.add_node("augmented", BrightnessContrastConfig(...), upstream="seed")
adapter = aip.register_sdg_adapter(name="brightness-tune", job_config=job_config)
run = aip.run_sdg(adapter_id=adapter.id, project_id="proj_…")
print(run.id, run.status)