Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SUP-1982): aa enabled sdk copy project auto assign and skip quality #1815

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/kili/adapters/kili_api_gateway/project/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def project_data_mapper(data: ProjectDataKiliAPIGatewayInput) -> Dict:
"numberOfRemainingAssets": data.number_of_remaining_assets,
"numberOfReviewedAssets": data.number_of_reviewed_assets,
"reviewCoverage": data.review_coverage,
"secondsToLabelBeforeAutoAssign": data.seconds_to_label_before_auto_assign,
"shouldRelaunchKpiComputation": data.should_relaunch_kpi_computation,
"title": data.title,
"useHoneyPot": data.use_honeypot,
Expand Down
1 change: 1 addition & 0 deletions src/kili/adapters/kili_api_gateway/project/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ProjectDataKiliAPIGatewayInput:
number_of_remaining_assets: Optional[int]
number_of_reviewed_assets: Optional[int]
review_coverage: Optional[int]
seconds_to_label_before_auto_assign: Optional[int]
should_relaunch_kpi_computation: Optional[bool]
title: Optional[str]
use_honeypot: Optional[bool]
5 changes: 5 additions & 0 deletions src/kili/presentation/client/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def update_properties_in_project(
title: Optional[str] = None,
use_honeypot: Optional[bool] = None,
metadata_types: Optional[dict] = None,
seconds_to_label_before_auto_assign: Optional[int] = None,
) -> Dict[str, Any]:
"""Update properties of a project.

Expand Down Expand Up @@ -340,6 +341,9 @@ def update_properties_in_project(
metadata_types: Types of the project metadata.
Should be a `dict` of metadata fields name as keys and metadata types as values.
Currently, possible types are: `string`, `number`
seconds_to_label_before_auto_assign: When a user begins to annotate an asset,
it automatically gets assigned to them.
This ensures the user retains the asset until it is submitted.

Returns:
A dict with the changed properties which indicates if the mutation was successful,
Expand Down Expand Up @@ -388,6 +392,7 @@ def update_properties_in_project(
use_honeypot=use_honeypot,
title=title,
metadata_types=metadata_types,
seconds_to_label_before_auto_assign=seconds_to_label_before_auto_assign,
)

@typechecked
Expand Down
6 changes: 5 additions & 1 deletion src/kili/services/copy_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ class ProjectCopier: # pylint: disable=too-few-public-methods
)
FIELDS_JSON_INTERFACE = ("jsonInterface",)
FIELDS_QUALITY_SETTINGS = (
"canSkipAsset",
"consensusTotCoverage",
"minConsensusSize",
"useHoneyPot",
"reviewCoverage",
"secondsToLabelBeforeAutoAssign",
"useHoneyPot",
)

def __init__(self, kili: "Kili") -> None:
Expand Down Expand Up @@ -156,10 +158,12 @@ def _copy_members(self, from_project_id: str, new_project_id: str) -> None:
def _copy_quality_settings(self, new_project_id: str, src_project: Dict) -> None:
self.kili.update_properties_in_project(
project_id=new_project_id,
can_skip_asset=src_project["canSkipAsset"],
consensus_tot_coverage=src_project["consensusTotCoverage"],
min_consensus_size=src_project["minConsensusSize"],
use_honeypot=src_project["useHoneyPot"],
review_coverage=src_project["reviewCoverage"],
seconds_to_label_before_auto_assign=src_project["secondsToLabelBeforeAutoAssign"],
)

def _copy_assets(self, from_project_id: str, new_project_id: str) -> None:
Expand Down
2 changes: 2 additions & 0 deletions src/kili/use_cases/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def update_properties_in_project(
title: Optional[str] = None,
use_honeypot: Optional[bool] = None,
metadata_types: Optional[Dict] = None,
seconds_to_label_before_auto_assign: Optional[int] = None,
) -> Dict[str, object]:
"""Update properties in a project."""
if consensus_tot_coverage is not None and not 0 <= consensus_tot_coverage <= 100:
Expand Down Expand Up @@ -158,6 +159,7 @@ def update_properties_in_project(
number_of_remaining_assets=number_of_remaining_assets,
number_of_reviewed_assets=number_of_reviewed_assets,
review_coverage=review_coverage,
seconds_to_label_before_auto_assign=seconds_to_label_before_auto_assign,
should_relaunch_kpi_computation=should_relaunch_kpi_computation,
title=title,
use_honeypot=use_honeypot,
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/test_copy_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ def src_project_video(kili: "Kili"):

kili.update_properties_in_project(
project_id=project["id"],
can_skip_asset=True,
consensus_tot_coverage=0,
min_consensus_size=1,
review_coverage=0,
seconds_to_label_before_auto_assign=0,
)

kili.append_to_roles(
Expand Down Expand Up @@ -190,6 +192,7 @@ def test_copy_project_e2e_video(kili: "Kili", src_project_video):
description="new description",
copy_assets=True,
copy_labels=True,
copy_quality_settings=True,
)

proj_fields = (
Expand Down Expand Up @@ -229,6 +232,11 @@ def test_copy_project_e2e_video(kili: "Kili", src_project_video):
assert new_proj["description"] == "new description"
assert new_proj["inputType"] == src_proj["inputType"]
assert new_proj["jsonInterface"] == src_proj["jsonInterface"]
assert new_proj["consensusTotCoverage"] == src_proj["consensusTotCoverage"]
assert new_proj["minConsensusSize"] == src_proj["minConsensusSize"]
assert new_proj["reviewCoverage"] == src_proj["reviewCoverage"]
assert new_proj["secondsToLabelBeforeAutoAssign"] == src_proj["secondsToLabelBeforeAutoAssign"]
assert new_proj["canSkipAsset"] == src_proj["canSkipAsset"]

# assert quality settings
for field_name in ProjectCopier.FIELDS_QUALITY_SETTINGS:
Expand Down
1 change: 1 addition & 0 deletions tests/integration/presentation/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test_when_updating_project_then_it_returns_updated_project(mocker: pytest_mo
"numberOfRemainingAssets": None,
"numberOfReviewedAssets": None,
"reviewCoverage": 42,
"secondsToLabelBeforeAutoAssign": None,
"shouldRelaunchKpiComputation": None,
"title": None,
"useHoneyPot": None,
Expand Down