o
    -wi                     @   s   d Z ddlmZmZ ddlmZmZ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rBdd
lmZ G dd deZdedefddZdS )]Abstract plugin class defining the interface needed to build container images for W&B Launch.    )ABCabstractmethod)TYPE_CHECKINGAnyDictOptional)AbstractEnvironment)AbstractRegistry   )
EntryPointLaunchProject)AnonynmousRegistry)"AZURE_CONTAINER_REGISTRY_URI_REGEX$ELASTIC_CONTAINER_REGISTRY_URI_REGEXGCP_ARTIFACT_REGISTRY_URI_REGEX)JobAndRunStatusTrackerc                
   @   s   e Zd ZU dZeed< eed< eed< eee	f ed< e
	ddedededd	fd
dZee
dedededd fddZe
		ddededed defddZe
dddZd	S )AbstractBuilderr   builder_typeenvironmentregistrybuilder_configTverifyreturnNc                 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   ^/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/sdk/launch/builder/abstract.py__init__   s   zAbstractBuilder.__init__configc                 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_config0   s   zAbstractBuilder.from_configlaunch_project
entrypointjob_trackerr   c                       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_imageF   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   X   s   zAbstractBuilder.verify)T)N)r   N)__name__
__module____qualname____doc__str__annotations__r	   r
   r   r   r   boolr    classmethoddictr#   r   r   r   r(   r   r   r   r   r   r      sR   
 r   urir   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)r2   )GoogleArtifactRegistry)ElasticContainerRegistry)
startswithlenr   match2wandb.sdk.launch.registry.azure_container_registryr3   r   2wandb.sdk.launch.registry.google_artifact_registryr4   r   4wandb.sdk.launch.registry.elastic_container_registryr5   r   )r2   r3   r4   r5   r   r   r   registry_from_urib   s   
"



r<   N)r,   abcr   r   typingr   r   r   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   r   <module>   s    M