-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04a0c1e
commit e38c76f
Showing
16 changed files
with
850 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,22 @@ jobs: | |
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
cache: "pip" | ||
cache: 'pip' | ||
- uses: pre-commit/[email protected] | ||
|
||
pylint: | ||
runs-on: ubuntu-latest | ||
name: Pylint test | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.12"] | ||
python-version: ['3.8', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
cache: 'pip' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
|
@@ -37,13 +37,13 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: ["3.8", "3.12"] | ||
version: ['3.8', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.version }} | ||
cache: "pip" | ||
cache: 'pip' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
|
@@ -72,7 +72,7 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
cache: 'pip' | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
@@ -102,7 +102,7 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
cache: "pip" | ||
cache: 'pip' | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
@@ -132,7 +132,7 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
cache: "pip" | ||
cache: 'pip' | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
@@ -163,7 +163,7 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
cache: "pip" | ||
cache: 'pip' | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
@@ -184,15 +184,16 @@ jobs: | |
-e "is only referenced in tests" \ | ||
-e "_ is never read" \ | ||
-e "affected_rows" \ | ||
-e "src/kili/orm" \ | ||
-e "src/kili/entrypoints" \ | ||
-e "src/kili/services" \ | ||
-e "src/kili/types.py" \ | ||
-e "src/kili/core/graphql/ws_graphql_client" \ | ||
-e "internal" \ | ||
-e "src/kili/domain/ontology.py" \ | ||
-e "src/kili/client.py" \ | ||
-e "src/kili/core/graphql/ws_graphql_client" \ | ||
-e "src/kili/domain/annotation.py" \ | ||
-e "src/kili/domain/ontology.py" \ | ||
-e "src/kili/domain/project.py" \ | ||
-e "src/kili/entrypoints" \ | ||
-e "src/kili/orm" \ | ||
-e "src/kili/services" \ | ||
-e "src/kili/types.py" \ | ||
> dead_code_filtered.txt || true | ||
- name: Crash if dead code found | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/kili/adapters/kili_api_gateway/model_configuration/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Api key Kili Gateway module.""" |
11 changes: 11 additions & 0 deletions
11
src/kili/adapters/kili_api_gateway/model_configuration/mappers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""GraphQL payload data mappers for api keys operations.""" | ||
|
||
from kili.domain.project_model import ProjectModelFilters | ||
|
||
|
||
def project_model_where_mapper(filter: ProjectModelFilters): | ||
"""Build the GraphQL ProjectMapperWhere variable to be sent in an operation.""" | ||
return { | ||
"projectId": filter.project_id, | ||
"modelId": filter.model_id, | ||
} |
12 changes: 12 additions & 0 deletions
12
src/kili/adapters/kili_api_gateway/model_configuration/operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""GraphQL Asset operations.""" | ||
|
||
|
||
def get_project_models_query(fragment: str) -> str: | ||
"""Return the GraphQL projectModels query.""" | ||
return f""" | ||
query ProjectModels($where: ProjectModelWhere!, $first: PageSize!, $skip: Int!) {{ | ||
data: projectModels(where: $where, first: $first, skip: $skip) {{ | ||
{fragment} | ||
}} | ||
}} | ||
""" |
36 changes: 36 additions & 0 deletions
36
src/kili/adapters/kili_api_gateway/model_configuration/operations_mixin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Mixin extending Kili API Gateway class with Api Keys related operations.""" | ||
|
||
from typing import Dict, Generator, Optional | ||
|
||
from kili.adapters.kili_api_gateway.base import BaseOperationMixin | ||
from kili.adapters.kili_api_gateway.helpers.queries import ( | ||
PaginatedGraphQLQuery, | ||
QueryOptions, | ||
fragment_builder, | ||
) | ||
from kili.adapters.kili_api_gateway.model_configuration.mappers import project_model_where_mapper | ||
from kili.adapters.kili_api_gateway.model_configuration.operations import get_project_models_query | ||
from kili.domain.project_model import ProjectModelFilters | ||
from kili.domain.types import ListOrTuple | ||
|
||
|
||
class ModelConfigurationOperationMixin(BaseOperationMixin): | ||
"""Mixin extending Kili API Gateway class with model configuration related operations.""" | ||
|
||
def list_project_models( | ||
self, | ||
filters: ProjectModelFilters, | ||
fields: ListOrTuple[str], | ||
options: Optional[QueryOptions] = None, | ||
) -> Generator[Dict, None, None]: | ||
"""List assets with given options.""" | ||
fragment = fragment_builder(fields) | ||
query = get_project_models_query(fragment) | ||
where = project_model_where_mapper(filters) | ||
return PaginatedGraphQLQuery(self.graphql_client).execute_query_from_paginated_call( | ||
query, | ||
where, | ||
options if options else QueryOptions(disable_tqdm=False), | ||
"Retrieving project models", | ||
None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""API Key domain.""" | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class ProjectModelFilters: | ||
"""Project model filters for running a project model search.""" | ||
|
||
project_id: Optional[str] = None | ||
model_id: Optional[str] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.