forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes [unit] webserver 03 and [unit] settings-library (both mypy and …
…tests) (ITISFoundation#6773)
- Loading branch information
Showing
8 changed files
with
77 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from enum import StrEnum | ||
|
||
|
||
class LogLevel(StrEnum): | ||
DEBUG = "DEBUG" | ||
INFO = "INFO" | ||
WARNING = "WARNING" | ||
ERROR = "ERROR" | ||
|
||
|
||
class BootModeEnum(StrEnum): | ||
""" | ||
Values taken by SC_BOOT_MODE environment variable | ||
set in Dockerfile and used during docker/boot.sh | ||
""" | ||
|
||
DEFAULT = "default" | ||
LOCAL = "local-development" | ||
DEBUG = "debug" | ||
PRODUCTION = "production" | ||
DEVELOPMENT = "development" | ||
|
||
def is_devel_mode(self) -> bool: | ||
"""returns True if this boot mode is used for development""" | ||
return self in (self.DEBUG, self.DEVELOPMENT, self.LOCAL) | ||
|
||
|
||
class BuildTargetEnum(StrEnum): | ||
""" | ||
Values taken by SC_BUILD_TARGET environment variable | ||
set in Dockerfile that defines the stage targeted in the | ||
docker image build | ||
""" | ||
|
||
BUILD = "build" | ||
CACHE = "cache" | ||
PRODUCTION = "production" | ||
DEVELOPMENT = "development" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 14 additions & 40 deletions
54
packages/settings-library/src/settings_library/basic_types.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,31 @@ | ||
# | ||
# NOTE: This file copies some of the types from models_library.basic_types | ||
# This is a minor evil to avoid the maintenance burden that creates | ||
# an extra dependency to a larger models_library (intra-repo library) | ||
|
||
from enum import StrEnum | ||
from enum import Enum | ||
from typing import Annotated, TypeAlias | ||
|
||
from common_library.basic_types import BootModeEnum, BuildTargetEnum, LogLevel | ||
from pydantic import Field, StringConstraints | ||
|
||
assert issubclass(LogLevel, Enum) # nosec | ||
assert issubclass(BootModeEnum, Enum) # nosec | ||
assert issubclass(BuildTargetEnum, Enum) # nosec | ||
|
||
__all__: tuple[str, ...] = ( | ||
"LogLevel", | ||
"BootModeEnum", | ||
"BuildTargetEnum", | ||
) | ||
|
||
|
||
# port number range | ||
PortInt: TypeAlias = Annotated[int, Field(gt=0, lt=65535)] | ||
RegisteredPortInt: TypeAlias = Annotated[int, Field(gt=1024, lt=65535)] | ||
|
||
|
||
# e.g. 'v5' | ||
VersionTag: TypeAlias = Annotated[str, StringConstraints(pattern=r"^v\d$")] | ||
|
||
|
||
class LogLevel(StrEnum): | ||
DEBUG = "DEBUG" | ||
INFO = "INFO" | ||
WARNING = "WARNING" | ||
ERROR = "ERROR" | ||
|
||
|
||
class BootMode(StrEnum): | ||
""" | ||
Values taken by SC_BOOT_MODE environment variable | ||
set in Dockerfile and used during docker/boot.sh | ||
""" | ||
|
||
DEFAULT = "default" | ||
LOCAL = "local-development" | ||
DEBUG = "debug" | ||
PRODUCTION = "production" | ||
DEVELOPMENT = "development" | ||
|
||
|
||
class BuildTargetEnum(StrEnum): | ||
""" | ||
Values taken by SC_BUILD_TARGET environment variable | ||
set in Dockerfile that defines the stage targeted in the | ||
docker image build | ||
""" | ||
|
||
BUILD = "build" | ||
CACHE = "cache" | ||
PRODUCTION = "production" | ||
DEVELOPMENT = "development" | ||
|
||
|
||
# non-empty bounded string used as identifier | ||
# e.g. "123" or "name_123" or "fa327c73-52d8-462a-9267-84eeaf0f90e3" but NOT "" | ||
IDStr: TypeAlias = Annotated[ | ||
str, StringConstraints(strip_whitespace=True, min_length=1, max_length=50) | ||
] | ||
RegisteredPortInt: TypeAlias = Annotated[int, Field(gt=1024, lt=65535)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters