Skip to content

Commit

Permalink
feat: fix circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
theodu committed Aug 28, 2023
1 parent bb39dd5 commit 6e7e27c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/kili/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from kili.entrypoints.mutations.project import MutationsProject
from kili.entrypoints.mutations.project_version import MutationsProjectVersion
from kili.entrypoints.mutations.user import MutationsUser
from kili.entrypoints.queries.asset import QueriesAsset
from kili.entrypoints.queries.data_connection import QueriesDataConnection
from kili.entrypoints.queries.data_integration import QueriesDataIntegration
from kili.entrypoints.queries.issue import QueriesIssue
Expand Down Expand Up @@ -67,7 +66,6 @@ class Kili( # pylint: disable=too-many-ancestors,too-many-instance-attributes
MutationsProject,
MutationsProjectVersion,
MutationsUser,
QueriesAsset,
QueriesDataConnection,
QueriesDataIntegration,
QueriesIssue,
Expand Down
2 changes: 1 addition & 1 deletion src/kili/gateways/kili_api_gateway/project/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def build_gql_value(self):
"updatedAtLte": self.updated_at_lte,
}
if self.archived is not None:
value["archived"] = self.archived
value["archived"] = self.archived # type: ignore
return value
2 changes: 1 addition & 1 deletion src/kili/gateways/kili_api_gateway/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AbstractQueryWhere(ABC):
"""Abtsract class for defining the where payload to send in a graphQL query."""

@abstractmethod
def build_gql_value(self) -> Dict:
def build_gql_value(self):
"""Build the GraphQL where payload sent in the resolver from the
arguments given to the where class."""
raise NotImplementedError
Expand Down
7 changes: 2 additions & 5 deletions src/kili/services/asset_import/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from tenacity.retry import retry_if_exception_type
from tenacity.wait import wait_exponential

from kili.client import Kili
from kili.core.graphql.operations.asset.mutations import (
GQL_APPEND_MANY_ASSETS,
GQL_APPEND_MANY_FRAMES_TO_DATASET,
Expand Down Expand Up @@ -74,9 +73,7 @@ class LoggerParams(NamedTuple):
class BaseBatchImporter: # pylint: disable=too-many-instance-attributes
"""Base class for BatchImporters."""

def __init__(
self, kili: Kili, project_params: ProjectParams, batch_params: BatchParams, pbar: tqdm
):
def __init__(self, kili, project_params: ProjectParams, batch_params: BatchParams, pbar: tqdm):
self.kili = kili
self.project_id = project_params.project_id
self.input_type = project_params.input_type
Expand Down Expand Up @@ -342,7 +339,7 @@ class BaseAbstractAssetImporter(abc.ABC):

def __init__(
self,
kili: Kili,
kili,
project_params: ProjectParams,
processing_params: ProcessingParams,
logger_params: LoggerParams,
Expand Down
3 changes: 1 addition & 2 deletions src/kili/services/copy_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Dict, Optional

from kili import services
from kili.client import Kili
from kili.core.graphql.operations.label.queries import LabelQuery, LabelWhere
from kili.gateways.kili_api_gateway.asset.types import AssetWhere
from kili.gateways.kili_api_gateway.queries import QueryOptions
Expand All @@ -31,7 +30,7 @@ class ProjectCopier: # pylint: disable=too-few-public-methods
"reviewCoverage",
]

def __init__(self, kili: Kili) -> None:
def __init__(self, kili) -> None:
self.disable_tqdm = False
self.kili = kili

Expand Down
3 changes: 1 addition & 2 deletions src/kili/services/data_connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from tenacity.stop import stop_after_delay
from tenacity.wait import wait_exponential

from kili.client import Kili
from kili.core.graphql.operations.data_connection.queries import (
DataConnectionIdWhere,
DataConnectionQuery,
Expand Down Expand Up @@ -62,7 +61,7 @@ def trigger_validate_data_differences(


def validate_data_differences(
kili: Kili, diff_type: Literal["ADD", "REMOVE"], data_connection: Dict
kili, diff_type: Literal["ADD", "REMOVE"], data_connection: Dict
) -> None:
"""Call the validateDataDifferences resolver and wait until the validation is done."""
diff = data_connection["dataDifferencesSummary"]["added" if diff_type == "ADD" else "removed"]
Expand Down
3 changes: 1 addition & 2 deletions src/kili/services/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path
from typing import Any, Dict, Generator, Iterable, List, Optional, TypeVar

from kili.client import Kili
from kili.core.utils import pagination
from kili.exceptions import NotFound
from kili.gateways.kili_api_gateway.asset.types import AssetWhere
Expand Down Expand Up @@ -87,7 +86,7 @@ def infer_ids_from_external_ids(
return id_map


def _build_id_map(kili: Kili, asset_external_ids, project_id):
def _build_id_map(kili, asset_external_ids, project_id):
assets_generators: List[Generator[Dict, None, None]] = []
# query all assets by external ids batches when there are too many
for external_ids_batch in pagination.BatchIteratorBuilder(asset_external_ids, 1000):
Expand Down
4 changes: 1 addition & 3 deletions src/kili/utils/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from tenacity.stop import stop_after_attempt
from tenacity.wait import wait_random

from kili.client import Kili

AZURE_STRING = "blob.core.windows.net"
GCP_STRING = "storage.googleapis.com"
GCP_STRING_PUBLIC = "storage.cloud.google.com"
Expand All @@ -25,7 +23,7 @@ def generate_unique_id():
return cuid.cuid()


def request_signed_urls(kili: Kili, file_urls: List[str]):
def request_signed_urls(kili, file_urls: List[str]):
"""Get upload signed URLs.
Args:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/services/asset_import/test_import_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def test_import_one_video_with_metadata(self, *_):
@patch("kili.utils.bucket.generate_unique_id", mocked_unique_id)
@patch.object(ProjectQuery, "__call__", side_effect=mocked_project_input_type("VIDEO_LEGACY"))
@patch.object(
QueriesAsset,
"assets",
AssetOperationMixin,
"list_assets",
MagicMock(return_value=[]),
)
@patch.object(AssetOperationMixin, "count_assets", return_value=1)
Expand Down

0 comments on commit 6e7e27c

Please sign in to comment.