diff --git a/src/kili/core/enums.py b/src/kili/core/enums.py index 8e0d8ff0b..eac48e312 100644 --- a/src/kili/core/enums.py +++ b/src/kili/core/enums.py @@ -39,19 +39,6 @@ "VIDEO_LEGACY", ] - -IssueStatus = Literal[ - "OPEN", - "SOLVED", -] - - -IssueType = Literal[ - "ISSUE", - "QUESTION", -] - - LabelFormat = Literal[ "RAW", "SIMPLE", diff --git a/src/kili/gateways/kili_api_gateway/issue/__init__.py b/src/kili/gateways/kili_api_gateway/issue/__init__.py index 5cc1815d0..e4e0aa77b 100644 --- a/src/kili/gateways/kili_api_gateway/issue/__init__.py +++ b/src/kili/gateways/kili_api_gateway/issue/__init__.py @@ -1,41 +1,21 @@ -"""GraphQL Mixin extending GraphQL Gateway class with Issue related operations.""" +"""Mixin extending Kili API Gateway class with Issue related operations.""" -from dataclasses import dataclass from typing import List, Optional -from kili.core.enums import IssueStatus from kili.core.graphql.graphql_client import GraphQLClient from kili.core.utils.pagination import BatchIteratorBuilder -from kili.domain.issue import Issue, IssueType +from kili.domain.issue import Issue, IssueStatus, IssueType from kili.gateways.kili_api_gateway.issue.operations import ( GQL_COUNT_ISSUES, GQL_CREATE_ISSUES, ) -from kili.gateways.kili_api_gateway.issue.types import IssueToCreateKiliAPIGatewayInput +from kili.gateways.kili_api_gateway.issue.types import ( + IssueToCreateKiliAPIGatewayInput, + IssueWhere, +) from kili.utils import tqdm -@dataclass -class IssueWhere: - """Tuple to be passed to the IssueQuery to restrict query.""" - - project_id: str - asset_id: Optional[str] = None - asset_id_in: Optional[List[str]] = None - issue_type: Optional[IssueType] = None - status: Optional[IssueStatus] = None - - def get_graphql_input(self): - """Build the GraphQL IssueWhere payload to be sent in an operation.""" - return { - "project": {"id": self.project_id}, - "asset": {"id": self.asset_id}, - "assetIn": self.asset_id_in, - "status": self.status, - "type": self.issue_type, - } - - class IssueOperationMixin: """GraphQL Mixin extending GraphQL Gateway class with Issue related operations.""" @@ -82,7 +62,7 @@ def count_issues( # pylint: disable=too-many-arguments, """Send a GraphQL request calling countIssues resolver.""" where = IssueWhere(project_id, asset_id, asset_id_in, issue_type, status) payload = { - "where": where.get_graphql_input(), + "where": where.get_graphql_where_value(), } count_result = self.graphql_client.execute(GQL_COUNT_ISSUES, payload) return count_result["data"] diff --git a/src/kili/gateways/kili_api_gateway/issue/types.py b/src/kili/gateways/kili_api_gateway/issue/types.py index d59fbaf51..a23e0a16d 100644 --- a/src/kili/gateways/kili_api_gateway/issue/types.py +++ b/src/kili/gateways/kili_api_gateway/issue/types.py @@ -1,6 +1,8 @@ """Types for the Issue-related Kili API gateway functions.""" from dataclasses import dataclass -from typing import Optional +from typing import List, Optional + +from kili.domain.issue import IssueStatus, IssueType @dataclass @@ -12,3 +14,24 @@ class IssueToCreateKiliAPIGatewayInput: object_mid: Optional[str] asset_id: str text: Optional[str] + + +@dataclass +class IssueWhere: + """Tuple to be passed to the IssueQuery to restrict query.""" + + project_id: str + asset_id: Optional[str] = None + asset_id_in: Optional[List[str]] = None + issue_type: Optional[IssueType] = None + status: Optional[IssueStatus] = None + + def get_graphql_where_value(self): + """Build the GraphQL IssueWhere variable value to be sent in an operation.""" + return { + "project": {"id": self.project_id}, + "asset": {"id": self.asset_id}, + "assetIn": self.asset_id_in, + "status": self.status, + "type": self.issue_type, + } diff --git a/src/kili/types.py b/src/kili/types.py index 0c351b764..00461a79d 100644 --- a/src/kili/types.py +++ b/src/kili/types.py @@ -6,7 +6,6 @@ from kili.core.enums import ( InputType, - IssueStatus, LabelType, LicenseType, LockType, @@ -17,6 +16,7 @@ Status, ) from kili.core.helpers import deprecate +from kili.domain.issue import IssueStatus #######