-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Enhancement/3022/allow setting services scheduler specs (⚠️ devops) (…
- Loading branch information
Showing
51 changed files
with
5,926 additions
and
418 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
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
41 changes: 41 additions & 0 deletions
41
packages/models-library/src/models_library/aiodocker_api.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import Optional | ||
|
||
from pydantic import Field, validator | ||
|
||
from .generated_models.docker_rest_api import ContainerSpec, ServiceSpec, TaskSpec | ||
from .utils.converters import to_snake_case | ||
|
||
|
||
class AioDockerContainerSpec(ContainerSpec): | ||
Env: Optional[dict[str, str]] = Field( | ||
None, | ||
description="aiodocker expects here a dictionary and re-convert it back internally`.\n", | ||
) | ||
|
||
@validator("Env", pre=True) | ||
@classmethod | ||
def convert_list_to_dict(cls, v): | ||
if v is not None and isinstance(v, list): | ||
converted_dict = {} | ||
for env in v: | ||
splitted_env = f"{env}".split("=", maxsplit=1) | ||
converted_dict[splitted_env[0]] = ( | ||
splitted_env[1] if len(splitted_env) > 1 else None | ||
) | ||
return converted_dict | ||
return v | ||
|
||
|
||
class AioDockerTaskSpec(TaskSpec): | ||
ContainerSpec: Optional[AioDockerContainerSpec] = Field( | ||
None, | ||
) | ||
|
||
|
||
class AioDockerServiceSpec(ServiceSpec): | ||
|
||
TaskTemplate: Optional[AioDockerTaskSpec] = None | ||
|
||
class Config(ServiceSpec.Config): | ||
alias_generator = to_snake_case | ||
allow_population_by_field_name = True |
Empty file.
Oops, something went wrong.