─░├žeri─če ge├ž

Referans i├žin hub_sdk/modules/teams.py

Not

Bu dosya https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/modules/teams .py adresinde mevcuttur. Bir sorun tespit ederseniz, l├╝tfen bir ├çekme ─░ste─či ­čŤá´ŞĆ ile katk─▒da bulunarak d├╝zeltmeye yard─▒mc─▒ olun. Te┼čekk├╝rler ­čÖĆ!



hub_sdk.modules.teams.Teams

├ťsler: CRUDClient

CRUD i┼člemleri arac─▒l─▒─č─▒yla Teams ile etkile┼čim kurmak i├žin bir istemciyi temsil eden bir s─▒n─▒f. Bu s─▒n─▒f CRUDClient'─▒ geni┼čletir s─▒n─▒f─▒n─▒ olu┼čturur ve Teams ile ├žal─▒┼čmak i├žin ├Âzel y├Ântemler sa─člar.

Nitelikler:

─░sim Tip A├ž─▒klama
id (str, None)

Varsa, ekibin benzersiz tan─▒mlay─▒c─▒s─▒.

data dict

Ekip verilerini saklamak i├žin bir s├Âzl├╝k.

Not

'id' ├Âzniteli─či ba┼člatma s─▒ras─▒nda ayarlan─▒r ve bir ekibi benzersiz bir ┼čekilde tan─▒mlamak i├žin kullan─▒labilir. 'data' ├Âzniteli─či, API'den al─▒nan ekip verilerini saklamak i├žin kullan─▒l─▒r.

Kaynak kodu hub_sdk/modules/teams.py
class Teams(CRUDClient):
    """
    A class representing a client for interacting with Teams through CRUD operations. This class extends the CRUDClient
    class and provides specific methods for working with Teams.

    Attributes:
        id (str, None): The unique identifier of the team, if available.
        data (dict): A dictionary to store team data.

    Note:
        The 'id' attribute is set during initialization and can be used to uniquely identify a team.
        The 'data' attribute is used to store team data fetched from the API.
    """

    def __init__(self, team_id: Optional[str] = None, headers: Optional[Dict[str, Any]] = None):
        """
        Initialize a Teams instance.

        Args:
            team_id (str, optional): The unique identifier of the team.
            headers (dict, optional): A dictionary of HTTP headers to be included in API requests.
        """
        super().__init__("teams", "team", headers)
        self.id = team_id
        self.data = {}
        if team_id:
            self.get_data()

    def get_data(self) -> None:
        """
        Retrieves data for the current team instance.

        If a valid team ID has been set, it sends a request to fetch the team data and stores it in the instance.
        If no team ID has been set, it logs an error message.

        Returns:
            (None): The method does not return a value.
        """
        if not self.id:
            self.logger.error("No team id has been set. Update the team id or create a team.")
            return

        try:
            response = super().read(self.id)

            if response is None:
                self.logger.error(f"Received no response from the server for team ID: {self.id}")
                return

            # Check if the response has a .json() method (it should if it's a response object)
            if not hasattr(response, "json"):
                self.logger.error(f"Invalid response object received for team ID: {self.id}")
                return

            resp_data = response.json()
            if resp_data is None:
                self.logger.error(f"No data received in the response for team ID: {self.id}")
                return

            data = resp_data.get("data", {})
            self.data = self._reconstruct_data(data)
            self.logger.debug(f"Team data retrieved for ID: {self.id}")

        except Exception as e:
            self.logger.error(f"An error occurred while retrieving data for team ID: {self.id}, {str(e)}")

    def create_team(self, team_data) -> None:
        """
        Creates a new team with the provided data and sets the team ID for the current instance.

        Args:
            team_data (dict): A dictionary containing the data for creating the team.

        Returns:
            (None): The method does not return a value.
        """
        resp = super().create(team_data).json()
        self.id = resp.get("data", {}).get("id")
        self.get_data()

    def delete(self, hard=False) -> Optional[Response]:
        """
        Delete the team resource represented by this instance.

        Args:
            hard (bool, optional): If True, perform a hard (permanent) delete.

        Note:
            The 'hard' parameter determines whether to perform a soft delete (default) or a hard delete.
            In a soft delete, the team might be marked as deleted but retained in the system.
            In a hard delete, the team is permanently removed from the system.

        Returns:
            (Optional[Response]): The response from the delete request, or None if it fails.
        """
        return super().delete(self.id, hard)

    def update(self, data) -> Optional[Response]:
        """
        Update the team resource represented by this instance.

        Args:
            data (dict): The updated data for the team resource.

        Returns:
            (Optional[Response]): The response from the update request, or None if it fails.
        """
        return super().update(self.id, data)

__init__(team_id=None, headers=None)

Bir Teams ├Ârne─čini ba┼člat─▒n.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
team_id str

Ekibin benzersiz tan─▒mlay─▒c─▒s─▒.

None
headers dict

API isteklerine dahil edilecek HTTP ├╝stbilgileri s├Âzl├╝─č├╝.

None
Kaynak kodu hub_sdk/modules/teams.py
def __init__(self, team_id: Optional[str] = None, headers: Optional[Dict[str, Any]] = None):
    """
    Initialize a Teams instance.

    Args:
        team_id (str, optional): The unique identifier of the team.
        headers (dict, optional): A dictionary of HTTP headers to be included in API requests.
    """
    super().__init__("teams", "team", headers)
    self.id = team_id
    self.data = {}
    if team_id:
        self.get_data()

create_team(team_data)

Sa─članan verilerle yeni bir ekip olu┼čturur ve ge├žerli ├Ârnek i├žin ekip kimli─čini ayarlar.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
team_data dict

Ekibi olu┼čturmak i├žin gerekli verileri i├žeren bir s├Âzl├╝k.

gerekli

─░ade:

Tip A├ž─▒klama
None

Y├Ântem bir de─čer d├Ând├╝rmez.

Kaynak kodu hub_sdk/modules/teams.py
def create_team(self, team_data) -> None:
    """
    Creates a new team with the provided data and sets the team ID for the current instance.

    Args:
        team_data (dict): A dictionary containing the data for creating the team.

    Returns:
        (None): The method does not return a value.
    """
    resp = super().create(team_data).json()
    self.id = resp.get("data", {}).get("id")
    self.get_data()

delete(hard=False)

Bu ├Ârnek taraf─▒ndan temsil edilen ekip kayna─č─▒n─▒ silin.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
hard bool

Do─čru ise, sert (kal─▒c─▒) bir silme i┼člemi ger├žekle┼čtirin.

False
Not

'Sert' parametresi yumu┼čak silme (varsay─▒lan) veya sert silme i┼člemlerinden hangisinin ger├žekle┼čtirilece─čini belirler. Yumu┼čak silme i┼čleminde, ekip silinmi┼č olarak i┼čaretlenebilir ancak sistemde tutulabilir. Sert silme i┼čleminde, ekip sistemden kal─▒c─▒ olarak kald─▒r─▒l─▒r.

─░ade:

Tip A├ž─▒klama
Optional[Response]

Silme iste─činden gelen yan─▒t veya ba┼čar─▒s─▒z olursa Yok.

Kaynak kodu hub_sdk/modules/teams.py
def delete(self, hard=False) -> Optional[Response]:
    """
    Delete the team resource represented by this instance.

    Args:
        hard (bool, optional): If True, perform a hard (permanent) delete.

    Note:
        The 'hard' parameter determines whether to perform a soft delete (default) or a hard delete.
        In a soft delete, the team might be marked as deleted but retained in the system.
        In a hard delete, the team is permanently removed from the system.

    Returns:
        (Optional[Response]): The response from the delete request, or None if it fails.
    """
    return super().delete(self.id, hard)

get_data()

Ge├žerli ekip ├Ârne─či i├žin verileri al─▒r.

Ge├žerli bir tak─▒m kimli─či ayarlanm─▒┼čsa, tak─▒m verilerini almak i├žin bir istek g├Ânderir ve bunlar─▒ ├Ârnekte depolar. Herhangi bir tak─▒m kimli─či ayarlanmam─▒┼čsa, bir hata mesaj─▒ g├╝nl├╝─če kaydeder.

─░ade:

Tip A├ž─▒klama
None

Y├Ântem bir de─čer d├Ând├╝rmez.

Kaynak kodu hub_sdk/modules/teams.py
def get_data(self) -> None:
    """
    Retrieves data for the current team instance.

    If a valid team ID has been set, it sends a request to fetch the team data and stores it in the instance.
    If no team ID has been set, it logs an error message.

    Returns:
        (None): The method does not return a value.
    """
    if not self.id:
        self.logger.error("No team id has been set. Update the team id or create a team.")
        return

    try:
        response = super().read(self.id)

        if response is None:
            self.logger.error(f"Received no response from the server for team ID: {self.id}")
            return

        # Check if the response has a .json() method (it should if it's a response object)
        if not hasattr(response, "json"):
            self.logger.error(f"Invalid response object received for team ID: {self.id}")
            return

        resp_data = response.json()
        if resp_data is None:
            self.logger.error(f"No data received in the response for team ID: {self.id}")
            return

        data = resp_data.get("data", {})
        self.data = self._reconstruct_data(data)
        self.logger.debug(f"Team data retrieved for ID: {self.id}")

    except Exception as e:
        self.logger.error(f"An error occurred while retrieving data for team ID: {self.id}, {str(e)}")

update(data)

Bu ├Ârnek taraf─▒ndan temsil edilen ekip kayna─č─▒n─▒ g├╝ncelleyin.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
data dict

Ekip kayna─č─▒ i├žin g├╝ncellenmi┼č veriler.

gerekli

─░ade:

Tip A├ž─▒klama
Optional[Response]

The response from the update request, or None if it fails.

Kaynak kodu hub_sdk/modules/teams.py
def update(self, data) -> Optional[Response]:
    """
    Update the team resource represented by this instance.

    Args:
        data (dict): The updated data for the team resource.

    Returns:
        (Optional[Response]): The response from the update request, or None if it fails.
    """
    return super().update(self.id, data)



hub_sdk.modules.teams.TeamList

├ťsler: PaginatedList

Kaynak kodu hub_sdk/modules/teams.py
class TeamList(PaginatedList):
    def __init__(self, page_size=None, public=None, headers=None):
        """
        Initialize a TeamList instance.

        Args:
            page_size (int, optional): The number of items to request per page.
            public (bool, optional): Whether the items should be publicly accessible.
            headers (dict, optional): Headers to be included in API requests.
        """
        base_endpoint = "datasets"
        if public:
            base_endpoint = f"public/{base_endpoint}"
        super().__init__(base_endpoint, "team", page_size, headers)

__init__(page_size=None, public=None, headers=None)

Bir TeamList ├Ârne─čini ba┼člat─▒n.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
page_size int

Sayfa ba┼č─▒na talep edilecek ├Â─če say─▒s─▒.

None
public bool

├ľ─čelerin kamu eri┼čimine a├ž─▒k olup olmamas─▒.

None
headers dict

API isteklerine dahil edilecek ba┼čl─▒klar.

None
Kaynak kodu hub_sdk/modules/teams.py
def __init__(self, page_size=None, public=None, headers=None):
    """
    Initialize a TeamList instance.

    Args:
        page_size (int, optional): The number of items to request per page.
        public (bool, optional): Whether the items should be publicly accessible.
        headers (dict, optional): Headers to be included in API requests.
    """
    base_endpoint = "datasets"
    if public:
        base_endpoint = f"public/{base_endpoint}"
    super().__init__(base_endpoint, "team", page_size, headers)