Giter VIP home page Giter VIP logo

online-judge's Introduction

Competitive Programming Initiative

We promote competitive programming among students through resources, outreach, classes, and contests.

Thanks to Vercel for providing free hosting & continuous deployment!

Development Environment Setup

Instructions (for volunteer hours -- not necessarily needed for other stuff)

  1. If not done already, clone the repository cpinitiative/cpinitiative and open up the folder.

  2. At the root directory, add a file .env, which will contain the environment configuration for the volunteer-hours. An example .env file will look like

    GOOGLE_CLIENT_ID="....apps.googleusercontent.com"
    GOOGLE_CLIENT_SECRET="asdkjflasdjfklas"
    NEXTAUTH_URL="http://localhost:3000"
    SHEETS_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..."
    SHEETS_PRIVATE_KEY_ID="1298301asfa98sf09ac0291023"
    FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..."
    ENCRYPTION_KEY="asdjkflajsdflkjas;ldjfa"
    MJ_APIKEY_PUBLIC="mailjet api key public"
    MJ_APIKEY_PRIVATE=""
    PAYPAL_API_SECRET="ddd"
    MAILGUN_API_KEY=""

    Here's how to get the following keys:

    • Google Sheets: https://developers.google.com/sheets/api/guides/authorizing#APIKey
    • NEXT_AUTH_URL: choose the address of deployment
    • FIREBASE_PRIVATE_KEY -- I don't think this is even needed??
    • ENCRYPTION_KEY -- ask Nathan (or modify cryptography file), used to decrypt firebase key on vercel
    • MJ_APIKEY_PUBLIC/PRIVATE -- ask Nathan, only needed for newsletter
    • MAILCHIMP_API_KEY -- ask Nathan, only needed for class registration system
    • PAYPAL_API_SECRET -- ask Nathan, only needed for class registration system
  3. Using the correct configuration file, go into SHEETS_API_CREDS inconfig.ts and make sure the credential object matches your Google Sheet configuration that you retrieved in the previous step.

  4. Acquire firebase credentials (or setup emulator), and make sure to replace the configuration in the firebaseAdmin.initializeApp in firebase.ts with the correct configuration.

  5. To navigate to the volunteer hours page after running yarn dev, you can go to localhost:3000/view-hours. Then, it should be able to test.

  6. Make sure to add access to the sheet in mind through Google Sheets itself (add the service account email as an editor in the sheet)

Here is a sample entry in the table, for reference, which can be called with the google-spreadsheet node package, :

Timestamp What is your name? What is your email address? List any PR's that you reviewed or submitted this week. How many hours did you spend on the USACO Guide this week? Enter only a number. (Optional, only if you want volunteer hours) Anything else you want to tell us? (Optional)
2021-10-23T23:18:42.653Z Someone [email protected] I worked on pull requests and reviewed things. 4 Yes, I made some stuff.

online-judge's People

Contributors

bqi343 avatar mrinallu avatar nikhilc1527 avatar thecodingwizard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

online-judge's Issues

partially migrate to modal

modal doesn't support fixing CPU so we can't actually do code execution there. we can do everything else (download test data, run tests simultaneously, grading, etc) there though.

Error: ENOSPC: no space left on device..

One user reported seeing this error. I think it's possible that a long-lasting lambda function might run out of space. Either way, probably not very high priority


never mind, I'm also seeing this error, no clue why

Problem Submission Grading

Remaining Tasks

  • Write tests
  • Figure out how to handle large input files (robo cow herd is 10MB which exceeds lambda limit)

Goal

Add support for submitting and grading code for entire problems (ex. USACO problems), to be used by things like USACO Guide Groups.

Rough guidelines

Execute Lambda

https://github.com/cpinitiative/online-judge/tree/serverless/execute

  • Truncate large standard inputs / outputs (aws lambda has a 6mb limit; see below)
  • Return a hash of the output. Make sure to normalize whitespace (ie we don't want to return WA if the user is off by whitespace only).

Submit Lambda

https://github.com/cpinitiative/online-judge/tree/serverless/submit

  • Distinguish between three types of requests: Create a new problem submission (POST), get a problem submission status (GET), and create an execution request for a single test case like ide.usaco.guide (POST).
  • When a new problem submission is created, create a new DynamoDB row and return the row ID. Then, use one execution lambda request to compile the code. Fetch all the test cases from S3 somehow. For every test case, call another execution lambda. Then, compare the execution lambda output hash with the expected output hash to determine whether the answer is correct or not. Also check for memory usage. Update the dynamodb row as needed
  • For get problem submission status requests, just fetch data from DynamoDB and return it

Things to keep in mind

  • AWS Lambda has a 6mb output size limit, and some USACO problems exceed that, so we'll need to use hashing to check whether an output is correct or not.
  • DynamoDB is very expensive and charges by size. We should avoid storing large text like input / output / etc; if we ever need to do this, we should use S3.
  • However, we do want to store source code, compilation errors, and small test case outputs for USACO Guide groups (to help users debug their code on small cases more easily). We should put a limit on how big the source code can be (64kb is what Codeforces uses), and use gzip to compress any text we store.

Standardize using compilationMessage

Right now for code executions, if status is compile error, the compilationMessage isn't set but stderr is. We should set compilationMessage even for compile errors for consistency

fix stack size limit

CSES Subordinates:

AC Code

#include "bits/stdc++.h"
 
int dfs(int node, std::vector<std::vector<int>>& a, std::vector<int>& ans) {
    int temp = 0;
    for(auto& i : a[node]) temp += dfs(i, a, ans);
    return ans[node] = 1 + temp;
}
 
signed main() {
    std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
    int n; std::cin >> n;
    std::vector<std::vector<int>> a(n + 1);
    std::vector<int> ans(n + 1, 0);
    for(int i = 2, x; i <= n; ++i) {
        std::cin >> x;
        a[x].push_back(i);
    }
    dfs(1, a, ans);
 
    for(int i = 1; i <= n; ++i) std::cout << ans[i] - 1 << " ";
}

gives RTE on our grader. I think this is because our stack size is too small. Fix with ulimit -s unlimited: https://stackoverflow.com/questions/14471564/what-does-ulimit-s-unlimited-do

Serverless Online Judge

Goal

To create a low-cost, reliable, fast, and consistent online judge that supports C++, Java, and Python.

See serverless branch for more information

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.