Skip to content

Commit

Permalink
mf
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Dec 3, 2024
1 parent b90a230 commit b26b6e1
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 31 deletions.
18 changes: 13 additions & 5 deletions application/src/tira_app/endpoints/v1/_anonymous.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def read_anonymous_submission(request: Request, submission_uuid: str) -> Respons
)


@api_view(["POST"])
@check_permissions
def claim_submission(request: Request, vm_id: str, submission_uuid: str) -> Response:

Expand Down Expand Up @@ -69,9 +70,7 @@ def claim_submission(request: Request, vm_id: str, submission_uuid: str) -> Resp
dataset_id = upload.dataset.dataset_id

if "upload_group" not in body:
body["upload_group"] = model.add_upload(
task_id,
)
body["upload_group"] = model.add_upload(task_id, vm_id)["id"]
model.model.update_upload_metadata(
task_id, vm_id, body["upload_group"], body["display_name"], body["description"], body["paper_link"]
)
Expand All @@ -86,11 +85,20 @@ def claim_submission(request: Request, vm_id: str, submission_uuid: str) -> Resp
if status_code != _fmt.OK:
HttpResponseServerError(json.dumps({"status": 1, "message": message}))

new_run = model.model.add_uploaded_run(task_id, vm_id, dataset_id, body["upload_group"], uploaded_file)
class MockedResponse:
name = uploaded_file.name

def chunks(self):
with open(uploaded_file, "rb") as f:
all_bytes = f.read()

return [all_bytes]

new_run = model.model.add_uploaded_run(task_id, vm_id, dataset_id, body["upload_group"], MockedResponse())
if model.model.git_pipeline_is_enabled_for_task(task_id, cache):
model.run_eval(request=request, vm_id=vm_id, dataset_id=dataset_id, run_id=new_run["run"]["run_id"])

return Response({"upload_group": body["upload_group"]})
return Response({"upload_group": body["upload_group"], "status": "0"})


endpoints = [
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/ClaimSubmission.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<v-autocomplete v-if="new_software !== undefined && ('' + new_software) == 'false'" clearable auto-select-first label="Choose approach &hellip;" prepend-inner-icon="mdi-magnify"
:items="upload_groups" item-title="display_name" item-value="id" variant="underlined" v-model="selected_upload_group" :rules="[select_rule]"/>
</v-form>
<v-btn :disabled="new_software === undefined" @click="submitForm()">Claim Ownersip</v-btn>
<v-btn :disabled="new_software === undefined || claim_in_progress" :loading="claim_in_progress" @click="submitForm()">Claim Ownersip</v-btn>
<div class="py-2"></div>
<v-divider/>
<!--<h3 class="my-1">Inspect Submission</h3>
Expand All @@ -72,7 +72,7 @@
<script lang="ts">
import { inject } from 'vue'
import { get, post, vm_id, inject_response, chatNoirUrl, irDatasetsUrls, type UserInfo, type DatasetInfo, type ClaimSubmissionInfo, type UploadGroupInfo } from './utils';
import { get, post, vm_id, inject_response, reportError, chatNoirUrl, irDatasetsUrls, type UserInfo, type DatasetInfo, type ClaimSubmissionInfo, type UploadGroupInfo } from './utils';
import { Loading, TiraBreadcrumb } from './components'
import RunPage from './tirex/RunPage.vue'
Expand All @@ -98,6 +98,7 @@ export default {
display_name: '' as string,
description: '' as string,
paper_link: '' as string,
claim_in_progress: false
}
},
methods: {
Expand All @@ -120,7 +121,7 @@ export default {
.then(() => {
this.dataset = i as DatasetInfo
if (this.vm_id) {
get(this.rest_url + '/api/submissions-for-task/tira-tutorial/' + this.vm_id + '/upload')
get(this.rest_url + '/api/submissions-for-task/' + this.dataset.default_task + '/' + this.vm_id + '/upload')
.then((uploads) => {
this.upload_groups = uploads['context']['all_uploadgroups']
})
Expand All @@ -133,16 +134,21 @@ export default {
async submitForm() {
const form = this.$refs.form as any
const { valid } = await form.validate()
if (valid) {
if (valid && this.dataset) {
let params : Record<string, string> = {}
let task_id = this.dataset.default_task
if (this.new_software !== undefined && ('' + this.new_software) == 'true') {
params['display_name'] = this.display_name + ''
params['description'] = this.description + ''
params['paper_link'] = this.paper_link + ''
} else {
params['upload_group'] = this.selected_upload_group + ''
}
this.claim_in_progress = true
post(this.rest_url + `/v1/anonymous/claim/` + this.vm_id + '/' + this.uuid, params, this.userinfo)
.then((i) => {this.$router.push({ path: '/submit/' + task_id + '/user/' + this.vm_id + '/upload-submission/' + i['upload_group']})})
.catch(reportError("Could not claim submission."))
.finally(() => this.claim_in_progress = false)
}
}
},
Expand Down
53 changes: 31 additions & 22 deletions frontend/src/submission-components/UploadSubmission.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<loading :loading="loading" />

<login-to-submit v-if="!loading && userinfo.role === 'guest'" />
<v-row v-if="!loading && userinfo.role !== 'guest'">
<v-col :cols="$vuetify.display.mdAndUp ? '9' : '12'">
Expand All @@ -9,13 +10,13 @@
<v-col v-if="!$vuetify.display.smAndDown" :cols="$vuetify.display.mdAndUp ? '3' : '0'">
<v-btn color="primary" v-if="!$vuetify.display.mdAndUp" icon="mdi-plus" @click="this.tab = 'newUploadGroup'" />
<v-btn color="primary" v-if="$vuetify.display.mdAndUp" prepend-icon="mdi-plus" size="large"
@click="this.tab = 'newUploadGroup'" block>New Uploadgroup</v-btn>
@click="this.tab = 'newUploadGroup'" block>New Approach</v-btn>
</v-col>
</v-row>
<v-row v-if="$vuetify.display.smAndDown">
<v-col :cols="12">
<v-btn color="primary" prepend-icon="mdi-plus" size="large" @click="this.tab = 'newUploadGroup'" block rounded>New
Uploadgroup</v-btn>
Approach</v-btn>
</v-col>
</v-row>
<v-row v-if="!loading && userinfo.role !== 'guest'">
Expand All @@ -35,7 +36,6 @@
</v-col>
</v-row>
<v-window v-model="tab" v-if="!loading && userinfo.role !== 'guest'" :touch="{ left: null, right: null }">

<v-window-item value="newUploadGroup">
<h2>New Upload</h2>
<v-stepper :items="['About', 'Specify Metadata', 'Upload']" v-model="stepperModel" hide-actions="true" flat
Expand Down Expand Up @@ -163,24 +163,6 @@
</div>

</div>
<v-form v-if="description !== 'no-description'">
<h2>Upload new Submissions for Approach {{ us.display_name }}</h2>
<v-radio-group v-model="upload_type_next_upload">
<v-radio :label="'I want to upload a new run for approach ' + us.display_name + ' via the web UI'"
value="upload-via-ui" />
<v-radio :label="'I want to batch upload runs for approach ' + us.display_name + ' via a script'"
value="upload-via-script" />
</v-radio-group>
<div v-if="upload_type_next_upload == 'upload-via-ui'">
<v-file-input v-model="fileHandle" :rules="[v => !!v || 'File is required']" label="Click to add run file" />
<v-autocomplete label="Input Dataset" :items="datasets" item-title="display_name" item-value="dataset_id"
prepend-icon="mdi-file-document-multiple-outline" v-model="selectedDataset" variant="underlined"
clearable />
<v-text-field v-if="'' + rename_to !== 'null' && '' + rename_to !== '' && '' + rename_to !== 'undefined'"
v-model="rename_to" label="Uploaded Files are renamed to (immutable for reproducibility)" disabled="true" />
</div>
</v-form>

<v-btn v-if="description !== 'no-description' && upload_type_next_upload == 'upload-via-ui'" color="primary"
:loading="uploading" :disabled="uploading || fileHandle === null || selectedDataset === ''"
@click="fileUpload(us.id)">Upload Run</v-btn>
Expand All @@ -198,6 +180,27 @@
<h2>Your Existing Submissions for Approach {{ us.display_name }}</h2>
<run-list :task_id="task_id" :organizer="organizer" :organizer_id="organizer_id" :vm_id="user_id_for_task"
:upload_id="us.id" ref="upload-run-list" />


<v-btn class="my-5" v-if="description !== 'no-description' && !upload_for_approach" color="primary" prepend-icon="mdi-plus" size="large"
@click="this.upload_for_approach = true" block>Upload New Submission for Approach {{ us.display_name }}</v-btn>
<v-form class="my-5" v-if="description !== 'no-description' && upload_for_approach">
<h2>Upload new Submissions for Approach {{ us.display_name }}</h2>
<v-radio-group v-model="upload_type_next_upload">
<v-radio :label="'I want to upload a new run for approach ' + us.display_name + ' via the web UI'"
value="upload-via-ui" />
<v-radio :label="'I want to batch upload runs for approach ' + us.display_name + ' via a script'"
value="upload-via-script" />
</v-radio-group>
<div v-if="upload_type_next_upload == 'upload-via-ui'">
<v-file-input v-model="fileHandle" :rules="[v => !!v || 'File is required']" label="Click to add run file" />
<v-autocomplete label="Input Dataset" :items="datasets" item-title="display_name" item-value="dataset_id"
prepend-icon="mdi-file-document-multiple-outline" v-model="selectedDataset" variant="underlined"
clearable />
<v-text-field v-if="'' + rename_to !== 'null' && '' + rename_to !== '' && '' + rename_to !== 'undefined'"
v-model="rename_to" label="Uploaded Files are renamed to (immutable for reproducibility)" disabled="true" />
</div>
</v-form>
</v-window-item>
</v-window>
</template>
Expand All @@ -206,7 +209,7 @@
import { inject } from 'vue'
import { VAutocomplete } from 'vuetify/components'
import { extractTaskFromCurrentUrl, extractUserFromCurrentUrl, get, inject_response, reportError, post_file, reportSuccess, handleModifiedSubmission, get_link_to_organizer, get_contact_link_to_organizer } from "@/utils";
import { extractTaskFromCurrentUrl, extractUserFromCurrentUrl, extractSoftwareIdFromCurrentUrl, get, inject_response, reportError, post_file, reportSuccess, handleModifiedSubmission, get_link_to_organizer, get_contact_link_to_organizer } from "@/utils";
import { Loading, LoginToSubmit, RunList } from "@/components";
import EditSubmissionDetails from "@/submission-components/EditSubmissionDetails.vue";
import ImportSubmission from "./ImportSubmission.vue";
Expand Down Expand Up @@ -243,6 +246,7 @@ export default {
all_uploadgroups: [{ "id": null, "display_name": 'loading...' }],
selectedDataset: '',
showImportSubmission: false,
upload_for_approach: false,
token: 'YOUR-TOKEN-HERE',
datasets: [{ "dataset_id": "loading...", "display_name": "loading...", }],
rest_url: inject("REST base URL"),
Expand Down Expand Up @@ -360,6 +364,11 @@ export default {
beforeMount() {
get(this.rest_url + '/api/submissions-for-task/' + this.task_id + '/' + this.user_id_for_task + '/upload')
.then(inject_response(this, { 'loading': false }, true))
.then((i) => {
if(extractSoftwareIdFromCurrentUrl() !== null) {
this.tab = extractSoftwareIdFromCurrentUrl()
}
})
.catch(reportError("Problem While Loading The Submissions of the Task " + this.task_id, "This might be a short-term hiccup, please try again. We got the following error: "))
get(this.rest_url + '/api/token/' + this.user_id_for_task)
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,23 @@ export function extractSearchQueryFromCurrentUrl() {
return search_query ? search_query.toLowerCase() : search_query
}

export function extractSoftwareIdFromCurrentUrl() {
let url = ref(window.location).value.href
let to_split = 'submit/' + extractTaskFromCurrentUrl() + '/user/' + extractUserFromCurrentUrl() + '/'

if (url.includes(to_split)) {
url = url.split(to_split)[1]
} else {
return null
}

if (url.includes('upload-submission/')) {
url = url.split('upload-submission/')[1].split('/')[0].split('?')[0].split('#')[0]
}

return parseInt(url) > 0 ? parseInt(url) : null
}

export function extractSubmissionTypeFromCurrentUrl() {
let url = ref(window.location).value.href
let to_split = 'submit/' + extractTaskFromCurrentUrl() + '/user/' + extractUserFromCurrentUrl() + '/'
Expand Down

0 comments on commit b26b6e1

Please sign in to comment.