Skip to content

Commit

Permalink
Fixed error when getting data from CS and cache=True (#6932)
Browse files Browse the repository at this point in the history
Fix 
```python
AttributeError: 'tuple' object has no attribute 'tobytes'
```
  • Loading branch information
azhavoro committed Oct 2, 2023
1 parent 92906a7 commit 2dfe6db
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
(<https://github.com/opencv/cvat/pull/6929>)
- Internal server error when retrieving data from CS and cache=True
(<https://github.com/opencv/cvat/pull/6932>)

### Security

Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions tests/python/rest_api/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2dfe6db

Please sign in to comment.