Start cleaning up unused imports #1035
6 fail, 4 skipped, 275 pass in 15m 39s
Annotations
Check warning on line 0 in datasets.test_dataset_helpers
github-actions / SDK integration test report
test_obtain_re_encode_video_status_and_re_encoded_link[ssh-key-authentication] (datasets.test_dataset_helpers) failed
./encord-backend/projects/sdk-integration-tests/integration-test-report-python3_13.xml [took 5s]
Raw output
encord.exceptions.AuthorisationError: You are not authorised to access this asset. timestamp='2025-11-27T10:57:00.677933+00:00' trace_id='e167017e04d046d780b3732a58257781' span_id='1' domain='https://dev.api.encord.com/'
ephemeral_cord_dataset_client = <encord.dataset.Dataset object at 0x7f67bbbc2690>
def test_obtain_re_encode_video_status_and_re_encoded_link(
ephemeral_cord_dataset_client: EncordClientDataset | Dataset,
) -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
directory_path = Path(tmp_dir)
file_path = directory_path / VIDEO_1
create_mp4_file([file_path])
ephemeral_cord_dataset_client.upload_video(file_path)
dataset = ephemeral_cord_dataset_client.get_dataset()
data_hash = dataset["data_rows"][0]["data_hash"]
> job_id = ephemeral_cord_dataset_client.re_encode_data([data_hash])
src/sdk_integration_tests/tests/datasets/test_dataset_helpers.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.11/site-packages/encord/dataset.py:463: in re_encode_data
return self._client.re_encode_data(data_hashes)
.venv/lib/python3.11/site-packages/encord/client.py:773: in re_encode_data
return self._querier.basic_put(ReEncodeVideoTask, uid=None, payload=payload)
.venv/lib/python3.11/site-packages/encord/http/querier.py:137: in basic_put
res, context = self._execute(request, retryable=retryable, enable_logging=enable_logging)
.venv/lib/python3.11/site-packages/encord/http/querier.py:208: in _execute
check_error_response(response, context, extra_payload)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = ['AUTHORISATION_ERROR']
context = RequestContext(timestamp='2025-11-27T10:57:00.677933+00:00', trace_id='e167017e04d046d780b3732a58257781', span_id='1', domain='https://dev.api.encord.com/')
payload = 'You are not authorized to re-encode videos.'
def check_error_response(response, context: Optional[RequestContext] = None, payload: Any = None):
"""Checks server response.
Called if HTTP response status code is an error response.
"""
if response == AUTHENTICATION_ERROR:
raise AuthenticationError("You are not authenticated to access the Encord platform.", context=context)
if response == AUTHORISATION_ERROR:
> raise AuthorisationError("You are not authorised to access this asset.", context=context)
E encord.exceptions.AuthorisationError: You are not authorised to access this asset. timestamp='2025-11-27T10:57:00.677933+00:00' trace_id='e167017e04d046d780b3732a58257781' span_id='1' domain='https://dev.api.encord.com/'
.venv/lib/python3.11/site-packages/encord/http/error_utils.py:64: AuthorisationError
Check warning on line 0 in projects.test_editor_logs
github-actions / SDK integration test report
test_read_logs_works (projects.test_editor_logs) failed
./encord-backend/projects/sdk-integration-tests/integration-test-report-python3_13.xml [took 2s]
Raw output
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://dev.api.encord.com/v2/projects/e2fc266d-0052-446f-b014-9be9f5ce87be/editor-logs
ephemeral_user_client = <encord.user_client.EncordUserClient object at 0x7f67b493d210>
ephemeral_project_hash = 'e2fc266d-0052-446f-b014-9be9f5ce87be'
@pytest.mark.skipif(ENCORD_VERSION < "0.1.179", reason="Editor logs feature only available from this version")
def test_read_logs_works(ephemeral_user_client: EncordUserClient, ephemeral_project_hash: str) -> None:
user_bearer_token = get_firebase_bearer_token(USER_EMAIL, PASSWORD)
project = ephemeral_user_client.get_project(ephemeral_project_hash)
start_time = get_utc_datetime_now() - timedelta(days=29)
end_time = get_utc_datetime_now()
logs = project.get_editor_logs(start_time=start_time, end_time=end_time)
assert len(list(logs)) == 0, "No logs have been added"
# Insert some test editor logs using the API directly
> original_logs = _insert_test_editor_logs(ephemeral_user_client, ephemeral_project_hash, user_bearer_token)
src/sdk_integration_tests/tests/projects/test_editor_logs.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/sdk_integration_tests/tests/projects/test_editor_logs.py:207: in _insert_test_editor_logs
response.raise_for_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://dev.api.encord.com/v2/projects/e2fc266d-0052-446f-b014-9be9f5ce87be/editor-logs
.venv/lib/python3.11/site-packages/requests/models.py:1026: HTTPError
Check warning on line 0 in projects.test_editor_logs
github-actions / SDK integration test report
test_filters_work (projects.test_editor_logs) failed
./encord-backend/projects/sdk-integration-tests/integration-test-report-python3_13.xml [took 2s]
Raw output
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://dev.api.encord.com/v2/projects/0e858552-fb2a-4863-b0b3-7e651c3b2c21/editor-logs
ephemeral_user_client = <encord.user_client.EncordUserClient object at 0x7f67b4ea4750>
ephemeral_project_hash = '0e858552-fb2a-4863-b0b3-7e651c3b2c21'
@pytest.mark.skipif(ENCORD_VERSION < "0.1.179", reason="Editor logs feature only available from this version")
def test_filters_work(ephemeral_user_client: EncordUserClient, ephemeral_project_hash: str) -> None:
user_bearer_token = get_firebase_bearer_token(USER_EMAIL, PASSWORD)
project = ephemeral_user_client.get_project(ephemeral_project_hash)
> original_logs = _insert_test_editor_logs(ephemeral_user_client, ephemeral_project_hash, user_bearer_token)
src/sdk_integration_tests/tests/projects/test_editor_logs.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/sdk_integration_tests/tests/projects/test_editor_logs.py:207: in _insert_test_editor_logs
response.raise_for_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [401]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://dev.api.encord.com/v2/projects/0e858552-fb2a-4863-b0b3-7e651c3b2c21/editor-logs
.venv/lib/python3.11/site-packages/requests/models.py:1026: HTTPError
Check warning on line 0 in projects.test_ontology
github-actions / SDK integration test report
test_get_ontologies_include_org_access (projects.test_ontology) failed
./encord-backend/projects/sdk-integration-tests/integration-test-report-python3_13.xml [took 3s]
Raw output
Failed: DID NOT RAISE <class 'encord.exceptions.AuthorisationError'>
main_account_user_client = <encord.user_client.EncordUserClient object at 0x7f214af92cd0>
service_account_user_client = <encord.user_client.EncordUserClient object at 0x7f214af92ed0>
ephemeral_user_client_non_org_user = <encord.user_client.EncordUserClient object at 0x7f214af92b50>
runid = 'c9627b1d-badb-403d-9f9f-370f2da8ddd9'
main_account_ontology = <encord.ontology.Ontology object at 0x7f214af90310>
service_account_ontology = <encord.ontology.Ontology object at 0x7f214af91990>
@pytest.mark.skipif(
"include_org_access" not in inspect.signature(EncordUserClient.get_ontologies).parameters,
reason="'include_org_access' not supported",
)
def test_get_ontologies_include_org_access(
main_account_user_client: EncordUserClient,
service_account_user_client: EncordUserClient,
ephemeral_user_client_non_org_user: EncordUserClient,
runid: str,
main_account_ontology: Ontology,
service_account_ontology: Ontology,
) -> None:
main_own_ontologies = main_account_user_client.get_ontologies(
include_org_access=False, # type: ignore[call-arg, unused-ignore]
title_like=f"%{runid}",
)
assert len(main_own_ontologies) == 1
assert main_own_ontologies[0]["ontology"].ontology_hash == main_account_ontology.ontology_hash
assert main_own_ontologies[0]["user_role"] == OntologyUserRole.ADMIN
service_own_ontologies = service_account_user_client.get_ontologies(
include_org_access=False, # type: ignore[call-arg, unused-ignore]
title_like=f"%{runid}",
)
assert len(service_own_ontologies) == 1
assert service_own_ontologies[0]["ontology"].ontology_hash == service_account_ontology.ontology_hash
assert service_own_ontologies[0]["user_role"] == OntologyUserRole.ADMIN
main_all_ontologies = main_account_user_client.get_ontologies(
include_org_access=True, # type: ignore[call-arg, unused-ignore]
title_like=f"%{runid}",
)
assert len(main_all_ontologies) == 2
main_ontology_info = next(
o for o in main_all_ontologies if o["ontology"].ontology_hash == main_account_ontology.ontology_hash
)
assert main_ontology_info["user_role"] == OntologyUserRole.ADMIN
service_ontology_info = next(
o for o in main_all_ontologies if o["ontology"].ontology_hash == service_account_ontology.ontology_hash
)
assert service_ontology_info["user_role"] is None
nothing_accessible_for_external_user = ephemeral_user_client_non_org_user.get_ontologies(
include_org_access=False, # type: ignore[call-arg, unused-ignore]
title_like=f"%{runid}",
)
assert len(nothing_accessible_for_external_user) == 0
> with pytest.raises(AuthorisationError):
E Failed: DID NOT RAISE <class 'encord.exceptions.AuthorisationError'>
src/sdk_integration_tests/tests/projects/test_ontology.py:195: Failed
Check warning on line 0 in projects.test_user_client_projects
github-actions / SDK integration test report
test_list_projects (projects.test_user_client_projects) failed
./encord-backend/projects/sdk-integration-tests/integration-test-report-python3_13.xml [took 1m 35s]
Raw output
assert not True
+ where True = any(<generator object test_list_projects.<locals>.<genexpr> at 0x7f67b4ee5620>)
main_account_user_client = <encord.user_client.EncordUserClient object at 0x7f67c0d2bd90>
ephemeral_user_client_non_org_user = <encord.user_client.EncordUserClient object at 0x7f67c0d2b6d0>
ephemeral_project_hash = '537b7aae-76a0-4123-b047-d729a30f691d'
non_org_project_hash = '62f64869-d40c-4073-81a3-d56d4b4ff0b5'
service_account_project_hash = '87021f4f-4c34-4642-abd4-c5b6cd098eb2'
@pytest.mark.skipif(not hasattr(EncordUserClient, "list_projects"), reason="list_projects not implemented")
def test_list_projects(
main_account_user_client: EncordUserClient,
ephemeral_user_client_non_org_user: EncordUserClient,
ephemeral_project_hash: str,
non_org_project_hash: str,
service_account_project_hash: str,
) -> None:
ephemeral_project = main_account_user_client.get_project(ephemeral_project_hash)
projects = main_account_user_client.list_projects() # type: ignore[attr-defined, unused-ignore]
project_from_listing = next(pr for pr in projects if pr.project_hash == ephemeral_project_hash)
assert project_from_listing.user_role == ProjectUserRole.ADMIN
projects = main_account_user_client.list_projects(title_like=ephemeral_project.title[:6] + "%") # type: ignore[attr-defined, unused-ignore]
# get matching
project_from_listing = next(pr for pr in projects if pr.project_hash == ephemeral_project_hash)
assert project_from_listing.user_role == ProjectUserRole.ADMIN
projects = main_account_user_client.list_projects(title_like=str(uuid.uuid4()) + ephemeral_project.title[:6] + "%") # type: ignore[attr-defined, unused-ignore]
assert len(list(projects)) == 0
yesterday = project_from_listing.created_at - timedelta(days=1)
projects = main_account_user_client.list_projects( # type: ignore[attr-defined, unused-ignore]
created_after=yesterday, title_like=ephemeral_project.title[:4] + "%"
)
project_from_listing = next(pr for pr in projects if pr.project_hash == ephemeral_project_hash)
assert project_from_listing.user_role == ProjectUserRole.ADMIN
tomorrow = project_from_listing.created_at + timedelta(days=1)
projects = main_account_user_client.list_projects( # type: ignore[attr-defined, unused-ignore]
title_eq=ephemeral_project.title,
created_after=tomorrow.isoformat(),
)
assert len(list(projects)) == 0
projects = main_account_user_client.list_projects() # type: ignore[attr-defined, unused-ignore]
assert not any(pr.project_hash == non_org_project_hash for pr in projects)
assert not any(pr.project_hash == service_account_project_hash for pr in projects)
projects = list(main_account_user_client.list_projects(include_org_access=True)) # type: ignore[attr-defined, unused-ignore]
> assert not any(pr.project_hash == non_org_project_hash for pr in projects)
E assert not True
E + where True = any(<generator object test_list_projects.<locals>.<genexpr> at 0x7f67b4ee5620>)
src/sdk_integration_tests/tests/projects/test_user_client_projects.py:147: AssertionError
Check warning on line 0 in storage.test_storage_video_operations
github-actions / SDK integration test report
test_reencode_video (storage.test_storage_video_operations) failed
./encord-backend/projects/sdk-integration-tests/integration-test-report-python3_13.xml [took 4s]
Raw output
encord.exceptions.AuthorisationError: You are not authorized to re-encode videos. timestamp='2025-11-27T11:09:03.533834+00:00' trace_id='0b38e44f01b349cd8d3b8c3e9e3eda9b' span_id='1' domain='https://dev.api.encord.com'
video_in_folder = UUID('2d7af114-574d-40a8-82c8-a5d5a233be22')
storage_folder = <encord.storage.StorageFolder object at 0x7f21378fc3d0>
def test_reencode_video(video_in_folder: UUID, storage_folder: StorageFolder) -> None:
assert set(item.name for item in storage_folder.list_items(search=VIDEO_TITLE)) == {f"{VIDEO_TITLE}.mp4"}
> process = storage_folder.re_encode_videos([video_in_folder], "play nicely", False)
src/sdk_integration_tests/tests/storage/test_storage_video_operations.py:43:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.11/site-packages/encord/storage.py:329: in re_encode_videos
return self._api_client.post(
.venv/lib/python3.11/site-packages/encord/http/v2/api_client.py:117: in post
return self._request_with_payload(
.venv/lib/python3.11/site-packages/encord/http/v2/api_client.py:200: in _request_with_payload
return self._request(
.venv/lib/python3.11/site-packages/encord/http/v2/api_client.py:256: in _request
self._handle_error(res, context)
.venv/lib/python3.11/site-packages/encord/http/v2/api_client.py:302: in _handle_error
raise e
.venv/lib/python3.11/site-packages/encord/http/v2/api_client.py:295: in _handle_error
handle_error_response(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
status_code = 403
response_headers = {'date': 'Thu, 27 Nov 2025 11:09:03 GMT', 'Content-Length': '147', 'content-type': 'application/json', 'via': '1.1 goo...; includeSubDomains', 'x-content-type-options': 'nosniff', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}
message = 'You are not authorized to re-encode videos.'
context = RequestContext(timestamp='2025-11-27T11:09:03.533834+00:00', trace_id='0b38e44f01b349cd8d3b8c3e9e3eda9b', span_id='1', domain='https://dev.api.encord.com')
def handle_error_response(status_code: int, response_headers: Mapping[str, str], message=None, context=None):
"""Checks server response.
Called if HTTP response status code is an error response.
"""
if status_code == HTTP_UNAUTHORIZED:
raise AuthenticationError(
message or "You are not authenticated to access the Encord platform.", context=context
)
if status_code == HTTP_FORBIDDEN:
> raise AuthorisationError(message or "You are not authorised to access this asset.", context=context)
E encord.exceptions.AuthorisationError: You are not authorized to re-encode videos. timestamp='2025-11-27T11:09:03.533834+00:00' trace_id='0b38e44f01b349cd8d3b8c3e9e3eda9b' span_id='1' domain='https://dev.api.encord.com'
.venv/lib/python3.11/site-packages/encord/http/v2/error_utils.py:34: AuthorisationError