From 9b54380d6c200e195bfde6b4afa9f11f735cb111 Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Fri, 5 Jul 2024 17:51:36 +0300 Subject: [PATCH 1/3] ci: Update size label --- .github/workflows/labeler.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index af744dcd..ad85867f 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -69,6 +69,36 @@ jobs: fi echo "label=$label" >> $GITHUB_ENV + - name: Fetch current labels + id: fetch_labels + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: labels } = await github.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + return labels.map(label => label.name); + + - name: Remove old size labels + id: remove_labels + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const sizeLabels = ['size:s', 'size:m', 'size:l', 'size:xl', 'size:xxl']; + const labelsToRemove = ${JSON.stringify(fetch_labels.outputs.labels)}.filter(label => sizeLabels.includes(label)); + for (const label of labelsToRemove) { + await github.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: label, + }); + } + - name: Add label to PR uses: actions-ecosystem/action-add-labels@v1 with: From 3972200f430cabc193eb78d900cb02b3866b030b Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Fri, 5 Jul 2024 17:55:09 +0300 Subject: [PATCH 2/3] test: File to test label --- ai21/test_file.py | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 ai21/test_file.py diff --git a/ai21/test_file.py b/ai21/test_file.py new file mode 100644 index 00000000..7d5bae8d --- /dev/null +++ b/ai21/test_file.py @@ -0,0 +1,95 @@ +from typing import Optional + + +class AI21APIError(Exception): + def __init__(self, status_code: int, details: Optional[str] = None): + super().__init__(details) + self.details = details + self.status_code = status_code + + def __str__(self) -> str: + return f"Failed with http status code: {self.status_code} ({type(self).__name__}). Details: {self.details}" + + +class BadRequest(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(400, details) + + +class Unauthorized(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(401, details) + + +class AccessDenied(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(403, details) + + +class NotFound(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(404, details) + + +class APITimeoutError(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(408, details) + + +class UnprocessableEntity(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(422, details) + + +class TooManyRequestsError(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(429, details) + + +class AI21ServerError(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(500, details) + + +class ServiceUnavailable(AI21APIError): + def __init__(self, details: Optional[str] = None): + super().__init__(500, details) + + +class AI21Error(Exception): + def __init__(self, message: str): + self.message = message + super().__init__(message) + + def __str__(self) -> str: + return f"{type(self).__name__} {self.message}" + + +class MissingApiKeyError(AI21Error): + def __init__(self): + message = "API key must be supplied either globally in the ai21 namespace, or to be provided in the call args" + super().__init__(message) + self.message = message + + +class ModelPackageDoesntExistError(AI21Error): + def __init__(self, model_name: str, region: str, version: Optional[str] = None): + message = f"model_name: {model_name} doesn't exist in region: {region}" + + if version is not None: + message += f" with version: {version}" + + super().__init__(message) + self.message = message + + +class EmptyMandatoryListError(AI21Error): + def __init__(self, key: str): + message = f"Supplied {key} is empty. At least one element should be present in the list" + super().__init__(message) + + +class StreamingDecodeError(AI21Error): + def __init__(self, chunk: str): + message = f"Failed to decode chunk: {chunk} in stream. Please check the stream format" + super().__init__(message) From 99f586805eaf801f49d3c0bcabb0a125e8e6358a Mon Sep 17 00:00:00 2001 From: Josephasafg Date: Fri, 5 Jul 2024 17:56:44 +0300 Subject: [PATCH 3/3] fix: Remove file --- ai21/test_file.py | 95 ----------------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 ai21/test_file.py diff --git a/ai21/test_file.py b/ai21/test_file.py deleted file mode 100644 index 7d5bae8d..00000000 --- a/ai21/test_file.py +++ /dev/null @@ -1,95 +0,0 @@ -from typing import Optional - - -class AI21APIError(Exception): - def __init__(self, status_code: int, details: Optional[str] = None): - super().__init__(details) - self.details = details - self.status_code = status_code - - def __str__(self) -> str: - return f"Failed with http status code: {self.status_code} ({type(self).__name__}). Details: {self.details}" - - -class BadRequest(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(400, details) - - -class Unauthorized(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(401, details) - - -class AccessDenied(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(403, details) - - -class NotFound(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(404, details) - - -class APITimeoutError(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(408, details) - - -class UnprocessableEntity(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(422, details) - - -class TooManyRequestsError(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(429, details) - - -class AI21ServerError(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(500, details) - - -class ServiceUnavailable(AI21APIError): - def __init__(self, details: Optional[str] = None): - super().__init__(500, details) - - -class AI21Error(Exception): - def __init__(self, message: str): - self.message = message - super().__init__(message) - - def __str__(self) -> str: - return f"{type(self).__name__} {self.message}" - - -class MissingApiKeyError(AI21Error): - def __init__(self): - message = "API key must be supplied either globally in the ai21 namespace, or to be provided in the call args" - super().__init__(message) - self.message = message - - -class ModelPackageDoesntExistError(AI21Error): - def __init__(self, model_name: str, region: str, version: Optional[str] = None): - message = f"model_name: {model_name} doesn't exist in region: {region}" - - if version is not None: - message += f" with version: {version}" - - super().__init__(message) - self.message = message - - -class EmptyMandatoryListError(AI21Error): - def __init__(self, key: str): - message = f"Supplied {key} is empty. At least one element should be present in the list" - super().__init__(message) - - -class StreamingDecodeError(AI21Error): - def __init__(self, chunk: str): - message = f"Failed to decode chunk: {chunk} in stream. Please check the stream format" - super().__init__(message)