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

feat: Add a new published job stage #8018

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

Conversation

likelikeslike
Copy link

@likelikeslike likelikeslike commented Jun 12, 2024

We added a new stage for Job in CVAT called published, which allows users to make one Job accessible to all members of their organization.

Motivation and context

First, thank you for the amazing project that has significantly helped us with our annotation program.

In our work, we encountered a problem: we want to provide annotation examples for new annotators to help them understand the annotation standards easily. However, with the current CVAT design, the only way to do this is by duplicating several Tasks and assigning each one to an annotator. While this method achieves our goal, it is not that convenient, and there is a risk that the annotators might accidentally change the pre-annotated examples.

Our ideal solution is that each annotator can share a single Job where they can only add comments by opening an Issue.

To achieve this, we added a new stage for Job, called published. If we change a Job to the published stage, any annotator with the link to this Job can view it and add comments.

How has this been tested?

Yes, we followed the Development environment guidelines and tested it on Ubuntu 22.04. The results were as we expected.

However, due to our limited knowledge of this project, we made the changes as minor as possible. We may also need your help to make this PR more useful in the future.

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 job stage, Published, to the application.
    • Added the ability to publish jobs, making them accessible to all organization members.
    • Updated filter options and configurations to include the new Published stage.
    • Enhanced the task progress bar to reflect the new Published stage.
  • Bug Fixes

    • Adjusted access control logic to handle the new Published job stage.
  • Documentation

    • Updated user manuals to include information about the new Published job stage and its impact on the annotation interface and task progress bar.

 - All organization members can view the published jobs, but cannot make revision.
 - All organization members can open issue on the published jobs.
Copy link
Contributor

coderabbitai bot commented Jun 12, 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 recent updates introduce a new PUBLISHED stage to the CVAT platform, affecting job management, UI components, access control, and documentation. This new stage allows jobs to be marked as published, making them accessible to all organization members. The changes span across core enums, UI elements, backend models, permissions, and documentation, enhancing the workflow and visibility of job statuses.

Changes

Files/Paths Summary of Changes
cvat-core/src/enums.ts Added PUBLISHED to JobStage enum.
cvat-ui/src/components/.../job-list.tsx, job-item.tsx, jobs-filter-configuration.ts, task-quality/job-list.tsx Added published option to filter dropdowns and job stages.
cvat-ui/src/components/annotation-page/top-bar/annotation-menu.tsx, job-item/job-actions-menu.tsx Added PUBLISH_JOB action and publishJob function to handle job publishing logic.
cvat/apps/engine/models.py Added PUBLISHED to StageChoice enum and updated with_job_summary function.
cvat/apps/engine/permissions.py Added handling for stage attribute in JSON responses.
cvat/apps/engine/rules/issues.rego, jobs.rego Added is_job_published condition for access control based on job stage.
cvat/apps/engine/serializers.py Modified update method to set status to COMPLETED when stage is PUBLISHED.
cvat/schema.yml Added published to various schema components.
site/content/en/docs/manual/... Updated documentation to include the new PUBLISHED stage and its impact on job and task workflows.

Poem

In the land of CVAT, jobs now shine bright,
Published and completed, a new stage in sight.
From enums to filters, and menus anew,
Permissions and models, all got a view.
A platform enhanced, with stages now four,
For tasks and for jobs, efficiency soars.
🎉✨📜


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.

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: 2

Outside diff range and nitpick comments (1)
site/content/en/docs/manual/basics/task-details.md (1)

Line range hint 47-47: Consider adding a comma before 'and' for better readability.

- Other frames will be loaded and you will be able to annotate first images.
+ Other frames will be loaded, and you will be able to annotate first images.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 14b65ac and a81d65d.

Files selected for processing (17)
  • cvat-core/src/enums.ts (1 hunks)
  • cvat-ui/src/components/analytics-page/task-quality/job-list.tsx (1 hunks)
  • cvat-ui/src/components/annotation-page/top-bar/annotation-menu.tsx (3 hunks)
  • cvat-ui/src/components/job-item/job-actions-menu.tsx (2 hunks)
  • cvat-ui/src/components/job-item/job-item.tsx (1 hunks)
  • cvat-ui/src/components/jobs-page/jobs-filter-configuration.ts (1 hunks)
  • cvat-ui/src/components/task-page/jobs-filter-configuration.ts (1 hunks)
  • cvat/apps/engine/models.py (2 hunks)
  • cvat/apps/engine/permissions.py (2 hunks)
  • cvat/apps/engine/rules/issues.rego (6 hunks)
  • cvat/apps/engine/rules/jobs.rego (3 hunks)
  • cvat/apps/engine/serializers.py (1 hunks)
  • cvat/schema.yml (2 hunks)
  • site/content/en/docs/manual/advanced/iam_user_roles.md (1 hunks)
  • site/content/en/docs/manual/basics/CVAT-annotation-Interface/navbar.md (1 hunks)
  • site/content/en/docs/manual/basics/task-details.md (1 hunks)
  • site/content/en/docs/manual/basics/vocabulary.md (1 hunks)
Files skipped from review due to trivial changes (4)
  • cvat-core/src/enums.ts
  • cvat-ui/src/components/analytics-page/task-quality/job-list.tsx
  • cvat-ui/src/components/job-item/job-item.tsx
  • cvat-ui/src/components/task-page/jobs-filter-configuration.ts
Additional context used
LanguageTool
site/content/en/docs/manual/basics/task-details.md

[uncategorized] ~45-~45: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...u can have several links. It depends on size of your task and Overlap Size and `Se...


[uncategorized] ~47-~47: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ...t chunk of several frames will be loaded and you will be able to annotate first imag...


[uncategorized] ~48-~48: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ... images. Other frames will be loaded in background.

site/content/en/docs/manual/basics/vocabulary.md

[duplication] ~7-~7: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...rtaining to annotation in CVAT.' --- ## Label Label is a type of an annotated object (e.g. ...


[grammar] ~8-~8: If ‘type’ is a classification term, ‘an’ is not necessary. Use “type of”. (The phrases ‘kind of’ and ‘sort of’ are informal if they mean ‘to some extent’.) (KIND_OF_A)
Context: ...ation in CVAT.' --- ## Label Label is a type of an annotated object (e.g. person, car, veh...


[duplication] ~14-~14: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...](/images/image032_detrac.jpg) --- ## Attribute Attribute is a property of an annotated object (e...


[duplication] ~18-~18: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...There are two types of attributes: ### Unique Unique immutable and can't be changed from fra...


[duplication] ~23-~23: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...etc.) ### Temporary Temporary mutable and can be changed on any frame...


[duplication] ~30-~30: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...) --- ## Track Track is a set of shapes on different frames ...


[duplication] ~38-~38: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ... --- ## Annotation Annotation is a set of shapes and tracks. There ar...


[duplication] ~47-~47: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...y without a person in the loop --- ## Approximation Approximation allows you to reduce the number of poin...


[style] ~48-~48: To form a complete sentence, be sure to include a subject. (MISSING_IT_THERE)
Context: ...ce the number of points in the polygon. Can be used to reduce the annotation file a...


[duplication] ~55-~55: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...es/approximation_accuracy.gif) --- ## Trackable Trackable object will be tracked automatically if...


[grammar] ~56-~56: Use “the” before the superlative. (THE_SUPERLATIVE)
Context: ...automatically if the previous frame was a latest keyframe for the object. More de...


[grammar] ~82-~82: It appears that a pronoun is missing. (SENT_START_DEPENDS)
Context: ...s" "Shape mode" >}} --- ## Dimension Depends on the task data type that is defined w...


[grammar] ~88-~88: Did you mean “2D”(= two-dimensional) or “2nd” (= second)? (THREE_D)
Context: ...eated" >}}. ### 2D The data format of 2d tasks are images and videos. Related se...


[grammar] ~94-~94: Did you mean “3D”(= three-dimensional) or “3rd” (= third)? (THREE_D)
Context: ...n task" >}} ### 3D The data format of 3d tasks is a cloud of points. {{< ilink "...


[duplication] ~104-~104: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...on" "3D Object annotation" >}} --- ## State State of the job. The state can be changed by...


[duplication] ~111-~111: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...ess, rejected, completed`. --- ## Stage Stage of the job. The stage is specified with...


[typographical] ~114-~114: Two consecutive dots (DOUBLE_PUNCTUATION)
Context: ...validation, acceptanceorpublished`.. This value affects the task progress ba...

site/content/en/docs/manual/advanced/iam_user_roles.md

[uncategorized] ~16-~16: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...determining the visibility of different resources for example, tasks or jobs. Limits...


[style] ~29-~29: Consider shortening or rephrasing this to strengthen your wording. (MAKE_CHANGES)
Context: ...policy-language/). > Note: Once you've made changes to the .rego files, you must > rebuild a...


[uncategorized] ~73-~73: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...on and assign roles to the invited users so the team can collaborate. | | **Maintai...


[uncategorized] ~74-~74: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ... see all tasks within the organization. Maintainer has complete access to Cloud Storages, ...

site/content/en/docs/manual/basics/CVAT-annotation-Interface/navbar.md

[style] ~35-~35: Consider an alternative to strengthen your wording. (CHANGES_ADJUSTMENTS)
Context: ...en finished, reviewed, and approved. No further changes are necessary.

    | | **Finish the jo...


    [typographical] ~84-~84: Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
    Context: .... For more information, see Manual QA

  • Start frame - the number o...

Additional comments not posted (23)
site/content/en/docs/manual/basics/task-details.md (1)

30-30: The addition of 'published' to the job stages is clear and integrates well with the existing content.

cvat-ui/src/components/jobs-page/jobs-filter-configuration.ts (1)

35-35: The addition of 'published' to the job stage filter options is correctly implemented.

cvat-ui/src/components/job-item/job-actions-menu.tsx (1)

72-75: The addition of the 'publish_job' action is correctly implemented and integrates well with the existing menu structure.

Also applies to: 89-89

cvat/apps/engine/rules/issues.rego (6)

57-59: The is_job_published function correctly checks if a job's stage is published. Ensure this function is utilized appropriately in permission checks.


39-39: Ensure the new published stage is consistently handled across all relevant policies.

Verification successful

The search results indicate that the published stage is consistently handled across various files, including policy files, schema definitions, and UI components. This suggests that the new published stage is integrated properly throughout the codebase.

  • cvat/apps/engine/rules/jobs.rego: Multiple references to the published stage.
  • cvat/apps/engine/rules/issues.rego: Multiple references to the published stage.
  • cvat/schema.yml: Definitions including the published stage.
  • cvat/apps/engine/models.py: Definition of the PUBLISHED constant.
  • Various UI components and documentation files also reference the published stage.

This comprehensive handling confirms that the published stage is consistently integrated.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the 'published' stage is handled in all relevant policy files.

# Test: Search for handling of 'published' stage in other policy files. Expect: Consistent handling across files.
rg --type rego 'published'

Length of output: 55



Script:

#!/bin/bash
# Description: Verify that the 'published' stage is handled in all relevant policy files.

# Test: Search for handling of 'published' stage in all files. Expect: Consistent handling across files.
rg 'published'

Length of output: 2383


283-289: This rule allows deleting issues if the job is published. Confirm that deletion policies are adhered to and that no critical data is lost.


261-266: This rule allows updating issues if the job is published. Ensure that only authorized modifications are permitted.


239-244: This rule allows viewing issues if the job is published. Verify that this does not inadvertently expose sensitive data.

Verification successful

The is_job_published function checks if the job's stage is "published". The allow if rules in cvat/apps/engine/rules/issues.rego include multiple conditions for different scopes, ensuring that only authorized users can view, create, update, or delete issues.

The specific rule in question allows viewing issues if the job is published and the user is a member of the organization. This rule does not seem to expose sensitive data inadvertently, as it still requires the user to be a member of the organization.

  • is_job_published function:

    is_job_published if {
        input.resource.job.stage == "published"
    }
  • Relevant allow if rule:

    allow if {
        input.scope == utils.VIEW
        input.auth.organization.id == input.resource.organization.id
        organizations.is_member
        is_job_published
    }

Based on this, the rule appears to be correctly scoped and does not expose sensitive data.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for potential data exposure in viewing issues of published jobs.

# Test: Review logs and access records for unauthorized data access attempts. Expect: No unauthorized access.
cat logs/access.log | grep 'published'

Length of output: 86



Script:

#!/bin/bash
# Search for the implementation of the `is_job_published` function in the codebase.
ast-grep --lang rego --pattern 'is_job_published { $$$ }'

# Search for other rules related to viewing issues in the codebase.
ast-grep --lang rego --pattern 'allow if { $$$ }'

Length of output: 329



Script:

#!/bin/bash
# Search for the implementation of the `is_job_published` function in the codebase.
rg 'is_job_published' --glob '*.rego'

# Search for other rules related to viewing issues in the codebase.
rg 'allow if' --glob '*.rego'

Length of output: 10409



Script:

#!/bin/bash
# Extract the implementation of the `is_job_published` function from cvat/apps/engine/rules/issues.rego.
sed -n '/is_job_published if {/,/}/p' cvat/apps/engine/rules/issues.rego

# Extract the `allow if` rules from cvat/apps/engine/rules/issues.rego.
sed -n '/allow if {/,/}/p' cvat/apps/engine/rules/issues.rego

Length of output: 2709


155-160: This rule allows issue creation if the job is published. Confirm that this aligns with organizational policies on issue visibility and creation.

cvat/apps/engine/rules/jobs.rego (3)

91-93: The is_job_published function correctly checks if a job's stage is published. Ensure this function is utilized appropriately in permission checks.


197-204: This rule allows viewing job-related data if the job is published. Confirm that this aligns with organizational policies on data visibility.


39-39: Ensure the new published stage is consistently handled across all relevant policies.

site/content/en/docs/manual/advanced/iam_user_roles.md (1)

101-101: The documentation correctly introduces the Published stage, making it accessible to all organization members. Ensure this description aligns with the actual implementation in the code.

cvat-ui/src/components/annotation-page/top-bar/annotation-menu.tsx (3)

47-47: The addition of PUBLISH_JOB to the Actions enum is consistent with the new functionality. Ensure this action is integrated properly in the UI.


118-127: The publishJob function correctly updates the job stage to PUBLISHED and the state to COMPLETED. Ensure that this change triggers appropriate updates in the UI and backend.


332-345: The UI integration of the publishJob action is well implemented, providing clear user feedback and navigation. Confirm that the modal's behavior aligns with user expectations.

site/content/en/docs/manual/basics/CVAT-annotation-Interface/navbar.md (1)

37-37: Ensure the new "Publish the job" section is clear and consistent with existing documentation.

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

93-93: The addition of the "PUBLISHED" stage to the StageChoice enum is correctly implemented.


383-389: The update to the with_job_summary method in TaskQuerySet correctly includes the "PUBLISHED" stage in job summaries.

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

946-947: Validate job stage updates correctly.

The get_resource method in the IssuePermission class includes the job's stage in the returned data. Given the new published stage introduced in the system, ensure that all necessary validations and checks are updated to handle this new stage appropriately.

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

759-760: The logic to set the job status to COMPLETED when the stage is PUBLISHED aligns with the PR's objectives. Ensure that this change does not unintentionally affect other job stages or transitions.

Verification successful

The logic to set the job status to COMPLETED when the stage is PUBLISHED aligns with the PR's objectives and does not unintentionally affect other job stages or transitions.

  • cvat/apps/engine/serializers.py: The COMPLETED status is correctly set for the PUBLISHED stage and for the ACCEPTANCE stage when the state is COMPLETED.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that no other job stages incorrectly transition to COMPLETED.

# Test: Search for job stage transitions in the application logic.
rg --type python "stage == models.StageChoice" -C 5

Length of output: 84



Script:

#!/bin/bash
# Description: Verify that no other job stages incorrectly transition to COMPLETED.

# Test: Search for job stage transitions in the application logic.
rg --type py "stage == models.StageChoice" -C 5

Length of output: 1379

cvat/schema.yml (2)

1866-1866: Addition of 'published' stage to the schema is consistent with the new feature.


7553-7559: Addition of 'published' stage to the schema is consistent with the new feature.

Verification successful

The 'published' stage appears three times in the schema file, indicating consistent usage. However, to ensure thorough verification, let's review the context around each instance to confirm they are correctly placed and aligned with the intended changes.


The 'published' stage is correctly added to the 'enum' lists and descriptions for job stages, aligning with the intended changes. The integration appears consistent and correct.

  • Lines around the first instance show 'published' added to the 'enum' list for job stages.
  • Lines around the second instance show 'published' added to the 'enum' list and description for job stages.

These changes are consistent with the schema's structure and the intended feature addition.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that 'published' stage is consistently added across all relevant parts of the schema.

# Test: Search for 'published' in the schema. Expect: Consistent usage across the file.
rg --type yaml 'published' cvat/schema.yml

Length of output: 116



Script:

#!/bin/bash
# Description: Display lines around each instance of 'published' to verify context and placement.

# Display 5 lines before and after each match
rg --type yaml -C 5 'published' cvat/schema.yml

Length of output: 690

site/content/en/docs/manual/basics/vocabulary.md Outdated Show resolved Hide resolved
cvat/apps/engine/permissions.py Show resolved Hide resolved
Copy link

sonarcloud bot commented Jun 13, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
2.6% Duplication on New Code

See analysis details on SonarCloud

@likelikeslike
Copy link
Author

Show the published jobs count in the Tasks page.

image

@likelikeslike
Copy link
Author

Hi @bsekachev, could you please take a moment to review this PR and let me know if it can be merged? Thank you!

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

1 participant