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

Fix upload big xml files for tasks #199

Merged
merged 13 commits into from
Nov 24, 2018
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
55 changes: 44 additions & 11 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() {
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
$.ajax({
url: '/save/annotation/task/' + window.cvat.dashboard.taskID,
url: '/delete/annotation/task/' + window.cvat.dashboard.taskID,
type: 'POST',
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
data: JSON.stringify(exportData),
contentType: 'application/json',
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 = 'Annotation uploading errors was occurred: ' +
Copy link
Member

Choose a reason for hiding this comment

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

There is no data uploading. Clean up only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

response.responseText;
showMessage(message);
overlay.remove();
},
complete: () => overlay.remove()
});
}

let asyncSaveChunk = function(start) {
let CHUNK_SIZE = 100000;
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
let end = start + CHUNK_SIZE;
var chunk = {};
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
var next = false;
for (var prop in parsed) {
if (parsed.hasOwnProperty(prop)) {
chunk[prop] = parsed[prop].slice(start, end);
next |= chunk[prop].length > 0;
}
}

if (next) {
const 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 = 'Annotation uploading errors were occurred: ' +
response.responseText;
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
showMessage(message);
overlay.remove();
},
});
} else {
let message = 'Annotation successfully uploaded';
showMessage(message);
overlay.remove();
}
};

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