Repository: voxel51/fiftyone

Issue:
[BUG] cvat uploads prefixes cvat samples with a sequence number
### Instructions

Thank you for submitting an issue. Please refer to our
[issue policy](https://www.github.com/voxel51/fiftyone/blob/develop/ISSUE_POLICY.md)
for information on what types of issues we address.

1. Please fill in this template to ensure a timely and thorough response
2. Remove the section instructions but leave the section header
3. Place an "x" between the brackets next to an option if it applies. For
   example:
    - [x] Selected option
4. **Please delete everything above this line before submitting the issue**

### Describe the problem
The cvat annotation backend is still prepending sample names with a sequence number to cope with old cvat behavior of alphabetical sorting of file names. However, there is now an sorting_method=predefined to be set which make cvat honor the upload order or alternatively a list of file names order.
For a mixed environment where not all annotation tasks goes back to 51, these prefixes messes things up in file searches after exports directly from cvat.

### Code to reproduce issue
Notice filepath on a file
Upload file to cvat with some settings
Access task and job in cvat and check the filepath under the sample navigator, it has a prefix 000000_ similar 
Load the annotations back to 51 -> no problem, 51 takes care of stripping the prefix.
Export the task from cvat gui -> here the prefix is still there and causes headaches.

### System information
-   Linux Ubuntu 22.04
-   python 3.10
-   FiftyOne v0.22.3, Voxel51, Inc.
-   pip install

### Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?

-   [x] Yes. I can contribute a fix for this bug independently
-   [x] Yes. I would be willing to contribute a fix for this bug with guidance
        from the FiftyOne community
-   [ ] No. I cannot contribute a bug fix at this time



Discussion:
@hoshimura a fix for this would be terrific! We definitely didn't want to include the prefixes, just didn't have any other option at the time.

Can you make it backwards-compatible so that older CVAT server versions will still use the prefix?

Resolving patch:
diff --git a/fiftyone/utils/cvat.py b/fiftyone/utils/cvat.py
--- a/fiftyone/utils/cvat.py
+++ b/fiftyone/utils/cvat.py
@@ -4233,6 +4233,9 @@ def upload_data(
 
         files, open_files = self._parse_local_files(paths)
 
+        if self._server_version >= Version("2.4.6"):
+            data["sorting_method"] = "predefined"
+
         try:
             self.post(self.task_data_url(task_id), data=data, files=files)
         except Exception as e:
@@ -4294,10 +4297,12 @@ def _parse_local_files(self, paths):
         else:
             # Image task
             for idx, path in enumerate(paths):
-                # IMPORTANT: CVAT organizes media within a task alphabetically
-                # by filename, so we must give CVAT filenames whose
-                # alphabetical order matches the order of `paths`
-                filename = "%06d_%s" % (idx, os.path.basename(path))
+                filename = os.path.basename(path)
+                if self._server_version < Version("2.4.6"):
+                    # IMPORTANT: older versions of CVAT organizes media within
+                    # a task alphabetically by filename, so we must give CVAT
+                    # filenames whose alphabetical order matches the order of `paths`
+                    filename = "%06d_%s" % (idx, os.path.basename(path))
 
                 if self._server_version >= Version("2.3"):
                     with open(path, "rb") as f:


Test patch: