Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
dcb5895
upgrade aws-library
giancarloromeo Sep 16, 2024
3620668
upgrade dask-task-models-library
giancarloromeo Sep 16, 2024
85dffd8
upgrade notifications-library
giancarloromeo Sep 16, 2024
17b9457
upgrade postgres-database
giancarloromeo Sep 16, 2024
9571d2f
upgrade service-library
giancarloromeo Sep 16, 2024
bff67e6
upgrade simcore-sdk
giancarloromeo Sep 16, 2024
17681a5
upgrade settings-library
giancarloromeo Sep 16, 2024
81c045b
upgrade service-integration
giancarloromeo Sep 16, 2024
3f4901e
upgrade settings-library
giancarloromeo Sep 16, 2024
5e42c7c
bump-pydantic
giancarloromeo Sep 16, 2024
a0f2890
add type hint
giancarloromeo Sep 17, 2024
e1ac2c6
continue upgrading
giancarloromeo Sep 17, 2024
92175f8
Merge branch 'pydantic_v2_migration' into is4481/upgrade-libs
giancarloromeo Sep 18, 2024
7f3801a
continue upgrading
giancarloromeo Sep 18, 2024
a470e9e
continue upgrading
giancarloromeo Sep 18, 2024
8652f39
update base requirements
giancarloromeo Sep 18, 2024
7b3c39e
continue upgrading
giancarloromeo Sep 18, 2024
2fe2b81
replace deprecated parse_obj methods
giancarloromeo Sep 18, 2024
f320883
replace deprecated dict methods
giancarloromeo Sep 18, 2024
2b6180c
replace deprecated json methods
giancarloromeo Sep 19, 2024
c88b393
replace deprecated parse_obj_as methods
giancarloromeo Sep 19, 2024
ceb9f69
update model config access
giancarloromeo Sep 19, 2024
e0bc99b
update pydantic settings test
giancarloromeo Sep 19, 2024
18b7e37
upgrade base module
giancarloromeo Sep 19, 2024
dc3d602
fix ByteSize values
giancarloromeo Sep 19, 2024
724bed4
replace deprecated parse_obj_as method
giancarloromeo Sep 19, 2024
f2f007e
fix regex validation with look-ahead assertion
giancarloromeo Sep 19, 2024
76f1d5e
fix validate tag_key
giancarloromeo Sep 19, 2024
2112122
remove deprecated
giancarloromeo Sep 19, 2024
7404f3e
continue upgrading
giancarloromeo Sep 19, 2024
7e156d7
fix regex
giancarloromeo Sep 20, 2024
1401f2e
fix error base class
giancarloromeo Sep 20, 2024
5f553ce
continue upgrading
giancarloromeo Sep 20, 2024
6ed0551
upgrade dependencies
giancarloromeo Sep 20, 2024
c36b542
fix error base class
giancarloromeo Sep 20, 2024
49a0ab4
upgrade dependencies
giancarloromeo Sep 20, 2024
0191717
continue upgrading
giancarloromeo Sep 20, 2024
2e74551
upgrade dependencies
giancarloromeo Sep 20, 2024
c4e6fb2
fix email model validator
giancarloromeo Sep 20, 2024
0846266
ignore code type
giancarloromeo Sep 20, 2024
5601125
fix validate_call
giancarloromeo Sep 20, 2024
d47edd0
fix validate call
giancarloromeo Sep 20, 2024
6f38de2
fix faker types
giancarloromeo Sep 20, 2024
e69b9ef
continue upgrading
giancarloromeo Sep 20, 2024
9f17d51
continue upgrading
giancarloromeo Sep 20, 2024
d13f0e0
continue upgrading
giancarloromeo Sep 20, 2024
ef0e355
fix endpoint_url type
giancarloromeo Sep 20, 2024
6c30f36
fix mock
giancarloromeo Sep 20, 2024
3d734e0
fix endpoint_url type
giancarloromeo Sep 20, 2024
c667921
remove unused type ignore
giancarloromeo Sep 20, 2024
4fb2bf2
update error base class
giancarloromeo Sep 20, 2024
c11f109
fix folders error
giancarloromeo Sep 20, 2024
68fa4ae
use common osparcerrormixin
giancarloromeo Sep 20, 2024
40a4627
continue upgrading
giancarloromeo Sep 20, 2024
0563d81
upgrade dependencies
giancarloromeo Sep 20, 2024
2094d4f
continue upgrading
giancarloromeo Sep 20, 2024
57b0710
continue upgrading
giancarloromeo Sep 20, 2024
29306b1
continue upgrading
giancarloromeo Sep 22, 2024
a9c3ef3
remove deprecated parse_obj_as
giancarloromeo Sep 23, 2024
8250aff
fix url type
giancarloromeo Sep 23, 2024
6c63ccf
fix url type
giancarloromeo Sep 23, 2024
fd2f6cb
fix rabbit settings
giancarloromeo Sep 23, 2024
7a888f5
upgrade deprecated method
giancarloromeo Sep 23, 2024
b43955c
fix dns* creation
giancarloromeo Sep 23, 2024
a1a7e24
return redis dns as str
giancarloromeo Sep 23, 2024
d74f380
upgrade pydantic dependencies
giancarloromeo Sep 23, 2024
40e34e5
continue upgrading
giancarloromeo Sep 23, 2024
2843a12
continue upgrading
giancarloromeo Sep 23, 2024
c82afa5
fix anyhttpurl validation
giancarloromeo Sep 23, 2024
c96cd21
continue upgrading
giancarloromeo Sep 23, 2024
dfe63b5
continue upgrading
giancarloromeo Sep 23, 2024
0df8f60
add ignore
giancarloromeo Sep 23, 2024
56c1c89
fix errors messages
giancarloromeo Sep 23, 2024
3b15198
continue upgrading
giancarloromeo Sep 23, 2024
bb10a3d
continue upgrading
giancarloromeo Sep 23, 2024
ec0404a
continue upgrading
giancarloromeo Sep 23, 2024
96a0663
continue upgrading
giancarloromeo Sep 23, 2024
ad7ddb5
continue upgrading
giancarloromeo Sep 23, 2024
6369b33
fix test
giancarloromeo Sep 23, 2024
7d5537d
continue upgrading
giancarloromeo Sep 23, 2024
486437d
update error msg
giancarloromeo Sep 23, 2024
0167480
fix model_fields iteration
giancarloromeo Sep 23, 2024
1409f87
fix labels type
giancarloromeo Sep 23, 2024
94749e6
fix root field reference
giancarloromeo Sep 23, 2024
223e2ac
continue upgrading
giancarloromeo Sep 23, 2024
a9d30ab
fix test
giancarloromeo Sep 23, 2024
2a497f3
remove deprecated method
giancarloromeo Sep 23, 2024
32318b0
fix error output
giancarloromeo Sep 23, 2024
45baff8
fix base settings
giancarloromeo Sep 24, 2024
81f80de
fix error
giancarloromeo Sep 24, 2024
1c33bfb
fix error class
giancarloromeo Sep 24, 2024
898155d
fix nullable
giancarloromeo Sep 24, 2024
e3fc9c5
update base
giancarloromeo Sep 24, 2024
e645331
update test
giancarloromeo Sep 24, 2024
ff5533b
restore Error type
giancarloromeo Sep 24, 2024
0eaa8c8
update test
giancarloromeo Sep 24, 2024
9c22d2b
force mode_rebuild
giancarloromeo Sep 25, 2024
4e74ec7
fix port type
giancarloromeo Sep 25, 2024
0e3f7d3
continue upgrading
giancarloromeo Sep 25, 2024
6aaaea1
continue upgrading
giancarloromeo Sep 25, 2024
4ddddc9
fix AnyUrl build
giancarloromeo Sep 25, 2024
8120fff
fix field_info
giancarloromeo Sep 25, 2024
a28234d
fix utils service
giancarloromeo Sep 25, 2024
da97728
fix mypy
giancarloromeo Sep 25, 2024
06912be
set optional
giancarloromeo Sep 25, 2024
a0d6f84
set optional
giancarloromeo Sep 25, 2024
8e62f69
continue upgrading
giancarloromeo Sep 25, 2024
e3510cd
continue upgrading
giancarloromeo Sep 25, 2024
3e8ca5d
continue upgrading
giancarloromeo Sep 25, 2024
fffb812
fix cached property
giancarloromeo Sep 25, 2024
e5f9263
remove pytest.mark
giancarloromeo Sep 25, 2024
cea85f8
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-api-server
giancarloromeo Sep 25, 2024
bc208a2
fix mypy
giancarloromeo Sep 26, 2024
85eb86f
fix parse none env
giancarloromeo Sep 26, 2024
476e538
fix env list parsing
giancarloromeo Sep 26, 2024
f28c414
use BeforeValidator for country codes
giancarloromeo Sep 26, 2024
5d4a6a2
fix mypy
giancarloromeo Sep 26, 2024
1283488
fix utils cli
giancarloromeo Sep 27, 2024
5cecc63
fix encoder issues
giancarloromeo Sep 27, 2024
cbc556f
add requirements
giancarloromeo Sep 27, 2024
4c27843
skip missing data
giancarloromeo Sep 27, 2024
9c4e07e
fix import
giancarloromeo Sep 27, 2024
6c58ae5
fix option name
giancarloromeo Sep 27, 2024
76b5cba
continue ugrading
giancarloromeo Sep 27, 2024
7021117
firx param name
giancarloromeo Sep 27, 2024
5d708b6
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-api-server
giancarloromeo Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion packages/aws-library/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ aiormq==6.8.0
# via aio-pika
aiosignal==1.3.1
# via aiohttp
annotated-types==0.7.0
# via pydantic
anyio==4.4.0
# via
# fast-depends
Expand Down Expand Up @@ -105,7 +107,7 @@ orjson==3.10.7
# -r requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/_base.in
pamqp==3.3.0
# via aiormq
pydantic==1.10.17
pydantic==2.9.1
# via
# -c requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
Expand All @@ -120,6 +122,20 @@ pydantic==1.10.17
# -r requirements/../../../packages/settings-library/requirements/_base.in
# -r requirements/_base.in
# fast-depends
# pydantic-extra-types
# pydantic-settings
pydantic-core==2.23.3
# via pydantic
pydantic-extra-types==2.9.0
# via
# -r requirements/../../../packages/models-library/requirements/_base.in
# -r requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/_base.in
pydantic-settings==2.5.2
# via
# -r requirements/../../../packages/models-library/requirements/_base.in
# -r requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/_base.in
# -r requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/_base.in
# -r requirements/../../../packages/settings-library/requirements/_base.in
pygments==2.18.0
# via rich
pyinstrument==4.7.2
Expand All @@ -128,6 +144,8 @@ python-dateutil==2.9.0.post0
# via
# arrow
# botocore
python-dotenv==1.0.1
# via pydantic-settings
pyyaml==6.0.2
# via
# -c requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
Expand Down Expand Up @@ -198,6 +216,7 @@ typing-extensions==4.12.2
# aiodebug
# faststream
# pydantic
# pydantic-core
# typer
# types-aiobotocore
# types-aiobotocore-ec2
Expand Down
15 changes: 13 additions & 2 deletions packages/aws-library/requirements/_test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
annotated-types==0.7.0
# via
# -c requirements/_base.txt
# pydantic
antlr4-python3-runtime==4.13.2
# via moto
appdirs==1.4.4
Expand Down Expand Up @@ -151,11 +155,15 @@ py-partiql-parser==0.5.5
# via moto
pycparser==2.22
# via cffi
pydantic==1.10.17
pydantic==2.9.1
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
# aws-sam-translator
pydantic-core==2.23.3
# via
# -c requirements/_base.txt
# pydantic
pyparsing==3.1.2
# via moto
pytest==8.3.2
Expand Down Expand Up @@ -193,7 +201,9 @@ python-dateutil==2.9.0.post0
# faker
# moto
python-dotenv==1.0.1
# via -r requirements/_test.in
# via
# -c requirements/_base.txt
# -r requirements/_test.in
pyyaml==6.0.2
# via
# -c requirements/../../../requirements/constraints.txt
Expand Down Expand Up @@ -268,6 +278,7 @@ typing-extensions==4.12.2
# flexparser
# pint
# pydantic
# pydantic-core
# types-aioboto3
# types-aiobotocore
urllib3==2.2.2
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-library/src/aws_library/ec2/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def create(cls, settings: EC2Settings) -> "SimcoreEC2API":
session = aioboto3.Session()
session_client = session.client(
"ec2",
endpoint_url=settings.EC2_ENDPOINT,
endpoint_url=str(settings.EC2_ENDPOINT),
aws_access_key_id=settings.EC2_ACCESS_KEY_ID,
aws_secret_access_key=settings.EC2_SECRET_ACCESS_KEY,
region_name=settings.EC2_REGION_NAME,
Expand Down
85 changes: 47 additions & 38 deletions packages/aws-library/src/aws_library/ec2/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
import re
import tempfile
from dataclasses import dataclass
from typing import Any, ClassVar, TypeAlias
from typing import Annotated, TypeAlias

import sh # type: ignore[import-untyped]
from models_library.docker import DockerGenericTag
from pydantic import (
BaseModel,
ByteSize,
ConstrainedStr,
ConfigDict,
Field,
NonNegativeFloat,
NonNegativeInt,
validator,
StringConstraints,
field_validator,
)
from types_aiobotocore_ec2.literals import InstanceStateNameType, InstanceTypeType

Expand All @@ -33,26 +34,26 @@ def __gt__(self, other: "Resources") -> bool:
return self.cpus > other.cpus or self.ram > other.ram

def __add__(self, other: "Resources") -> "Resources":
return Resources.construct(
return Resources.model_construct(
**{
key: a + b
for (key, a), b in zip(
self.dict().items(), other.dict().values(), strict=True
self.model_dump().items(), other.model_dump().values(), strict=True
)
}
)

def __sub__(self, other: "Resources") -> "Resources":
return Resources.construct(
return Resources.model_construct(
**{
key: a - b
for (key, a), b in zip(
self.dict().items(), other.dict().values(), strict=True
self.model_dump().items(), other.model_dump().values(), strict=True
)
}
)

@validator("cpus", pre=True)
@field_validator("cpus", mode="before")
@classmethod
def _floor_cpus_to_0(cls, v: float) -> float:
return max(v, 0)
Expand All @@ -67,19 +68,26 @@ class EC2InstanceType:
InstancePrivateDNSName: TypeAlias = str


class AWSTagKey(ConstrainedStr):
# see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions]
regex = re.compile(r"^(?!(_index|\.{1,2})$)[a-zA-Z0-9\+\-=\._:@]+$")
min_length = 1
max_length = 128


class AWSTagValue(ConstrainedStr):
# see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions]
# quotes []{} were added as it allows to json encode. it seems to be accepted as a value
regex = re.compile(r"^[a-zA-Z0-9\s\+\-=\.,_:/@\"\'\[\]\{\}]*$")
min_length = 0
max_length = 256
# see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions]
AWSTagKey: TypeAlias = Annotated[
str,
StringConstraints(
min_length=1,
max_length=128,
pattern=re.compile(r"^(?!(_index|\.{1,2})$)[a-zA-Z0-9\+\-=\._:@]+$"),
),
]

# see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions]
# quotes []{} were added as it allows to json encode. it seems to be accepted as a value
AWSTagValue: TypeAlias = Annotated[
str,
StringConstraints(
min_length=0,
max_length=256,
pattern=r"^[a-zA-Z0-9\s\+\-=\.,_:/@\"\'\[\]\{\}]*$",
),
]


EC2Tags: TypeAlias = dict[AWSTagKey, AWSTagValue]
Expand Down Expand Up @@ -148,8 +156,23 @@ class EC2InstanceBootSpecific(BaseModel):
default=0, description="number of buffer EC2s to keep (defaults to 0)"
)

class Config:
schema_extra: ClassVar[dict[str, Any]] = {
@field_validator("custom_boot_scripts")
@classmethod
def validate_bash_calls(cls, v):
try:
with tempfile.NamedTemporaryFile(mode="wt", delete=True) as temp_file:
temp_file.writelines(v)
temp_file.flush()
# NOTE: this will not capture runtime errors, but at least some syntax errors such as invalid quotes
sh.bash("-n", temp_file.name)
except sh.ErrorReturnCode as exc:
msg = f"Invalid bash call in custom_boot_scripts: {v}, Error: {exc.stderr}"
raise ValueError(msg) from exc

return v

model_config = ConfigDict(
json_schema_extra={
"examples": [
{
# just AMI
Expand Down Expand Up @@ -205,18 +228,4 @@ class Config:
},
]
}

@validator("custom_boot_scripts")
@classmethod
def validate_bash_calls(cls, v):
try:
with tempfile.NamedTemporaryFile(mode="wt", delete=True) as temp_file:
temp_file.writelines(v)
temp_file.flush()
# NOTE: this will not capture runtime errors, but at least some syntax errors such as invalid quotes
sh.bash("-n", temp_file.name)
except sh.ErrorReturnCode as exc:
msg = f"Invalid bash call in custom_boot_scripts: {v}, Error: {exc.stderr}"
raise ValueError(msg) from exc

return v
)
15 changes: 7 additions & 8 deletions packages/aws-library/src/aws_library/s3/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from botocore.client import Config
from models_library.api_schemas_storage import ETag, S3BucketName, UploadedPart
from models_library.basic_types import SHA256Str
from pydantic import AnyUrl, ByteSize, parse_obj_as
from pydantic import AnyUrl, ByteSize, TypeAdapter
from servicelib.logging_utils import log_catch, log_context
from servicelib.utils import limited_gather
from settings_library.s3 import S3Settings
Expand Down Expand Up @@ -70,7 +70,7 @@ async def create(
session = aioboto3.Session()
session_client = session.client(
"s3",
endpoint_url=settings.S3_ENDPOINT,
endpoint_url=str(settings.S3_ENDPOINT),
aws_access_key_id=settings.S3_ACCESS_KEY,
aws_secret_access_key=settings.S3_SECRET_KEY,
region_name=settings.S3_REGION,
Expand Down Expand Up @@ -260,7 +260,7 @@ async def create_single_presigned_download_link(
Params={"Bucket": bucket, "Key": object_key},
ExpiresIn=expiration_secs,
)
url: AnyUrl = parse_obj_as(AnyUrl, generated_link)
url: AnyUrl = TypeAdapter(AnyUrl).validate_python(generated_link)
return url

@s3_exception_handler(_logger)
Expand All @@ -274,7 +274,7 @@ async def create_single_presigned_upload_link(
Params={"Bucket": bucket, "Key": object_key},
ExpiresIn=expiration_secs,
)
url: AnyUrl = parse_obj_as(AnyUrl, generated_link)
url: AnyUrl = TypeAdapter(AnyUrl).validate_python(generated_link)
return url

@s3_exception_handler(_logger)
Expand All @@ -298,8 +298,7 @@ async def create_multipart_upload_links(
# compute the number of links, based on the announced file size
num_upload_links, chunk_size = compute_num_file_chunks(file_size)
# now create the links
upload_links = parse_obj_as(
list[AnyUrl],
upload_links = TypeAdapter(list[AnyUrl]).validate_python(
await asyncio.gather(
*(
self._client.generate_presigned_url(
Expand Down Expand Up @@ -473,7 +472,7 @@ def is_multipart(file_size: ByteSize) -> bool:

@staticmethod
def compute_s3_url(*, bucket: S3BucketName, object_key: S3ObjectKey) -> AnyUrl:
url: AnyUrl = parse_obj_as(
AnyUrl, f"s3://{bucket}/{urllib.parse.quote(object_key)}"
url: AnyUrl = TypeAdapter(AnyUrl).validate_python(
f"s3://{bucket}/{urllib.parse.quote(object_key)}"
)
return url
14 changes: 9 additions & 5 deletions packages/aws-library/src/aws_library/s3/_constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from typing import Final

from pydantic import ByteSize, parse_obj_as
from pydantic import ByteSize, TypeAdapter

# NOTE: AWS S3 upload limits https://docs.aws.amazon.com/AmazonS3/latest/userguide/qfacts.html
MULTIPART_UPLOADS_MIN_TOTAL_SIZE: Final[ByteSize] = parse_obj_as(ByteSize, "100MiB")
MULTIPART_COPY_THRESHOLD: Final[ByteSize] = parse_obj_as(ByteSize, "100MiB")
MULTIPART_UPLOADS_MIN_TOTAL_SIZE: Final[ByteSize] = TypeAdapter(
ByteSize
).validate_python("100MiB")
MULTIPART_COPY_THRESHOLD: Final[ByteSize] = TypeAdapter(ByteSize).validate_python(
"100MiB"
)

PRESIGNED_LINK_MAX_SIZE: Final[ByteSize] = parse_obj_as(ByteSize, "5GiB")
S3_MAX_FILE_SIZE: Final[ByteSize] = parse_obj_as(ByteSize, "5TiB")
PRESIGNED_LINK_MAX_SIZE: Final[ByteSize] = TypeAdapter(ByteSize).validate_python("5GiB")
S3_MAX_FILE_SIZE: Final[ByteSize] = TypeAdapter(ByteSize).validate_python("5TiB")
14 changes: 7 additions & 7 deletions packages/aws-library/src/aws_library/s3/_errors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic.errors import PydanticErrorMixin
from models_library.errors_classes import OsparcErrorMixin


class S3RuntimeError(PydanticErrorMixin, RuntimeError):
class S3RuntimeError(OsparcErrorMixin, RuntimeError):
msg_template: str = "S3 client unexpected error"


Expand All @@ -10,25 +10,25 @@ class S3NotConnectedError(S3RuntimeError):


class S3AccessError(S3RuntimeError):
code = "s3_access.error"
code = "s3_access.error" # type: ignore[assignment]
msg_template: str = "Unexpected error while accessing S3 backend"


class S3BucketInvalidError(S3AccessError):
code = "s3_bucket.invalid_error"
code = "s3_bucket.invalid_error" # type: ignore[assignment]
msg_template: str = "The bucket '{bucket}' is invalid"


class S3KeyNotFoundError(S3AccessError):
code = "s3_key.not_found_error"
code = "s3_key.not_found_error" # type: ignore[assignment]
msg_template: str = "The file {key} in {bucket} was not found"


class S3UploadNotFoundError(S3AccessError):
code = "s3_upload.not_found_error"
code = "s3_upload.not_found_error" # type: ignore[assignment]
msg_template: str = "The upload for {key} in {bucket} was not found"


class S3DestinationNotEmptyError(S3AccessError):
code = "s3_destination.not_empty_error"
code = "s3_destination.not_empty_error" # type: ignore[assignment]
msg_template: str = "The destination {dst_prefix} is not empty"
4 changes: 2 additions & 2 deletions packages/aws-library/src/aws_library/s3/_utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Final

from pydantic import ByteSize, parse_obj_as
from pydantic import ByteSize, TypeAdapter

_MULTIPART_MAX_NUMBER_OF_PARTS: Final[int] = 10000

# this is artifically defined, if possible we keep a maximum number of requests for parallel
# uploading. If that is not possible then we create as many upload part as the max part size allows
_MULTIPART_UPLOADS_TARGET_MAX_PART_SIZE: Final[list[ByteSize]] = [
parse_obj_as(ByteSize, x)
TypeAdapter(ByteSize).validate_python(x)
for x in [
"10Mib",
"50Mib",
Expand Down
Loading
Loading