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

Add docker image uploading #2013

Merged
merged 28 commits into from
Feb 8, 2024
Merged

Add docker image uploading #2013

merged 28 commits into from
Feb 8, 2024

Conversation

evanyeyeye
Copy link
Member

@evanyeyeye evanyeyeye commented Nov 19, 2023

Summary

Summary generated by Reviewpad on 29 Jan 24 23:11 UTC

This pull request includes the following changes:

  1. Addition of a new file dockers_controller.rb in the app/controllers directory.
  2. Modification in the existing file assessment_autograde_core.rb in the app/helpers directory.
  3. Modification in the existing file index.html.erb in the app/views/assessments directory.
  4. Modification in the existing file _form.html.erb in the app/views/autograders directory.
  5. Addition of a new file index.html.erb in the app/views/dockers directory.
  6. Modification in the existing file development.rb in the config/environments directory.
  7. Modification in the existing file production.rb.template in the config/environments directory.
  8. Modification in the existing file test.rb in the config/environments directory.
  9. Modification in the existing file routes.rb in the config directory.
  10. Modification in the existing file tango_client.rb in the lib directory.

Please refer to the diff for more details.

Description

How Has This Been Tested?

With both local and docker installs:

  1. Add an assessment that uses a docker image (created by docker save) not yet used by Tango.
  2. Confirm that attempting to autograde a submission will cause an error due to the missing image.
  3. Upload the docker image using the new upload docker image page.
  4. Confirm that autograding submissions on that assessment now works.

Types of changes

  • New feature (non-breaking change which adds functionality)

Copy link
Contributor

coderabbitai bot commented Nov 19, 2023

Warning

Rate Limit Exceeded

@evanyeyeye has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 7 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between e7bd58d and cff96fc.

Walkthrough

The overall change introduces a feature for uploading Docker images, controlled by a feature flag across different environments. It modifies views to conditionally display links for Docker image upload based on the feature's enablement status. Additionally, a new controller and view are added to handle the Docker image upload process, with environment-specific configurations determining the feature's availability.

Changes

File Path Change Summary
.../autograders/_form.html.erb Modified autograde_image field's help text to include conditional link for Docker image upload.
.../courses/manage.html.erb Added conditional block for Docker image upload link based on feature flag.
config/environments/development.rb, .../production.rb.template, .../test.rb Added docker_image_upload_enabled feature flag with environment-specific values.
app/controllers/dockers_controller.rb New controller to manage Docker image uploads with access control.
app/views/dockers/index.html.erb New view for Docker image upload form, allowing users to input image name and select file to upload.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@reviewpad reviewpad bot requested a review from najclark November 19, 2023 02:48
@reviewpad reviewpad bot added small Pull request is small waiting-for-review labels Nov 19, 2023
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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4dacaf1 and 8d53673.
Files selected for processing (7)
  • app/controllers/dockers_controller.rb (1 hunks)
  • app/helpers/assessment_autograde_core.rb (1 hunks)
  • app/views/assessments/index.html.erb (1 hunks)
  • app/views/autograders/_form.html.erb (1 hunks)
  • app/views/dockers/index.html.erb (1 hunks)
  • config/routes.rb (1 hunks)
  • lib/tango_client.rb (1 hunks)
Files skipped from review due to trivial changes (3)
  • app/helpers/assessment_autograde_core.rb
  • app/views/assessments/index.html.erb
  • app/views/autograders/_form.html.erb
Additional comments: 1
config/routes.rb (1)
  • 104-107: The new routes for the dockers resource are correctly defined for the index and uploadDockerImage actions. The index action is associated with a GET request, and the uploadDockerImage action is associated with a POST request, which is appropriate for file uploads. Ensure that the corresponding controller actions are properly secured to prevent unauthorized access, especially since this involves uploading Docker images which could potentially be a security risk if not handled correctly.

lib/tango_client.rb Outdated Show resolved Hide resolved
app/views/dockers/index.html.erb Outdated Show resolved Hide resolved
app/controllers/dockers_controller.rb Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8d53673 and c954d11.
Files selected for processing (1)
  • app/controllers/dockers_controller.rb (1 hunks)

app/controllers/dockers_controller.rb Outdated Show resolved Hide resolved
@damianhxy damianhxy linked an issue Nov 27, 2023 that may be closed by this pull request
@cg2v
Copy link
Member

cg2v commented Dec 1, 2023

This PR is not currently suitable for an autolab instance shared among multiple courses, since any instructor (in practice, many TAs) can overwrite any image (including those used by other courses/assessments)

Copy link
Contributor

@najclark najclark left a comment

Choose a reason for hiding this comment

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

Changes look good. I agree with @cg2v, it might be good to allow someone to specify the filename the image should be saved with.

app/helpers/assessment_autograde_core.rb Outdated Show resolved Hide resolved
app/views/assessments/index.html.erb Outdated Show resolved Hide resolved
@damianhxy
Copy link
Member

This PR is not currently suitable for an autolab instance shared among multiple courses, since any instructor (in practice, many TAs) can overwrite any image (including those used by other courses/assessments)

Maybe the best way to go about it is to hide this behind a feature flag for now?

I'm not sure how we can make this suitable for an instance shared among multiple courses. We could make it such that only the course that uploaded an image can overwrite it (by tracking it somehow), but we might also want to share the same image across iterations of a course.

app/views/autograders/_form.html.erb Outdated Show resolved Hide resolved
lib/tango_client.rb Outdated Show resolved Hide resolved
app/views/assessments/index.html.erb Outdated Show resolved Hide resolved
app/views/assessments/index.html.erb Outdated Show resolved Hide resolved
Copy link
Member

@damianhxy damianhxy left a comment

Choose a reason for hiding this comment

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

Blocking until filename can be specified and nits (typos) are resolved

app/views/dockers/index.html.erb Outdated Show resolved Hide resolved
app/views/dockers/index.html.erb Outdated Show resolved Hide resolved
app/controllers/dockers_controller.rb Show resolved Hide resolved
app/controllers/dockers_controller.rb Outdated Show resolved Hide resolved
app/controllers/dockers_controller.rb Show resolved Hide resolved
Copy link
Member

@damianhxy damianhxy left a comment

Choose a reason for hiding this comment

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

LGTM

@evanyeyeye evanyeyeye added this pull request to the merge queue Feb 8, 2024
Merged via the queue into master with commit 78f0a99 Feb 8, 2024
6 checks passed
@evanyeyeye evanyeyeye deleted the docker-upload branch February 8, 2024 07:30
KesterTan pushed a commit that referenced this pull request Feb 26, 2024
* Start frontend for docker upload

* Some fixes

* Typo fixes

* Modify post request to build

* Add error message for failed image uploads

* Add success message

* Add link to upload from edit assessment view

* Add link to view all pools on upload page

* Fix rubocop complaints

* Change content type to standard MIME type

* Fix erblint complaints

* Change button name

* Remove newline

* Add feature flag

* Add name specification for docker images, add to feature flag, and fix nits

* Add feature flag for test env

* Move button to manage course page

* Move feature flag to config.x namespace and fix syntax error

* Address issues with dockers_controller.rb

* Fix regex pattern in dockers controller

* Add frontend pattern

* Fix truthy config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Pull request is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add interface to upload docker files / images
4 participants