Skip to content

Commit 4247b88

Browse files
committed
feat(lab-4021): add method to activate and deactivate consensus on asset
1 parent c3d9a4f commit 4247b88

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/kili/adapters/kili_api_gateway/asset/operations_mixin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626
from kili.adapters.kili_api_gateway.label.common import get_annotation_fragment
2727
from kili.adapters.kili_api_gateway.project.common import get_project
28+
from kili.core.graphql.operations.asset.mutations import GQL_SET_ASSET_CONSENSUS
2829
from kili.domain.asset import AssetFilters
2930
from kili.domain.types import ListOrTuple
3031

@@ -166,3 +167,13 @@ def count_assets_annotations(self, filters: AssetFilters) -> int:
166167
count_result = self.graphql_client.execute(GQL_COUNT_ASSET_ANNOTATIONS, payload)
167168
count: int = count_result["data"]
168169
return count
170+
171+
def set_asset_consensus(self, asset_id: str, project_id: str, is_consensus: bool) -> bool:
172+
"""Set consensus on an asset."""
173+
payload = {
174+
"assetId": asset_id,
175+
"projectId": project_id,
176+
"isConsensus": is_consensus,
177+
}
178+
result = self.graphql_client.execute(GQL_SET_ASSET_CONSENSUS, payload)
179+
return result["data"]

src/kili/core/graphql/operations/asset/mutations.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@
2727
}
2828
}
2929
"""
30+
31+
GQL_SET_ASSET_CONSENSUS = """
32+
mutation setAssetConsensus(
33+
$assetId: ID!,
34+
$projectId: ID!,
35+
$isConsensus: Boolean!
36+
) {
37+
data: setAssetConsensus(
38+
assetId: $assetId,
39+
projectId: $projectId,
40+
isConsensus: $isConsensus
41+
)
42+
}
43+
"""

src/kili/presentation/client/asset.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,3 +764,12 @@ def count_assets(
764764
)
765765
asset_use_cases = AssetUseCases(self.kili_api_gateway)
766766
return asset_use_cases.count_assets(filters)
767+
768+
@typechecked
769+
def set_asset_consensus(
770+
self,
771+
asset_id: str,
772+
project_id: str,
773+
is_consensus: bool,
774+
) -> bool:
775+
return self.kili_api_gateway.set_asset_consensus(asset_id, project_id, is_consensus)

0 commit comments

Comments
 (0)