Skip to content

Images

Bases: SkahaClient

Skaha Image Management.

fetch

Python
fetch(kind: Optional[str] = None) -> List[str]

Get images from Skaha Server.

Parameters:

Name Type Description Default
kind Optional[str]

Type of image. Defaults to None.

None

Returns:

Type Description
List[str]

List[str]: A list of images on the skaha server.

Examples:

Python Console Session
>>> from skaha.images import Images
>>> images = Images()
>>> images.fetch(kind="headless")
['images.canfar.net/chimefrb/sample:latest',
 ...
 'images.canfar.net/skaha/terminal:1.1.1']
Source code in /home/runner/.cache/pypoetry/virtualenvs/handbook-G9X_rrhO-py3.10/lib/python3.10/site-packages/skaha/images.py
Python
def fetch(self, kind: Optional[str] = None) -> List[str]:
    """Get images from Skaha Server.

    Args:
        kind (Optional[str], optional): Type of image. Defaults to None.

    Returns:
        List[str]: A list of images on the skaha server.

    Examples:
        >>> from skaha.images import Images
        >>> images = Images()
        >>> images.fetch(kind="headless")
        ['images.canfar.net/chimefrb/sample:latest',
         ...
         'images.canfar.net/skaha/terminal:1.1.1']
    """
    data: Dict[str, str] = {}
    # If kind is not None, add it to the data dictionary
    if kind:
        data["type"] = kind
    response: Response = self.session.get(url=self.server, params=data)  # type: ignore # noqa
    response.raise_for_status()
    response = response.json()
    reply: List[str] = []
    for image in response:
        reply.append(image["id"])  # type: ignore
    return reply

set_server

Python
set_server(values: Dict[str, Any])

Sets the server path after validation.

Source code in /home/runner/.cache/pypoetry/virtualenvs/handbook-G9X_rrhO-py3.10/lib/python3.10/site-packages/skaha/images.py
Python
@root_validator
def set_server(cls, values: Dict[str, Any]):
    """Sets the server path after validation."""
    values["server"] = f"{values['server']}/{values['version']}/image"
    values["server"] = values["server"] + "/image"
    return values