-
Notifications
You must be signed in to change notification settings - Fork 27
add support for enc parameter for POST: /runs #23
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9dc4e19
add support for mode parameter for POST /runs
abhishek97 50816db
the dawgs
abhishek97 c2bc622
upload result to s3 for callback mode (POST: /runs)
abhishek97 a9fdd03
add support for enc parameter for run
abhishek97 356e2bd
update the docs
abhishek97 93c97be
Update 001-addOutputsToSubmission.sql
championswimmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alter table submissions add column outputs varchar[]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {RunJob} from '../rabbitmq/jobqueue' | ||
import {download} from './s3' | ||
|
||
/** | ||
* Normalizes the Run Job (effectively normalizes source and stdin to base64 immediate values) | ||
* @param {RunJob} job | ||
* @param {string} enc (Default = 'base64') | ||
* @returns {Promise<RunJob>} the normalized runJob | ||
*/ | ||
export const normalizeRunJob = async function (job: RunJob, enc:string = 'base64') : Promise<RunJob> { | ||
switch (enc) { | ||
case 'url': | ||
const [source, stdin] = await Promise.all([download(job.source), download(job.stdin)]) | ||
return { | ||
...job, | ||
source, | ||
stdin | ||
} | ||
default: return job | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Minio = require('minio') | ||
import v4 = require('uuid/v4') | ||
import axios from 'axios' | ||
import config = require('../../config') | ||
|
||
const client = new Minio.Client({ | ||
endPoint: config.S3.endpoint, | ||
port: config.S3.port, | ||
useSSL: config.S3.ssl, | ||
accessKey: config.S3.accessKey, | ||
secretKey: config.S3.secretKey, | ||
}) | ||
|
||
export type savedFile = { | ||
etag: string, | ||
url: string | ||
} | ||
|
||
export const urlForFilename = (bucket: string, filename: string) : string => `http${config.S3.ssl ? 's': ''}://${config.S3.endpoint}/${bucket}/${filename}` | ||
|
||
/** | ||
* Uploads an object to s3 encoded as json | ||
* @param {object} object | ||
* @param {string} filename The filename (Default = randomized) | ||
* @param {string} bucket The bucket name (Default = picked from config.json) | ||
* @returns {Promise<savedFile>} The etag and url for the file saved | ||
*/ | ||
export const upload = function (object:object, filename:string = v4() + '.json' ,bucket:string = config.S3.bucket) : Promise<savedFile> { | ||
return new Promise((resolve, reject) => { | ||
client.putObject(bucket, filename, JSON.stringify(object), function(err, etag) { | ||
if (err) return reject(err) | ||
resolve({etag, url: urlForFilename(bucket, filename) }) | ||
}) | ||
}) | ||
} | ||
|
||
/** | ||
* Downloads a file from url and encodes it | ||
* @param {string} url | ||
* @param {string} enc (Default = 'base64') | ||
* @returns {Promise<string>} the downloaded file encoded as specified | ||
*/ | ||
export const download = async function (url: string, enc: string = 'base64') : Promise<string> { | ||
if (!url) return '' | ||
|
||
const {data} = await axios.get(url) | ||
return Buffer.from(data).toString(enc) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
cool!