github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/python/aistore/sdk/client.py (about)

     1  #
     2  # Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
     3  #
     4  
     5  from __future__ import annotations  # pylint: disable=unused-variable
     6  
     7  from aistore.sdk.bucket import Bucket
     8  from aistore.sdk.const import (
     9      PROVIDER_AIS,
    10  )
    11  from aistore.sdk.cluster import Cluster
    12  from aistore.sdk.dsort import Dsort
    13  from aistore.sdk.request_client import RequestClient
    14  from aistore.sdk.types import Namespace
    15  from aistore.sdk.job import Job
    16  from aistore.sdk.etl import Etl
    17  
    18  
    19  # pylint: disable=unused-variable, duplicate-code
    20  class Client:
    21      """
    22      AIStore client for managing buckets, objects, ETL jobs
    23  
    24      Args:
    25          endpoint (str): AIStore endpoint
    26      """
    27  
    28      def __init__(
    29          self,
    30          endpoint: str,
    31          skip_verify: bool = False,
    32          ca_cert: str = None,
    33          timeout: float | tuple[float, float] | None = None,
    34      ):
    35          self._request_client = RequestClient(endpoint, skip_verify, ca_cert, timeout)
    36  
    37      def bucket(
    38          self, bck_name: str, provider: str = PROVIDER_AIS, namespace: Namespace = None
    39      ):
    40          """
    41          Factory constructor for bucket object.
    42          Does not make any HTTP request, only instantiates a bucket object.
    43  
    44          Args:
    45              bck_name (str): Name of bucket
    46              provider (str): Provider of bucket, one of "ais", "aws", "gcp", ... (optional, defaults to ais)
    47              namespace (Namespace): Namespace of bucket (optional, defaults to None)
    48  
    49          Returns:
    50              The bucket object created.
    51          """
    52          return Bucket(
    53              client=self._request_client,
    54              name=bck_name,
    55              provider=provider,
    56              namespace=namespace,
    57          )
    58  
    59      def cluster(self):
    60          """
    61          Factory constructor for cluster object.
    62          Does not make any HTTP request, only instantiates a cluster object.
    63  
    64          Returns:
    65              The cluster object created.
    66          """
    67          return Cluster(client=self._request_client)
    68  
    69      def job(self, job_id: str = "", job_kind: str = ""):
    70          """
    71          Factory constructor for job object, which contains job-related functions.
    72          Does not make any HTTP request, only instantiates a job object.
    73  
    74          Args:
    75              job_id (str, optional): Optional ID for interacting with a specific job
    76              job_kind (str, optional): Optional specific type of job empty for all kinds
    77  
    78          Returns:
    79              The job object created.
    80          """
    81          return Job(client=self._request_client, job_id=job_id, job_kind=job_kind)
    82  
    83      def etl(self, etl_name: str):
    84          """
    85          Factory constructor for ETL object.
    86          Contains APIs related to AIStore ETL operations.
    87          Does not make any HTTP request, only instantiates an ETL object.
    88  
    89          Args:
    90              etl_name (str): Name of the ETL
    91  
    92          Returns:
    93              The ETL object created.
    94          """
    95          return Etl(client=self._request_client, name=etl_name)
    96  
    97      def dsort(self, dsort_id: str = ""):
    98          """
    99          Factory constructor for dSort object.
   100          Contains APIs related to AIStore dSort operations.
   101          Does not make any HTTP request, only instantiates a dSort object.
   102  
   103          Args:
   104              dsort_id: ID of the dSort job
   105  
   106          Returns:
   107              dSort object created
   108          """
   109          return Dsort(client=self._request_client, dsort_id=dsort_id)