From e241d4f2ac026ffd78dffdea7b4512720111536a Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Mon, 2 Oct 2023 17:22:17 +0300 Subject: [PATCH] Fixed error when getting data from CS and cache=True (#6932) Fix ```python AttributeError: 'tuple' object has no attribute 'tobytes' ``` --- CHANGELOG.md | 2 ++ cvat/apps/engine/cache.py | 2 +- tests/python/rest_api/test_tasks.py | 30 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa475ea8025b..2e512b67fb86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Incorrectly determined video frame count when the video contains an MP4 edit list () +- Internal server error when retrieving data from CS and cache=True + () ### Security diff --git a/cvat/apps/engine/cache.py b/cvat/apps/engine/cache.py index 1d4c7925df8d..6f88ed51290c 100644 --- a/cvat/apps/engine/cache.py +++ b/cvat/apps/engine/cache.py @@ -169,7 +169,7 @@ def _get_images(db_data, chunk_number): cloud_storage_instance.bulk_download_to_dir(files=files_to_download, upload_dir=tmp_dir) - for checksum, fs_filename in zip(checksums, images): + for checksum, (_, fs_filename, _) in zip(checksums, images): if checksum and not md5_hash(fs_filename) == checksum: slogger.cloud_storage[db_cloud_storage.id].warning('Hash sums of files {} do not match'.format(file_name)) else: diff --git a/tests/python/rest_api/test_tasks.py b/tests/python/rest_api/test_tasks.py index 35d842bfc8c0..9d646565f3e2 100644 --- a/tests/python/rest_api/test_tasks.py +++ b/tests/python/rest_api/test_tasks.py @@ -1418,6 +1418,36 @@ def test_create_task_with_file_pattern( status = self._test_cannot_create_task(self._USERNAME, task_spec, data_spec) assert "No media data found" in status.message + @pytest.mark.with_external_services + @pytest.mark.parametrize( + "cloud_storage_id, org", + [ + (1, ""), + ], + ) + def test_create_task_with_cloud_storage_and_retrieve_data( + self, + cloud_storage_id, + cloud_storages, + request, + org, + ): + cloud_storage = cloud_storages[cloud_storage_id] + task_id, _ = self._create_task_with_cloud_data( + request=request, + cloud_storage=cloud_storage, + use_manifest=True, + use_cache=True, + server_files=[], + org=org, + ) + + with make_api_client(self._USERNAME) as api_client: + (_, response) = api_client.tasks_api.retrieve_data( + task_id, type="chunk", quality="compressed", number=0 + ) + assert response.status == HTTPStatus.OK + def test_can_specify_file_job_mapping(self): task_spec = { "name": f"test file-job mapping",