o
    xi                     @  s   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZ erDddlmZ G dd deZdddZdS )]Abstract plugin class defining the interface needed to build container images for W&B Launch.    )annotations)ABCabstractmethod)TYPE_CHECKINGAny)AbstractEnvironment)AbstractRegistry   )
EntryPointLaunchProject)AnonynmousRegistry)"AZURE_CONTAINER_REGISTRY_URI_REGEX$ELASTIC_CONTAINER_REGISTRY_URI_REGEXGCP_ARTIFACT_REGISTRY_URI_REGEX)JobAndRunStatusTrackerc                   @  sv   e Zd ZU dZded< ded< ded< ded	< e	
d d!ddZeed"ddZe	d#d$ddZ	ed%ddZ
dS )&AbstractBuilderr   strbuilder_typer   environmentr	   registryzdict[str, Any]builder_configTverifyboolreturnNonec                 C     t )a1  Initialize a builder.

        Arguments:
            builder_config: The builder config.
            registry: The registry to use.
            verify: Whether to verify the functionality of the builder.

        Raises:
            LaunchError: If the builder cannot be initialized or verified.
        NotImplementedError)selfr   r   r    r    U/home/ubuntu/.local/lib/python3.10/site-packages/wandb/sdk/launch/builder/abstract.py__init__   s   zAbstractBuilder.__init__configdictc                 C  r   )a  Create a builder from a config dictionary.

        Arguments:
            config: The config dictionary.
            environment: The environment to use.
            registry: The registry to use.
            verify: Whether to verify the functionality of the builder.
            login: Whether to login to the registry immediately.

        Returns:
            The builder.
        r   )clsr#   r   r   r    r    r!   from_config2   s   zAbstractBuilder.from_configNlaunch_projectr   
entrypointr   job_trackerJobAndRunStatusTracker | Nonec                      t )zBuild the image for the given project.

        Arguments:
            launch_project: The project to build.
            build_ctx_path: The path to the build context.

        Returns:
            The image name.
        r   )r   r'   r(   r)   r    r    r!   build_imageH   s   zAbstractBuilder.build_imagec                   r+   )zVerify that the builder can be used to build images.

        Raises:
            LaunchError: If the builder cannot be used to build images.
        r   )r   r    r    r!   r   Z   s   zAbstractBuilder.verify)T)r   r   r   r	   r   r   r   r   )r#   r$   r   r   r   r	   r   r   )N)r'   r   r(   r   r)   r*   r   r   )r   r   )__name__
__module____qualname____doc____annotations__r   r"   classmethodr&   r,   r   r    r    r    r!   r      s"   
 r   urir   r   r	   c                 C  s   |  dr| tdd } t| durddlm} || dS t| dur1ddlm} || dS t	| durCddl
m} || dS t| dS )aJ  Create a registry helper object from a uri.

    This function parses the URI and determines which supported registry it
    belongs to. It then creates a registry helper object for that registry.
    The supported remote registry types are:
    - Azure Container Registry
    - Google Container Registry
    - AWS Elastic Container Registry

    The format of the URI is as follows:
    - Azure Container Registry: <registry-name>.azurecr.io/<repo-name>/<image-name>
    - Google Container Registry: <location>-docker.pkg.dev/<project-id>/<repo-name>/<image-name>
    - AWS Elastic Container Registry: <account-id>.dkr.ecr.<region>.amazonaws.com/<repo-name>/<image-name>

    Our classification of the registry is based on the domain name. For example,
    if the uri contains `.azurecr.io`, we classify it as an Azure
    Container Registry. If the uri contains `.dkr.ecr`, we classify
    it as an AWS Elastic Container Registry. If the uri contains
    `-docker.pkg.dev`, we classify it as a Google Artifact Registry.

    This function will attempt to load the appropriate cloud helpers for the

    `https://` prefix is optional for all of the above.

    Arguments:
        uri: The uri to create a registry from.

    Returns:
        The registry.

    Raises:
        LaunchError: If the registry helper cannot be loaded for the given URI.
    zhttps://Nr   )AzureContainerRegistry)r3   )GoogleArtifactRegistry)ElasticContainerRegistry)
startswithlenr   match2wandb.sdk.launch.registry.azure_container_registryr4   r   2wandb.sdk.launch.registry.google_artifact_registryr5   r   4wandb.sdk.launch.registry.elastic_container_registryr6   r   )r3   r4   r5   r6   r    r    r!   registry_from_urid   s   
"



r=   N)r3   r   r   r	   )r0   
__future__r   abcr   r   typingr   r   %wandb.sdk.launch.environment.abstractr   "wandb.sdk.launch.registry.abstractr	   _project_specr   r   registry.anonr   utilsr   r   r   )wandb.sdk.launch.agent.job_status_trackerr   r   r=   r    r    r    r!   <module>   s    M