Skip to content

Commit

Permalink
append task number when multiple tasks are created
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustem Galiullin committed Dec 5, 2022
1 parent a15d19d commit 12208fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions fiftyone/utils/cvat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| `voxel51.com <https://voxel51.com/>`_
|
"""
import math
from collections import defaultdict
from copy import copy, deepcopy
from datetime import datetime
Expand Down Expand Up @@ -4229,6 +4230,7 @@ def upload_samples(self, samples, backend):

num_samples = len(samples)
batch_size = self._get_batch_size(samples, task_size)
num_batches = math.ceil(num_samples / batch_size)

samples.compute_metadata()

Expand Down Expand Up @@ -4294,10 +4296,15 @@ def upload_samples(self, samples, backend):
project_ids.append(project_id)

if config.task_name is None:
_dataset_name = samples_batch._dataset.name.replace(" ", "_")
task_name = "FiftyOne_%s" % _dataset_name
_dataset_name = samples_batch._dataset.name.replace(
" ", "_"
)
task_name = f"FiftyOne_{_dataset_name}"
else:
task_name = config.task_name
# append task number when multiple tasks are created
if num_batches > 1:
task_name += f"_{idx + 1}"

(
task_id,
Expand Down
4 changes: 2 additions & 2 deletions tests/intensive/cvat_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ def test_task_creation_arguments(self):
with results:
api = results.connect_to_api()
self.assertEqual(len(task_ids), 2)
for task_id in task_ids:
for idx, task_id in enumerate(task_ids):
task_json = api.get(api.task_url(task_id)).json()
self.assertEqual(task_json["bug_tracker"], bug_tracker)
self.assertEqual(task_json["segment_size"], 1)
self.assertEqual(task_json["name"], task_name)
self.assertEqual(task_json["name"], f"{task_name}_{idx + 1}")
if user is not None:
self.assertEqual(task_json["assignee"]["username"], user)
for job in api.get(api.jobs_url(task_id)).json():
Expand Down

0 comments on commit 12208fb

Please sign in to comment.