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

[wip] add: code submission endpoint #9

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

matheusfrancisco
Copy link
Member

Comment on lines +18 to +25
{: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}}})
Copy link
Member Author

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?

Copy link
Member Author

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,

Copy link
Member

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?

Copy link
Member

@rafaeldelboni rafaeldelboni Apr 7, 2024

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?

Copy link
Member Author

@matheusfrancisco matheusfrancisco Apr 7, 2024

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.

Copy link
Member Author

@matheusfrancisco matheusfrancisco Apr 7, 2024

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

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

nice 👍🏽

Comment on lines +18 to +25
{: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}}})
Copy link
Member

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"
Copy link
Member

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))
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

@matheusfrancisco matheusfrancisco Apr 9, 2024

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?]
Copy link
Member

Choose a reason for hiding this comment

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

UUID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

endpoint to receive a new code submission, and the caller should receive a submission id
2 participants