Skip to content

Commit e36b18c

Browse files
move changes
1 parent fa7072d commit e36b18c

File tree

28 files changed

+169
-43
lines changed

28 files changed

+169
-43
lines changed

packages/aws-library/requirements/ci.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
--requirement _test.txt
1212

1313
# installs this repo's packages
14+
simcore-common-library @ ../common-library
15+
simcore-models-library @ ../models-library/
1416
pytest-simcore @ ../pytest-simcore
15-
simcore-models-library @ ../models-library
1617
simcore-service-library @ ../service-library/
1718
simcore-settings-library @ ../settings-library/
1819

packages/aws-library/requirements/dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
--requirement _tools.txt
1313

1414
# installs this repo's packages
15-
--editable ../pytest-simcore
15+
--editable ../common-library/
1616
--editable ../models-library/
17+
--editable ../pytest-simcore/
1718
--editable ../service-library/
1819
--editable ../settings-library/
1920

packages/aws-library/src/aws_library/ec2/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from ._client import SimcoreEC2API
22
from ._errors import EC2AccessError, EC2NotConnectedError, EC2RuntimeError
33
from ._models import (
4+
AWS_TAG_KEY_MAX_LENGTH,
5+
AWS_TAG_KEY_MIN_LENGTH,
6+
AWS_TAG_VALUE_MAX_LENGTH,
7+
AWS_TAG_VALUE_MIN_LENGTH,
48
AWSTagKey,
59
AWSTagValue,
610
EC2InstanceBootSpecific,
@@ -14,6 +18,10 @@
1418
__all__: tuple[str, ...] = (
1519
"AWSTagKey",
1620
"AWSTagValue",
21+
"AWS_TAG_KEY_MIN_LENGTH",
22+
"AWS_TAG_KEY_MAX_LENGTH",
23+
"AWS_TAG_VALUE_MIN_LENGTH",
24+
"AWS_TAG_VALUE_MAX_LENGTH",
1725
"EC2AccessError",
1826
"EC2InstanceBootSpecific",
1927
"EC2InstanceConfig",

packages/aws-library/src/aws_library/ec2/_models.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33
import tempfile
44
from dataclasses import dataclass
5-
from typing import Annotated, TypeAlias
5+
from typing import Annotated, Final, TypeAlias
66

77
import sh # type: ignore[import-untyped]
88
from models_library.docker import DockerGenericTag
@@ -68,17 +68,21 @@ class EC2InstanceType:
6868
InstancePrivateDNSName: TypeAlias = str
6969

7070

71+
AWS_TAG_KEY_MIN_LENGTH: Final[int] = 1
72+
AWS_TAG_KEY_MAX_LENGTH: Final[int] = 128
7173
AWSTagKey: TypeAlias = Annotated[
7274
# see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions]
7375
str,
7476
StringConstraints(
75-
min_length=1,
76-
max_length=128,
77+
min_length=AWS_TAG_KEY_MIN_LENGTH,
78+
max_length=AWS_TAG_KEY_MAX_LENGTH,
7779
pattern=re.compile(r"^(?!(_index|\.{1,2})$)[a-zA-Z0-9\+\-=\._:@]+$"),
7880
),
7981
]
8082

8183

84+
AWS_TAG_VALUE_MIN_LENGTH: Final[int] = 0
85+
AWS_TAG_VALUE_MAX_LENGTH: Final[int] = 256
8286
AWSTagValue: TypeAlias = Annotated[
8387
# see [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions]
8488
# quotes []{} were added as it allows to json encode. it seems to be accepted as a value

packages/common-library/requirements/_test.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
coverage
1212
faker
13+
pydantic-settings
1314
pytest
1415
pytest-asyncio
1516
pytest-cov

packages/common-library/requirements/_test.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
annotated-types==0.7.0
2+
# via
3+
# -c requirements/_base.txt
4+
# pydantic
15
coverage==7.6.1
26
# via
37
# -r requirements/_test.in
48
# pytest-cov
5-
faker==30.1.0
9+
faker==30.3.0
610
# via -r requirements/_test.in
711
icdiff==2.0.7
812
# via pytest-icdiff
@@ -16,6 +20,17 @@ pluggy==1.5.0
1620
# via pytest
1721
pprintpp==0.4.0
1822
# via pytest-icdiff
23+
pydantic==2.9.2
24+
# via
25+
# -c requirements/../../../requirements/constraints.txt
26+
# -c requirements/_base.txt
27+
# pydantic-settings
28+
pydantic-core==2.23.4
29+
# via
30+
# -c requirements/_base.txt
31+
# pydantic
32+
pydantic-settings==2.5.2
33+
# via -r requirements/_test.in
1934
pytest==8.3.3
2035
# via
2136
# -r requirements/_test.in
@@ -44,7 +59,9 @@ pytest-sugar==1.0.0
4459
python-dateutil==2.9.0.post0
4560
# via faker
4661
python-dotenv==1.0.1
47-
# via -r requirements/_test.in
62+
# via
63+
# -r requirements/_test.in
64+
# pydantic-settings
4865
six==1.16.0
4966
# via python-dateutil
5067
termcolor==2.5.0
@@ -53,3 +70,5 @@ typing-extensions==4.12.2
5370
# via
5471
# -c requirements/_base.txt
5572
# faker
73+
# pydantic
74+
# pydantic-core

packages/common-library/requirements/_tools.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
astroid==3.3.5
22
# via pylint
3-
black==24.8.0
3+
black==24.10.0
44
# via -r requirements/../../../requirements/devenv.txt
55
build==1.2.2.post1
66
# via pip-tools
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
from typing import Annotated, TypeAlias
2-
from pydantic import AfterValidator, AnyHttpUrl
32

3+
from pydantic import AfterValidator, AnyHttpUrl, HttpUrl
44

5-
AnyHttpUrlLegacy: TypeAlias = Annotated[str, AnyHttpUrl, AfterValidator(lambda u: u.rstrip("/"))]
5+
6+
def _strip_last_slash(url: str) -> str:
7+
return url.rstrip("/")
8+
9+
10+
AnyHttpUrlLegacy: TypeAlias = Annotated[
11+
str, AnyHttpUrl, AfterValidator(_strip_last_slash)
12+
]
13+
14+
15+
HttpUrlLegacy: TypeAlias = Annotated[str, HttpUrl, AfterValidator(_strip_last_slash)]

packages/common-library/src/common_library/serialization.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import timedelta
12
from typing import Any
23

34
from common_library.pydantic_fields_extension import get_type
@@ -15,6 +16,9 @@ def model_dump_with_secrets(
1516

1617
field_data = data[field_name]
1718

19+
if isinstance(field_data, timedelta):
20+
data[field_name] = field_data.total_seconds()
21+
1822
if isinstance(field_data, SecretStr):
1923
if show_secrets:
2024
data[field_name] = field_data.get_secret_value()

packages/common-library/tests/test_errors_classes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class B12(B1, ValueError):
3838

3939
def test_error_codes_and_msg_template():
4040
class MyBaseError(OsparcErrorMixin, Exception):
41-
def __init__(self, **ctx: Any) -> None:
42-
super().__init__(**ctx) # Do not forget this for base exceptions!
41+
pass
4342

4443
class MyValueError(MyBaseError, ValueError):
4544
msg_template = "Wrong value {value}"

0 commit comments

Comments
 (0)