Skip to content

Commit e8a0bf5

Browse files
committed
Fix downloading, shrink list of export formats
1 parent b214884 commit e8a0bf5

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

cvat-core/src/server-proxy.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,12 @@
250250
.get(`${url}`, {
251251
proxy: config.proxy,
252252
});
253-
url = `${url}&action=download`;
254-
resolve(url);
253+
if (response.status === 202) {
254+
setTimeout(request, 3000);
255+
} else {
256+
url = `${url}&action=download`;
257+
resolve(url);
258+
}
255259
} catch (errorData) {
256260
reject(generateError(
257261
errorData,

cvat/apps/dashboard/static/dashboard/js/dashboard.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,16 @@ class TaskView {
110110
}
111111
}
112112

113-
async _exportDataset(button, format) {
113+
async _exportDataset(button, formatName) {
114114
button.disabled = true;
115115
try {
116-
const url = await this._task.annotations.exportDataset(format);
116+
const format = this._exportFormats.find((x) => {
117+
return x.name == formatName;
118+
});
119+
if (!format) {
120+
throw `Unknown dataset export format '${formatName}'`;
121+
}
122+
const url = await this._task.annotations.exportDataset(format.tag);
117123
const tempElem = document.createElement('a');
118124
tempElem.href = `${url}`;
119125
document.body.appendChild(tempElem);
@@ -126,8 +132,8 @@ class TaskView {
126132
}
127133
}
128134

129-
_isDefaultExportFormat(format) {
130-
return format == 'datumaro_project';
135+
_isDefaultExportFormat(formatTag) {
136+
return formatTag == 'datumaro_project';
131137
}
132138

133139
init(task) {
@@ -194,8 +200,8 @@ class TaskView {
194200
+ 'style="text-align-last: center;"> Export as Dataset </select>');
195201
$('<option selected disabled> Export as Dataset </option>').appendTo(exportButton);
196202
for (const format of this._exportFormats) {
197-
const item = $(`<option>${format}</li>`);
198-
if (this._isDefaultExportFormat(format)) {
203+
const item = $(`<option>${format.name}</li>`);
204+
if (this._isDefaultExportFormat(format.tag)) {
199205
item.addClass('bold');
200206
}
201207
item.appendTo(exportButton);
@@ -252,13 +258,39 @@ class DashboardView {
252258
this._sharePath = metaData.share_path;
253259
this._params = {};
254260
this._annotationFormats = annotationFormats;
255-
this._exportFormats = exportFormats;
261+
this._exportFormats = [];
256262

263+
this._setupExportFormats(exportFormats);
257264
this._setupList();
258265
this._setupTaskSearch();
259266
this._setupCreateDialog();
260267
}
261268

269+
_setupExportFormats(availableFormats) {
270+
const publicFormats = [];
271+
272+
if (-1 != availableFormats.indexOf('datumaro_project')) {
273+
publicFormats.push({
274+
tag: 'datumaro_project',
275+
name: 'Datumaro',
276+
});
277+
}
278+
if (-1 != availableFormats.indexOf('voc')) {
279+
publicFormats.push({
280+
tag: 'voc',
281+
name: 'PASCAL VOC 2012',
282+
});
283+
}
284+
if (-1 != availableFormats.indexOf('coco')) {
285+
publicFormats.push({
286+
tag: 'coco',
287+
name: 'MS COCO',
288+
});
289+
}
290+
291+
this._exportFormats = publicFormats;
292+
}
293+
262294
_setupList() {
263295
const dashboardList = $('#dashboardList');
264296
const dashboardPagination = $('#dashboardPagination');

cvat/apps/dataset_manager/task.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def log_exception(logger=None, exc_info=True):
3535
_TASK_IMAGES_REMOTE_EXTRACTOR = 'cvat_rest_api_task_images'
3636

3737
EXPORT_FORMAT_DATUMARO_PROJECT = "datumaro_project"
38-
EXPORT_FORMAT_DATUMARO_REMOTE_PROJECT = "datumaro_project_remote"
3938

4039
class TaskProject:
4140
@staticmethod
@@ -208,9 +207,7 @@ def save(self, save_dir=None, save_images=False):
208207
def export(self, dst_format, save_dir, save_images=False, server_url=None):
209208
if self._dataset is None:
210209
self._init_dataset()
211-
if dst_format == DEFAULT_FORMAT:
212-
self._dataset.save(save_dir=save_dir, save_images=save_images)
213-
elif dst_format == DEFAULT_FORMAT_REMOTE:
210+
if dst_format == EXPORT_FORMAT_DATUMARO_PROJECT:
214211
self._remote_export(save_dir=save_dir, server_url=server_url)
215212
else:
216213
self._dataset.export(output_format=dst_format,
@@ -351,7 +348,6 @@ def get_export_formats():
351348

352349
formats = [
353350
EXPORT_FORMAT_DATUMARO_PROJECT,
354-
EXPORT_FORMAT_DATUMARO_REMOTE_PROJECT,
355351
]
356352

357353
for name, _ in converters.items:

cvat/apps/engine/static/engine/js/cvat-core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cvat/apps/engine/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ def dataset_export(self, request, pk):
480480
rq_job = queue.fetch_job(rq_id)
481481
if rq_job:
482482
task_time = timezone.localtime(db_task.updated_date)
483-
request_time = timezone.localtime(rq_job.meta.get('request_time', datetime.min))
483+
request_time = timezone.localtime(
484+
rq_job.meta.get('request_time', datetime.min))
484485
if request_time < task_time:
485486
rq_job.cancel()
486487
rq_job.delete()
@@ -511,7 +512,7 @@ def dataset_export(self, request, pk):
511512
args=(pk, request.user, dst_format), job_id=rq_id,
512513
meta={ 'request_time': timezone.localtime() },
513514
result_ttl=ttl, failure_ttl=ttl)
514-
return Response(status=status.HTTP_201_CREATED)
515+
return Response(status=status.HTTP_202_ACCEPTED)
515516

516517
class JobViewSet(viewsets.GenericViewSet,
517518
mixins.RetrieveModelMixin, mixins.UpdateModelMixin):

0 commit comments

Comments
 (0)