Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rok4/core-python
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolite committed Feb 8, 2024
2 parents 80e7499 + 90c9466 commit 8a5f0b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: ".venv|__pycache__|tests/dev/|tests/fixtures/"
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
Expand All @@ -22,25 +22,25 @@ repos:
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.291"
rev: "v0.1.9"
hooks:
- id: ruff
args: ["--fix-only", "--target-version=py38"]

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.12.1
hooks:
- id: black
args: ["--target-version=py38"]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.0
hooks:
- id: pyupgrade
args:
Expand Down
7 changes: 5 additions & 2 deletions src/rok4/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def __get_cached_data_binary(path: str, ttl_hash: int, range: Tuple[int, int] =
)

except botocore.exceptions.ClientError as e:
if e.response["Error"]["Code"] == "404":
if e.response["Error"]["Code"] == "NoSuchKey":
raise FileNotFoundError(f"{storage_type.value}{path}")
else:
raise StorageError("S3", e)
Expand Down Expand Up @@ -443,6 +443,9 @@ def get_data_binary(path: str, range: Tuple[int, int] = None) -> str:
Returns:
str: Data binary content
"""
print("########################################")
print(f"get_data_binary {path}")
print("########################################")
return __get_cached_data_binary(path, __get_ttl_hash(), range)


Expand Down Expand Up @@ -573,7 +576,7 @@ def exists(path: str) -> bool:
s3_client["client"].head_object(Bucket=bucket_name, Key=base_name)
return True
except botocore.exceptions.ClientError as e:
if e.response["Error"]["Code"] == "404":
if e.response["Error"]["Code"] == "NoSuchKey":
return False
else:
raise StorageError("S3", e)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def test_exists_s3_ok(mocked_s3_client):
assert False, f"S3 exists raises an exception: {exc}"

s3_instance.head_object.side_effect = botocore.exceptions.ClientError(
operation_name="InvalidKeyPair.Duplicate", error_response={"Error": {"Code": "404"}}
operation_name="InvalidKeyPair.Duplicate", error_response={"Error": {"Code": "NoSuchKey"}}
)
try:
assert not exists("s3://bucket/object.ext")
Expand Down

0 comments on commit 8a5f0b2

Please sign in to comment.