Skip to content

DockerRepository

v5.0.0 uses the object-oriented models

This page documents the legacy DockerRepository entity class. An object-oriented DockerRepository model is available in synapseclient.models.

synapseclient.entity.DockerRepository

Bases: Entity

A Docker repository is a lightweight virtual machine image.

WARNING - This class is deprecated and will no longer be maintained. Please use the DockerRepository model from synapseclient.models.docker.DockerRepository instead.

NOTE: store()-ing a DockerRepository created in the Python client will always result in it being treated as a reference to an external Docker repository that is not managed by synapse. To upload a docker image that is managed by Synapse please use the official Docker client and read https://help.synapse.org/docs/Synapse-Docker-Registry.2011037752.html for instructions on uploading a Docker Image to Synapse

ATTRIBUTE DESCRIPTION
repositoryName

The name of the Docker Repository. Usually in the format: [host[:port]/]path. If host is not set, it will default to that of DockerHub. port can only be specified if the host is also specified.

parent

The parent project or folder

properties

A map of Synapse properties

annotations

A map of user defined annotations

local_state

Internal use only

TYPE: dict

Migration to the object-oriented model

 

The legacy DockerRepository class is created and persisted through the Synapse client. The object-oriented DockerRepository model stores itself. The parent_id must be a Project ID.

# Old approach (DEPRECATED)
# from synapseclient import DockerRepository
# repo = syn.store(DockerRepository(repositoryName="org/img", parent="syn123"))

# New approach (RECOMMENDED)
from synapseclient import Synapse
from synapseclient.models import DockerRepository

syn = Synapse()
syn.login()

repo = DockerRepository(repository_name="org/img", parent_id="syn123").store()
print(repo.id)
Source code in synapseclient/entity.py
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
@deprecated(
    version="4.14.0",
    reason="To be removed in 5.0.0. "
    "Use the DockerRepository model from synapseclient.models.docker.DockerRepository instead.",
)
class DockerRepository(Entity):
    """
    A Docker repository is a lightweight virtual machine image.

    WARNING - This class is deprecated and will no longer be maintained. Please use the DockerRepository model from synapseclient.models.docker.DockerRepository instead.

    NOTE: [store()][synapseclient.Synapse.store]-ing a DockerRepository created in the Python client will always result
    in it being treated as a reference to an external Docker repository that is not
    managed by synapse. To upload a docker image that is managed by Synapse please use the official
    Docker client and read <https://help.synapse.org/docs/Synapse-Docker-Registry.2011037752.html>
    for instructions on uploading a Docker Image to Synapse

    Attributes:
        repositoryName: The name of the Docker Repository. Usually in the format: [host[:port]/]path.
                        If host is not set, it will default to that of DockerHub.
                        port can only be specified if the host is also specified.
        parent: The parent project or folder
        properties: A map of Synapse properties
        annotations: A map of user defined annotations
        local_state: Internal use only

    Example: Migration to the object-oriented model
        &nbsp;

        The legacy DockerRepository class is created and persisted through the
        Synapse client. The object-oriented DockerRepository model stores itself.
        The parent_id must be a Project ID.

        ```python
        # Old approach (DEPRECATED)
        # from synapseclient import DockerRepository
        # repo = syn.store(DockerRepository(repositoryName="org/img", parent="syn123"))

        # New approach (RECOMMENDED)
        from synapseclient import Synapse
        from synapseclient.models import DockerRepository

        syn = Synapse()
        syn.login()

        repo = DockerRepository(repository_name="org/img", parent_id="syn123").store()
        print(repo.id)
        ```
    """

    _synapse_entity_type = "org.sagebionetworks.repo.model.docker.DockerRepository"

    _property_keys = Entity._property_keys + ["repositoryName"]

    def __init__(
        self,
        repositoryName=None,
        parent=None,
        properties=None,
        annotations=None,
        local_state=None,
        **kwargs,
    ):
        if repositoryName:
            kwargs["repositoryName"] = repositoryName
        super(DockerRepository, self).__init__(
            properties=properties,
            annotations=annotations,
            local_state=local_state,
            parent=parent,
            **kwargs,
        )
        if "repositoryName" not in self:
            raise SynapseMalformedEntityError(
                "DockerRepository must have a repositoryName."
            )