Skip to main content

synth_ai.sdk.harbor.uploader

HarborDeploymentUploader - Upload deployments to Harbor API. This module handles the API interactions for creating and managing Harbor deployments. It provides both sync and async interfaces. Example:
>>> from synth_ai.sdk.harbor import HarborBuildSpec, upload_harbor_deployment
>>>
>>> spec = HarborBuildSpec(
...     name="my-deployment",
...     dockerfile_path="./Dockerfile",
...     context_dir=".",
...     entrypoint="python run.py",
... )
>>>
>>> result = upload_harbor_deployment(spec)
>>> print(f"Created deployment: {result.deployment_id}")

Functions

upload_harbor_deployment

upload_harbor_deployment(spec: HarborBuildSpec, api_key: str | None = None, backend_url: str | None = None, auto_build: bool = True, wait_for_ready: bool = False, build_timeout_s: float = 600.0) -> HarborDeploymentResult
Upload a Harbor deployment from a build spec. This is the primary user-facing function for uploading deployments. It packages the build context, creates the deployment, and optionally waits for the build to complete. Args:
  • spec: HarborBuildSpec defining the deployment
  • api_key: Synth API key (default: from SYNTH_API_KEY env)
  • backend_url: Synth backend URL (default: from SYNTH_BACKEND_URL env)
  • auto_build: Whether to trigger build immediately (default: True)
  • wait_for_ready: Whether to wait for build completion (default: False)
  • build_timeout_s: Maximum time to wait for build (default: 600s)
Returns:
  • HarborDeploymentResult with deployment details
Raises:
  • HarborAPIError: If API request fails
  • FileNotFoundError: If Dockerfile or context_dir doesn’t exist
  • ValueError: If package exceeds size limit
  • TimeoutError: If wait_for_ready=True and build times out

upload_harbor_deployment_async

upload_harbor_deployment_async(spec: HarborBuildSpec, api_key: str | None = None, backend_url: str | None = None, auto_build: bool = True, wait_for_ready: bool = False, build_timeout_s: float = 600.0) -> HarborDeploymentResult
Upload a Harbor deployment asynchronously. Async version of upload_harbor_deployment(). See that function for full documentation.

Classes

HarborAPIError

Error from Harbor API.

HarborDeploymentUploader

Upload and manage Harbor deployments via API. Handles authentication, request formatting, and error handling for Harbor deployment operations. Attributes:
  • backend_url: Synth backend URL
  • api_key: Synth API key for authentication
  • timeout: Request timeout in seconds
Methods:

create_deployment_async

create_deployment_async(self, spec: HarborBuildSpec, auto_build: bool = True) -> HarborDeploymentResult
Create a new Harbor deployment asynchronously. Args:
  • spec: HarborBuildSpec defining the deployment
  • auto_build: Whether to trigger build immediately (default: True)
Returns:
  • HarborDeploymentResult with deployment details
Raises:
  • HarborAPIError: If API request fails
  • FileNotFoundError: If Dockerfile or context_dir doesn’t exist
  • ValueError: If package exceeds size limit

create_deployment

create_deployment(self, spec: HarborBuildSpec, auto_build: bool = True) -> HarborDeploymentResult
Create a new Harbor deployment synchronously. Args:
  • spec: HarborBuildSpec defining the deployment
  • auto_build: Whether to trigger build immediately (default: True)
Returns:
  • HarborDeploymentResult with deployment details
Raises:
  • HarborAPIError: If API request fails

get_deployment_status_async

get_deployment_status_async(self, deployment_id: str) -> dict[str, Any]
Get deployment status asynchronously. Args:
  • deployment_id: UUID of the deployment
Returns:
  • Status dictionary with deployment details and build history

get_deployment_status

get_deployment_status(self, deployment_id: str) -> dict[str, Any]
Get deployment status synchronously.

wait_for_build_async

wait_for_build_async(self, deployment_id: str, timeout_s: float = 600.0, poll_interval_s: float = 5.0) -> dict[str, Any]
Wait for deployment build to complete. Args:
  • deployment_id: UUID of the deployment
  • timeout_s: Maximum time to wait in seconds
  • poll_interval_s: Interval between status checks
Returns:
  • Final status dictionary
Raises:
  • TimeoutError: If build doesn’t complete within timeout
  • HarborAPIError: If build fails

wait_for_build

wait_for_build(self, deployment_id: str, timeout_s: float = 600.0, poll_interval_s: float = 5.0) -> dict[str, Any]
Wait for deployment build to complete synchronously.

trigger_build_async

trigger_build_async(self, deployment_id: str) -> dict[str, Any]
Trigger a new build for an existing deployment. Args:
  • deployment_id: UUID of the deployment
Returns:
  • Build information with build_id

trigger_build

trigger_build(self, deployment_id: str) -> dict[str, Any]
Trigger a new build synchronously.

list_deployments_async

list_deployments_async(self, status: str | None = None, limit: int = 50, offset: int = 0) -> list[dict[str, Any]]
List deployments with optional filtering. Args:
  • status: Filter by status (pending, building, ready, failed)
  • limit: Maximum number of results
  • offset: Pagination offset
Returns:
  • List of deployment dictionaries

list_deployments

list_deployments(self, status: str | None = None, limit: int = 50, offset: int = 0) -> list[dict[str, Any]]
List deployments synchronously.