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

feature: ProjectWorker #43

Merged

Conversation

prabalsingh24
Copy link
Contributor

@prabalsingh24 prabalsingh24 commented May 22, 2020

fixes #36, #39

  • Create project scenario

    • Complete setup method ( as done here in the test)
    • Complete run method
      • Complete result method
      • Write tests for the methods and scenario
  • Send the payload to the job

  • Refactor src/tasks/job.ts

    • Create src/tasks/jobs/ directory
    • Move all the jobs other than Base class to individual files in jobs dir
    • Like move RunJob and its type to src/tasks/jobs/run.ts
    • Refactor imports to support current structure

@auto-label auto-label bot added the feature label May 22, 2020
@prabalsingh24 prabalsingh24 force-pushed the project-worker-prabal branch from 45097f9 to b6ce935 Compare May 23, 2020 11:15
@prabalsingh24
Copy link
Contributor Author

prabalsingh24 commented May 23, 2020

@jatinkatyal13 can you have a look and let me know if I am not the correct path.

@prabalsingh24
Copy link
Contributor Author

prabalsingh24 commented May 23, 2020

Also how to extract zip file. I assume a library will be used for that. Let me know if you have any particular lib in your mind

Edit: i used AdmZip. It is working fine. If you want a different library, i'll change it.

@prabalsingh24
Copy link
Contributor Author

This seems to be workingg.

Screenshot from 2020-05-23 19-33-49

@prabalsingh24
Copy link
Contributor Author

Can you tell me what will be returned in which cases. (build fail, complie fail, etc ) what scores and code should be returned?

@prabalsingh24
Copy link
Contributor Author

prabalsingh24 commented May 23, 2020

Do I need to check how many tests are passing and how many are failing? To find out the score

And code is status code right? like if it's 25, then test directory were modified. or code === 137 --> MLE , etc etc

@prabalsingh24
Copy link
Contributor Author

Screenshot from 2020-05-23 21-39-57

@prabalsingh24
Copy link
Contributor Author

TODOs:

  1. Instead of using zip file locally. Download it and then extract it.
  2. Modify project result function to return correct code and score
  3. Add LANG.CONFIG
  4. Write tests :P

@prabalsingh24 prabalsingh24 marked this pull request as ready for review May 23, 2020 16:16
run(currentJobDir: string, job: ProjectJob) {

// LANG_CONFIG is undefined rn, hence card coding the value of cpus and memory
const LANG_CONFIG = config.LANGS[job.lang]
Copy link
Contributor

Choose a reason for hiding this comment

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

We will be creating a new config here named PROJECTS. In future, we might need more configurable information for these projects.

const solutionDir = path.join(currentJobDir, job.source)
await download(job.problem, solutionDir)
// for testing only, change it to download
var problemZip = new AdmZip('/judge-worker-prabal/current/problem.zip')
Copy link
Contributor

Choose a reason for hiding this comment

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

We were already downloading the zip. Using exec('unzip abc.zip') should work

id: job.id,
stderr: build_stderr,
stdout: '',
code: 12123,
Copy link
Contributor

Choose a reason for hiding this comment

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

set code to result_code, time to result.time and score to 0

stdout: '',
code: parseInt(result_code),
time: 1,
score: 12
Copy link
Contributor

Choose a reason for hiding this comment

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

score will be 0

@jatinkatyal13
Copy link
Contributor

Nice job!

So here are few pointers

  1. The score will 100 if and only if result.code file if 0
  2. For unzipping the downloaded zip we can use the Linux unzip command using the exec from shelljs
  3. The score is currently binary, you either get 100 or 0
  4. Yes the status code is right and generated from worker's runguard

@jatinkatyal13
Copy link
Contributor

@prabalsingh24 are facing any issue with the changes requested? You can always reach out to me on discord for any help. Let's complete this task and we'll be ready to deploy the new judge.

@prabalsingh24
Copy link
Contributor Author

@prabalsingh24 are facing any issue with the changes requested? You can always reach out to me on discord for any help. Let's complete this task and we'll be ready to deploy the new judge.

Yeah thankss. Actually I didn't work yesterday :P I am working on it rn. I will push changes soon :)

}
}

// if hashes were equal, result_code will be found inside solution directory
Copy link
Contributor Author

@prabalsingh24 prabalsingh24 May 25, 2020

Choose a reason for hiding this comment

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

@jatinkatyal13 is this done on purpose? result_code and result_time inside solutionDirectory? and other stuff in the baseDirectory? Shouldn't everything be in base directory?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch, I'll fix this here. You can safely assume everything related to the result will be in the base directory

@prabalsingh24
Copy link
Contributor Author

Screenshot from 2020-05-25 17-38-32

@codecov
Copy link

codecov bot commented May 25, 2020

Codecov Report

Merging #43 into project-worker will decrease coverage by 14.43%.
The diff coverage is 39.02%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           project-worker      #43       +/-   ##
===================================================
- Coverage           90.65%   76.22%   -14.44%     
===================================================
  Files                   7       11        +4     
  Lines                 107      143       +36     
  Branches               11       16        +5     
===================================================
+ Hits                   97      109       +12     
- Misses                  5       29       +24     
  Partials                5        5               
Impacted Files Coverage Δ
src/tasks/job.ts 100.00% <ø> (+12.50%) ⬆️
src/tasks/scenarios/submission.ts 92.30% <ø> (ø)
src/tasks/scenarios/project.ts 22.22% <4.76%> (ø)
src/tasks/jobs/project.ts 40.00% <40.00%> (ø)
src/tasks/index.ts 86.95% <66.66%> (-7.49%) ⬇️
src/tasks/jobs/run.ts 100.00% <100.00%> (ø)
src/tasks/jobs/submission.ts 100.00% <100.00%> (ø)
src/tasks/scenarios/run.ts 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78a3cbb...9a24b9e. Read the comment docs.

@prabalsingh24 prabalsingh24 force-pushed the project-worker-prabal branch from 338cacd to 9a24b9e Compare May 25, 2020 13:57
@jatinkatyal13 jatinkatyal13 merged commit 9fa1620 into coding-blocks:project-worker May 25, 2020
@boss-contributions-bot
Copy link

Congratualtions @prabalsingh24, your pull request is merged! 🎉

Thanks for your contributions and participating in BOSS 2020. 🙌

You can claim your bounty points here. 💰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants