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

Creating Consensus Job #7974

Open
wants to merge 46 commits into
base: gsoc/consensus-feature
Choose a base branch
from

Conversation

Viditagarwal7479
Copy link
Contributor

@Viditagarwal7479 Viditagarwal7479 commented May 31, 2024

Fixes Creating consensus jobs for normal jobs in #7973

List of features present in this PR

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.

Summary by CodeRabbit

  • New Features

    • Introduced a new consensus job per segment configuration option for tasks.
    • Added the ability to specify a source job ID for jobs.
  • Enhancements

    • Advanced configuration form now includes an option to set consensus job per segment.
    • Improved task and job creation workflows to support consensus jobs.
  • Bug Fixes

    • Fixed issues related to job and task serialization and deserialization to include new fields.
  • Migration

    • Multiple database migrations to add and alter fields for consensus job per segment and source job ID.

Copy link
Contributor

coderabbitai bot commented May 31, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce two new properties, consensus_job_per_segment and source_job_id, across various components of the CVAT system. These properties are integrated into the task and job models, serializers, and UI forms, enabling the creation and management of consensus jobs per segment within tasks. The updates span from backend database migrations to frontend user interface adjustments, ensuring seamless incorporation of these new features.

Changes

File Path Change Summary
cvat-core/src/server-response-types.ts Added consensus_job_per_segment to SerializedTask and source_job_id to SerializedJob.
cvat-core/src/session-implementation.ts Added consensus_job_per_segment property in implementTask function.
cvat-core/src/session.ts Added source_job_id and consensusJobPerSegment properties to Job and Task classes.
cvat-sdk/cvat_sdk/core/proxies/tasks.py Added consensus_job_per_segment parameter to upload_data function.
cvat-ui/src/actions/tasks-actions.ts Added consensus_job_per_segment to description object and conditionally set it based on data.advanced.consensusJobPerSegment.
cvat-ui/src/components/create-task-page/advanced-configuration-form.tsx Added consensusJobPerSegment property to AdvancedConfiguration interface and form item rendering method.
cvat/apps/dataset_manager/bindings.py Added source_job_id and consensus_job_per_segment parameters to metadata functions.
cvat/apps/dataset_manager/project.py Added consensus_job_per_segment parameter to dictionary.
cvat/apps/dataset_manager/task.py Added source_job_id=None filter condition.
cvat/apps/engine/admin.py Added consensus_job_per_segment field to DataAdmin class.
cvat/apps/engine/backup.py Added consensus_job_per_segment to allowed_fields set.
cvat/apps/engine/migrations/... Introduced and altered fields source_job_id and consensus_job_per_segment across multiple migration files.
cvat/apps/engine/models.py Added consensus_job_per_segment and source_job_id fields to models.
cvat/apps/engine/serializers.py Added source_job_id and consensus_job_per_segment fields to various serializers.
cvat/apps/engine/task.py Added loop to create consensus jobs per segment.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant UI as CVAT UI
    participant Backend as CVAT Backend
    participant DB as Database

    User->>UI: Create Task
    UI->>Backend: Send Task Data (including consensusJobPerSegment)
    Backend->>DB: Save Task Data
    DB-->>Backend: Confirmation
    Backend-->>UI: Task Created
    UI-->>User: Task Creation Confirmation

    User->>UI: View Task Details
    UI->>Backend: Fetch Task Details
    Backend->>DB: Retrieve Task Data
    DB-->>Backend: Task Data (including consensusJobPerSegment)
    Backend-->>UI: Task Details
    UI-->>User: Display Task Details

Poem

In code's vast realm, where logic flows,
New fields sprout, like springtime shows. 🌸
Consensus jobs now take their place,
Each segment finds its rightful space.
Source IDs link the tasks anew,
A seamless dance, both old and true. 💻
In CVAT's heart, the changes bloom,
Enhancing tasks, dispelling gloom. 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Viditagarwal7479 Viditagarwal7479 marked this pull request as draft May 31, 2024 11:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ab636fb and 6c2fe19.

Files selected for processing (22)
  • cvat-core/src/server-response-types.ts (2 hunks)
  • cvat-core/src/session-implementation.ts (1 hunks)
  • cvat-core/src/session.ts (6 hunks)
  • cvat-sdk/cvat_sdk/core/proxies/tasks.py (2 hunks)
  • cvat-ui/src/actions/tasks-actions.ts (2 hunks)
  • cvat-ui/src/components/create-task-page/advanced-configuration-form.tsx (4 hunks)
  • cvat/apps/dataset_manager/bindings.py (2 hunks)
  • cvat/apps/dataset_manager/project.py (1 hunks)
  • cvat/apps/dataset_manager/task.py (1 hunks)
  • cvat/apps/engine/admin.py (1 hunks)
  • cvat/apps/engine/backup.py (1 hunks)
  • cvat/apps/engine/migrations/0079_job_source_job_id_task_consensus_job_per_segment.py (1 hunks)
  • cvat/apps/engine/migrations/0080_alter_job_source_job_id.py (1 hunks)
  • cvat/apps/engine/migrations/0081_alter_job_source_job_id.py (1 hunks)
  • cvat/apps/engine/migrations/0082_alter_task_consensus_job_per_segment.py (1 hunks)
  • cvat/apps/engine/migrations/0083_alter_task_consensus_job_per_segment.py (1 hunks)
  • cvat/apps/engine/migrations/0084_remove_task_consensus_job_per_segment_and_more.py (1 hunks)
  • cvat/apps/engine/migrations/0085_alter_data_consensus_job_per_segment.py (1 hunks)
  • cvat/apps/engine/migrations/0086_alter_data_consensus_job_per_segment.py (1 hunks)
  • cvat/apps/engine/models.py (2 hunks)
  • cvat/apps/engine/serializers.py (9 hunks)
  • cvat/apps/engine/task.py (1 hunks)
Files skipped from review due to trivial changes (9)
  • cvat/apps/dataset_manager/project.py
  • cvat/apps/engine/backup.py
  • cvat/apps/engine/migrations/0079_job_source_job_id_task_consensus_job_per_segment.py
  • cvat/apps/engine/migrations/0080_alter_job_source_job_id.py
  • cvat/apps/engine/migrations/0081_alter_job_source_job_id.py
  • cvat/apps/engine/migrations/0082_alter_task_consensus_job_per_segment.py
  • cvat/apps/engine/migrations/0083_alter_task_consensus_job_per_segment.py
  • cvat/apps/engine/migrations/0085_alter_data_consensus_job_per_segment.py
  • cvat/apps/engine/migrations/0086_alter_data_consensus_job_per_segment.py
Additional comments not posted (27)
cvat/apps/engine/migrations/0084_remove_task_consensus_job_per_segment_and_more.py (2)

13-16: The removal of the consensus_job_per_segment field from the task model is correctly implemented.


17-21: The addition of the consensus_job_per_segment field to the data model with a default value and allowing blank entries is correctly implemented.

cvat/apps/engine/admin.py (1)

62-62: The addition of consensus_job_per_segment to the DataAdmin fields and marking it as read-only is correctly implemented.

cvat-ui/src/actions/tasks-actions.ts (2)

216-216: Initialization of consensus_job_per_segment with a default value of 0 in the task creation description is correctly implemented.


255-257: The conditional setting of consensus_job_per_segment based on user input is correctly implemented.

cvat-core/src/server-response-types.ts (2)

123-123: The addition of consensus_job_per_segment to the SerializedTask interface is correctly implemented.


150-150: The addition of source_job_id to the SerializedJob interface, allowing both number and null, is correctly implemented.

cvat-sdk/cvat_sdk/core/proxies/tasks.py (1)

Line range hint 81-99: The addition of consensus_job_per_segment with a default value of 0 in the upload_data method, and its inclusion in the keep list for data filtering, is correctly implemented.

cvat-ui/src/components/create-task-page/advanced-configuration-form.tsx (2)

52-52: The addition of the optional consensusJobPerSegment field to the AdvancedConfiguration interface is correctly implemented.


330-337: The implementation of the renderConsensusJobPerSegment method, including validation for non-negative integers and its placement in the form, is correctly implemented.

cvat-core/src/session-implementation.ts (1)

486-486: The addition of consensus_job_per_segment to the task specification is correctly implemented.

Verification successful

The addition of consensus_job_per_segment is correctly handled in various parts of the system, including tasks-actions.ts, session.ts, session-implementation.ts, and server-response-types.ts.

  • cvat-ui/src/actions/tasks-actions.ts:
    • Line: consensus_job_per_segment: 0,
    • Line: description.consensus_job_per_segment = data.advanced.consensusJobPerSegment;
  • cvat-core/src/session.ts:
    • Line: consensus_job_per_segment: undefined,
    • Line: get: () => data.consensus_job_per_segment,
  • cvat-core/src/session-implementation.ts:
    • Line: consensus_job_per_segment: this.consensusJobPerSegment,
  • cvat-core/src/server-response-types.ts:
    • Line: consensus_job_per_segment: number;
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `consensus_job_per_segment` is correctly handled in all related parts of the system.

# Test: Search for the usage of `consensus_job_per_segment` in the TypeScript files.
rg --type typescript $'consensus_job_per_segment'

Length of output: 83



Script:

#!/bin/bash
# Description: Verify that `consensus_job_per_segment` is correctly handled in all related parts of the system.

# Test: Search for the usage of `consensus_job_per_segment` in all TypeScript files.
rg 'consensus_job_per_segment' --glob '*.ts'

Length of output: 599

cvat/apps/dataset_manager/task.py (1)

733-733: Ensure proper filtering of jobs based on source_job_id.

This change correctly implements the filtering of annotation jobs to exclude those that are sourced from other jobs, aligning with the new functionality for consensus jobs.

cvat/apps/engine/models.py (2)

235-235: Ensure the default value for consensus_job_per_segment aligns with system requirements.

Verification successful

The default value for consensus_job_per_segment is consistently set to 0 across the codebase.

  • cvat/apps/engine/models.py: consensus_job_per_segment = models.IntegerField(default=0, blank=True)
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the default value of 0 for consensus_job_per_segment is consistent across all related files.

# Test: Search for the default value across all Python files. Expect: Consistent default value of 0.
rg --type python 'consensus_job_per_segment' --files-with-matches | xargs rg 'default=0'

Length of output: 5318


681-681: Check if allowing null for source_job_id aligns with the data integrity requirements of the system.

Verification successful

Allowing null for source_job_id aligns with the data integrity requirements of the system.

The search results indicate that source_job_id is used in various parts of the codebase, including models, serializers, and migrations. Specifically, the following points are noteworthy:

  • In cvat/apps/engine/models.py, source_job_id is defined as null=True, blank=True, default=None.
  • In cvat/apps/engine/serializers.py, source_job_id is a ReadOnlyField with allow_null=True.
  • In cvat/apps/dataset_manager/task.py, there is an instance where source_job_id is explicitly set to None.

These points suggest that the system is designed to handle null values for source_job_id, and this is consistent across the codebase.

  • cvat/apps/engine/models.py
  • cvat/apps/engine/serializers.py
  • cvat/apps/dataset_manager/task.py
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that allowing null values for source_job_id is consistent and necessary across the system.

# Test: Search for the usage of source_job_id in Python files. Expect: Proper handling of null values.
rg --type python 'source_job_id' --files-with-matches | xargs rg 'if.*source_job_id'

Length of output: 115



Script:

#!/bin/bash
# Description: Verify that allowing null values for source_job_id is consistent and necessary across the system.

# Test: Search for the usage of source_job_id in Python files. Expect: Proper handling of null values.
rg --type py 'source_job_id' --files-with-matches | xargs rg 'if.*source_job_id'

Length of output: 80



Script:

#!/bin/bash
# Description: Gather more information about the usage and constraints of source_job_id.

# Search for all occurrences of source_job_id in the codebase.
rg --type py 'source_job_id'

# Check for any related database constraints or migrations.
fd -e sql -e py | xargs rg 'source_job_id'

Length of output: 2725

cvat-core/src/session.ts (5)

457-457: Addition of source_job_id to the Job class.

This change aligns with the PR's objective to track the source job of a task, facilitating the creation of consensus jobs.


592-594: Getter for source_job_id in the Job class.

Proper encapsulation of source_job_id with a getter ensures that the property is accessed in a controlled manner, which is a good practice in object-oriented programming.


674-674: Addition of consensusJobPerSegment to the Task class.

This addition supports the new functionality of handling consensus jobs per segment, as described in the PR summary.


729-729: Initialization of consensus_job_per_segment in the Task constructor.

Initializing this property in the constructor ensures that it is set up correctly when an instance of Task is created.


915-917: Getter for consensusJobPerSegment in the Task class.

The implementation of a getter for consensusJobPerSegment follows best practices for data encapsulation and provides a clean API for accessing this property.

cvat/apps/dataset_manager/bindings.py (2)

678-678: Ensure proper handling of source_job_id in the metadata.

Verification successful

Ensure proper handling of source_job_id in the metadata.

  • cvat/apps/engine/serializers.py: source_job_id is defined as a ReadOnlyField.
  • cvat/apps/engine/models.py: source_job_id is defined as a PositiveIntegerField.
  • cvat/apps/engine/task.py: source_job_id is used in the Job model.
  • cvat/apps/dataset_manager/task.py: source_job_id is used in a query filter.
  • cvat/apps/dataset_manager/bindings.py: source_job_id is included in the metadata.

These usages indicate that source_job_id is properly handled in the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `source_job_id` is properly handled in all relevant places.

# Test: Search for the usage of `source_job_id`. Expect: Proper handling in all relevant places.
rg --type python $'source_job_id'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify that `source_job_id` is properly handled in all relevant places.

# Test: Search for the usage of `source_job_id`. Expect: Proper handling in all relevant places.
rg 'source_job_id' --glob '*.py'

Length of output: 1359


783-783: Ensure consensus_job_per_segment is properly integrated and used where necessary.

Verification successful

Ensure consensus_job_per_segment is properly integrated and used where necessary.

The search results indicate that consensus_job_per_segment is indeed integrated and used in various parts of the codebase, including serializers, models, migrations, and other modules.

  • Serializers: cvat/apps/engine/serializers.py
  • Task Processing: cvat/apps/engine/task.py
  • Backup: cvat/apps/engine/backup.py
  • Admin: cvat/apps/engine/admin.py
  • Models: cvat/apps/engine/models.py
  • Migrations: Multiple migration files
  • Project Management: cvat/apps/dataset_manager/project.py
  • Bindings: cvat/apps/dataset_manager/bindings.py
  • UI Actions: cvat-ui/src/actions/tasks-actions.ts
  • Core Session: cvat-core/src/session.ts, cvat-core/src/session-implementation.ts
  • Server Response Types: cvat-core/src/server-response-types.ts
  • SDK Proxies: cvat-sdk/cvat_sdk/core/proxies/tasks.py

Given the extensive integration across different modules, it appears that consensus_job_per_segment is properly integrated and used where necessary.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `consensus_job_per_segment` is properly integrated and used where necessary.

# Test: Search for the usage of `consensus_job_per_segment`. Expect: Proper integration and usage in all relevant places.
rg --type python $'consensus_job_per_segment'

Length of output: 75



Script:

#!/bin/bash
# Description: Verify that `consensus_job_per_segment` is properly integrated and used where necessary.

# Test: Search for the usage of `consensus_job_per_segment`. Expect: Proper integration and usage in all relevant places.
rg 'consensus_job_per_segment'

Length of output: 4002

cvat/apps/engine/serializers.py (6)

596-596: Addition of source_job_id field in JobReadSerializer.

This field addition aligns with the PR's objective to support job sourcing functionalities.


968-971: Addition of consensus_job_per_segment field in DataSerializer.

This field supports the new functionality for consensus jobs per segment, which is crucial for the task segmentation feature.


1104-1104: Addition of consensus_job_per_segment field in TaskReadSerializer.

Proper integration of the new field to support consensus job configurations at the task level.


1129-1129: Addition of consensus_job_per_segment field in TaskWriteSerializer.

This addition allows setting the consensus job per segment during task creation or update, which is essential for the new functionality.


1195-1195: Handling of consensus_job_per_segment in the update method of TaskWriteSerializer.

Proper handling of the new field during the update operations, ensuring that the consensus job settings are preserved or updated correctly.


Line range hint 1456-1470: Addition of consensus_job_per_segment field in DataMetaReadSerializer.

The field is correctly added to support reading consensus job configurations, which is necessary for proper data management and operations.

cvat/apps/engine/task.py Outdated Show resolved Hide resolved
@Viditagarwal7479
Copy link
Contributor Author

In the above commit itself, I have added the constraint on the value of consensus jobs, [0, 10] - {1}.

@Viditagarwal7479
Copy link
Contributor Author

Viditagarwal7479 commented Jun 8, 2024

List of features added in this PR

  1. Separate collapsable menu for setting consensus_job_per_segement and agreement_score_threshold while creating the task. Both have default value as 0.
image image
  1. Task having consensus jobs have a additional tag in their task name as "Consensus Based Annotation"
  2. agreement_score_threshold parameter can be changed after task is created
  3. Consensus jobs corresponding are in a collapsed view under their parent job, with the number of consensus jobs mentioned
image image
  1. api/jobs?parent_job_id={id} added additional filter option to filter out consensus jobs in corresponding to the parent_job_id
  2. Added frontend side and server side validation for these newly added parameters. consensus_job_per_segment (Integer) [0, 10] - {1} and agreement_score_threshold (floating point) [0,1]
  3. Annotations made in consensus jobs aren't included in the annotation export of the task and the task backup. Though they can be exported individually.
  4. These newly added paramterers are shown appropriately in GET request when for task and job details, PATCH request when creating and updating the task, while updating task only agreement_score_threshold can be adjusted among the newly added parameters

Copy link

sonarcloud bot commented Jun 12, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@Viditagarwal7479
Copy link
Contributor Author

Quality Gate Failed Quality Gate failed

Failed conditions 3.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

On going through its detailed analysis, I also don't seem to find any redundant code block that can be removed.

cvat-sdk/cvat_sdk/core/proxies/tasks.py Outdated Show resolved Hide resolved
cvat/apps/dataset_manager/bindings.py Outdated Show resolved Hide resolved
cvat/apps/dataset_manager/task.py Outdated Show resolved Hide resolved
cvat/apps/engine/serializers.py Outdated Show resolved Hide resolved
@@ -677,6 +679,7 @@ class Job(TimestampedModel):

type = models.CharField(max_length=32, choices=JobType.choices(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a new job type in the enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we would also have to check that that there isn't any logic based on job type due to which the consensus job doesn't work properly.

Like some functionalities which it exhibited since it was inheriting the job type, would now not work, and break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Despite that, shouldn't the job type structure look like this?

  • Job Types
    • Ground Truth
    • Annotation
      • Normal Job
      • Consensus Job

And inevitably the information about whether it's a normal or consensus job is present in parameter parent_job_id...?

Copy link
Contributor

Choose a reason for hiding this comment

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

Despite that, shouldn't the job type structure look like this? [...]

I don't see a point in making such a nested structure at this point. The consensus jobs are not the same as annotation jobs, they have different handling logic in annotation import and export. Probably, they should not be included in the task quality report. It's better to just keep the type list flat, unless there is a clear use case for such a structure.

But then we would also have to check that that there isn't any logic based on job type due to which the consensus job doesn't work properly.
Like some functionalities which it exhibited since it was inheriting the job type, would now not work, and break?

You would need to check this in any case, as these jobs aren't the same as "normal" jobs.

cvat/apps/engine/models.py Outdated Show resolved Hide resolved
@Viditagarwal7479 Viditagarwal7479 changed the base branch from develop to gsoc/consensus-feature June 20, 2024 14:28
@@ -92,7 +92,7 @@ function validateURL(_: RuleObject, value: string): Promise<void> {
return Promise.resolve();
}

const isInteger = ({ min, max }: { min?: number; max?: number }) => (
const isInteger = ({ min, max, toBeSkipped }: { min?: number; max?: number; toBeSkipped?: number }) => (
Copy link
Contributor

@zhiltsov-max zhiltsov-max Jun 27, 2024

Choose a reason for hiding this comment

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

Consider renaming the isInteger function or adding another validator that checks for specific values. toBeSkipped can be renamed to excluded for better readability.

Copy link
Contributor Author

@Viditagarwal7479 Viditagarwal7479 Jun 27, 2024

Choose a reason for hiding this comment

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

With this, the functionality is added with minimal modifications, and the function gets reused in consensus-configuration. The existing function also checks for the range along with whether it's an integer, as the function's name suggests...

Copy link
Contributor

Choose a reason for hiding this comment

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

This is clear, but now the function does something that is not explicitly reflected in its name. It can be confusing and unexpected to other people editing this code.

@@ -1119,12 +1122,13 @@ class TaskWriteSerializer(WriteOnceMixin, serializers.ModelSerializer):
project_id = serializers.IntegerField(required=False, allow_null=True)
target_storage = StorageSerializer(required=False, allow_null=True)
source_storage = StorageSerializer(required=False, allow_null=True)
consensus_jobs_per_segment = serializers.IntegerField(required=False)
Copy link
Contributor

@zhiltsov-max zhiltsov-max Jun 27, 2024

Choose a reason for hiding this comment

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

Typically, it's nice to set the default value to 0 or none for such optional parameters. You can see how we use allow_null for other parameters here. This simplifies calling of such APIs in various SDKs and API clients.

@@ -1891,6 +1891,11 @@ paths:
enum:
Copy link
Contributor

@zhiltsov-max zhiltsov-max Jun 27, 2024

Choose a reason for hiding this comment

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

Probably, this file needs to be updated to reflect the latest changes. I can see some added parameters are missing.

const { task: taskInstance, onUpdateTask } = this.props;
const taskName = name + (consensusJobsPerSegment > 0 ? ' (Consensus Based Annotation)' : '');
Copy link
Contributor

@zhiltsov-max zhiltsov-max Jun 27, 2024

Choose a reason for hiding this comment

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

I suggest that the task name is not modified, and an icon or a tag is shown instead. Take for example the "Ground Truth" label on GT jobs.

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.

None yet

4 participants