Skip to content

Commit

Permalink
Fix upload big xml files for tasks (#199)
Browse files Browse the repository at this point in the history
* Fix #123 (Uploading large XML Files)
* Integrated SILK for profiling.
* Don't try to call save_job without objects.
  • Loading branch information
nmanovic authored Nov 24, 2018
1 parent 076899a commit 1a040a0
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/keys
/logs
/components/openvino/*.tgz
/profiles

# Ignore temporary files
docker-compose.override.yml
Expand Down
57 changes: 45 additions & 12 deletions cvat/apps/dashboard/static/dashboard/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,29 +538,62 @@ function uploadAnnotationRequest() {
}
catch(error) {
overlay.remove();
showMessage("Parsing errors was occured. " + error);
showMessage("Parsing errors was occurred. " + error);
return;
}

const exportData = createExportContainer();
exportData.create = parsed;

let asyncSave = function() {
$.ajax({
url: '/save/annotation/task/' + window.cvat.dashboard.taskID,
type: 'POST',
data: JSON.stringify(exportData),
contentType: 'application/json',
url: '/delete/annotation/task/' + window.cvat.dashboard.taskID,
type: 'DELETE',
success: function() {
let message = 'Annotation successfully uploaded';
showMessage(message);
asyncSaveChunk(0);
},
error: function(response) {
let message = 'Annotation uploading errors was occured. ' + response.responseText;
let message = 'Previous annotations cannot be deleted: ' +
response.responseText;
showMessage(message);
overlay.remove();
},
complete: () => overlay.remove()
});
}

let asyncSaveChunk = function(start) {
const CHUNK_SIZE = 100000;
let end = start + CHUNK_SIZE;
let chunk = {};
let next = false;
for (let prop in parsed) {
if (parsed.hasOwnProperty(prop)) {
chunk[prop] = parsed[prop].slice(start, end);
next |= chunk[prop].length > 0;
}
}

if (next) {
let exportData = createExportContainer();
exportData.create = chunk;

$.ajax({
url: '/save/annotation/task/' + window.cvat.dashboard.taskID,
type: 'POST',
data: JSON.stringify(exportData),
contentType: 'application/json',
success: function() {
asyncSaveChunk(end);
},
error: function(response) {
let message = 'Annotations uploading errors were occurred: ' +
response.responseText;
showMessage(message);
overlay.remove();
},
});
} else {
let message = 'Annotations were uploaded successfully';
showMessage(message);
overlay.remove();
}
};

overlay.setMessage('Annotation is being saved..');
Expand Down
Loading

0 comments on commit 1a040a0

Please sign in to comment.