-
Notifications
You must be signed in to change notification settings - Fork 0
[wip] add: code submission endpoint #9
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
base: main
Are you sure you want to change the base?
Conversation
matheusfrancisco
commented
Apr 7, 2024
- This PR adds the endpoint to receive the code to be executed. closes endpoint to receive a new code submission, and the caller should receive a submission id #6
{:code "(ns runner | ||
(:require [clojure.test :refer [use-fixtures]]) | ||
(defn my-sum [a b] (+ a b)))" | ||
:language :clojure | ||
:test-cases {:case-1 {:input "(my-sum 1 2)" | ||
:output 3} | ||
:case-2 {:input "(my-sum 2 3)" | ||
:output 5}}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaeldelboni what do you think of this input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way I will have to merge it, so I think is better to receive it already merged,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is going to send this payload the frontend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is use this code + test cases to build the code that will run in the pod right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is going to send this payload the frontend?
Hm, 🤔 idk why I was thinking of having two backends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is use this code + test cases to build the code that will run in the pod right?
Yep, the idea was to merge it in some way and send to the pod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:language could be an enum WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍🏽
{:code "(ns runner | ||
(:require [clojure.test :refer [use-fixtures]]) | ||
(defn my-sum [a b] (+ a b)))" | ||
:language :clojure | ||
:test-cases {:case-1 {:input "(my-sum 1 2)" | ||
:output 3} | ||
:case-2 {:input "(my-sum 2 3)" | ||
:output 5}}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:language could be an enum WDYT?
;; submitions routes | ||
["/code" | ||
{:swagger {:tags ["Code Runner"]}} | ||
["/submission" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think even we going to receive this by another backend we need to ensure a bearer token is passed, since this will be accessed by only one service, this could be stored in the configuration files
|
||
(defn submit-code-execution! | ||
[submission] | ||
(random-uuid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are generating this just to insert into the database, you can delegate the UUID generation to postgres.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not 100% clear what we are going to save on postgres
id, code, code-hash, language and test-cases as string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question, I think I would store information to be possible to trace back the author, contest and the submission.
I would have an table to the contests (where the base challenge, and test inputs (and demo test inputs) would be stored, another for the authors, another for the submission where you would have the challenge id, author id, and the submission itself, to not store to much data in the database I would keep only the latest submission for each challenge and author, so if I submit and answer for a challenge we update the submission table by author-id and challenge-id with the new code, code-hash and updated date
After I would have a table with the execution results where you could store submission-id, code-hash and the result.
We can whiteboard this later if you want so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can whiteboard this later if you want so.
I would love to whiteboard this
|
||
(def Submission | ||
[:map | ||
[:submission/id string?] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UUID?