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

Consensus simple merging #8953

Open
wants to merge 129 commits into
base: develop
Choose a base branch
from
Open

Conversation

zhiltsov-max
Copy link
Contributor

@zhiltsov-max zhiltsov-max commented Jan 16, 2025

Motivation and context

Depends on #8939, #9026
A part of #8434

  • Added support for consensus task and consensus job merging (API and UI)
  • Added simple consensus settings
  • Added server tests
  • Added new consensus RQ queue and worker

Limitations:

  • Merging is supported for all annotations except 2d and 3d cuboids. 3d tasks are not supported
  • Annotation groups are not supported (each annotation is considered separate in a group)
  • Polygons and masks are not interchangeable (each type is compared only with the same type)

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

@zhiltsov-max zhiltsov-max marked this pull request as ready for review February 3, 2025 16:11
Comment on lines 35 to +36
QualitySettingsFilter, SerializedAsset,
ConsensusSettingsFilter,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QualitySettingsFilter, SerializedAsset,
ConsensusSettingsFilter,
QualitySettingsFilter, SerializedAsset, ConsensusSettingsFilter,

@@ -46,6 +47,7 @@ import { convertDescriptions, getServerAPISchema } from './server-schema';
import { JobType } from './enums';
import { PaginatedResource } from './core-types';
import CVATCore from '.';
import ConsensusSettings from './consensus-settings';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should place it before annotation-actions

),
};

export const mergeTaskConsensusJobsAsync = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like having two functions for the same action is redundant since both task and job instance have .mergeConsensusJobs method

cvat-core/src/server-proxy.ts Show resolved Hide resolved
Comment on lines +128 to +133
let taskInstance = null;
try {
[taskInstance] = await core.tasks.get({ id });
} catch (error: unknown) {
throw new Error('The task was not found on the server');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this part can be extracted into hook and re-used on quality page

Comment on lines +32 to +34
const onViewConsensusManagement = (): void => {
history.push(`/tasks/${taskInstance.id}/consensus`);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As those onView... functions are duplicated, it seems we can extract them and re-use as callbacks

@@ -36,6 +38,7 @@ interface DispatchToProps {
openRunModelWindow: (taskInstance: any) => void;
deleteTask: (taskInstance: any) => void;
openMoveTaskToProjectWindow: (taskInstance: any) => void;
mergeConsensusJobs: (taskInstance: any) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mergeConsensusJobs: (taskInstance: any) => void;
mergeConsensusJobs: (taskInstance: Task) => void;

jobInstance: null,
fetching: true,
consensusSettings: null,
mergingConsensus: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we do activities: { action: {} } merging in our case

mergingConsensus: {},
};

function makeKey(id: number, instance: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to pass instance itself here

taskInstance: Task | null;
jobInstance: Job | null;
mergingConsensus: {
[taskId: string]: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[taskId: string]: boolean;
[instanceId: string]: boolean;

Copy link

sonarqubecloud bot commented Feb 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need another worker for this? Can't an existing worker, like the quality report worker, handle this?

schema:
type: string
description: |
The consensus merge request id. Can be specified to check operation status.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using the request API for status checking.


@property
def organization_id(self):
return getattr(self.task.organization, "id", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return getattr(self.task.organization, "id", None)
return self.task.organization_id

@@ -453,7 +453,7 @@ def get_tmp_dirname(self) -> str:


@transaction.atomic(savepoint=False)
def clear_annotations_in_jobs(job_ids):
def clear_annotations_in_jobs(job_ids: Iterable[int] | Iterator[int]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterator is a subclass of Iterable, so this is equivalent to Iterable[int].

@@ -14,7 +14,7 @@
from collections.abc import Collection, Sequence
from enum import Enum
from functools import cached_property
from typing import Any, ClassVar, Optional
from typing import Any, ClassVar, Iterable, Iterator, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use collections.abc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants