From 0e5de35c92a380c45b07a3eaee44d0ffb1e91b82 Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Mon, 2 Oct 2023 09:48:07 +0530 Subject: [PATCH 01/10] Add missing docker compose apis --- .gitignore | 23 +++++++ python_on_whales/components/compose/models.py | 60 ++++++++++++++++--- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index c10ddcb9..c6361be6 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,26 @@ dmypy.json .pyre/ docs/generated_sources docs/site + +### Intellij+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml diff --git a/python_on_whales/components/compose/models.py b/python_on_whales/components/compose/models.py index d81ed707..eedc8d0e 100644 --- a/python_on_whales/components/compose/models.py +++ b/python_on_whales/components/compose/models.py @@ -39,7 +39,20 @@ class ComposeServiceBuild(BaseModel): context: Optional[Path] = None dockerfile: Optional[Path] = None args: Optional[Dict[str, Any]] = None + cache_from: Optional[List[str]] = None labels: Optional[Dict[str, Any]] = None + network: Optional[str] = None + shm_size: Optional[str] = None + target: Optional[str] = None + + +class ComposeServiceHealthcheck(BaseModel): + interval: Optional[str] = None + start_period: Optional[str] = None + start_interval: Optional[str] = None + test: Optional[List[str]] = None + timeout: Optional[str] = None + retries: Optional[int] = None class ComposeServicePort(BaseModel): @@ -49,6 +62,16 @@ class ComposeServicePort(BaseModel): target: Optional[int] = None +class ComposeServiceULimitsNoFile(BaseModel): + soft: Optional[int] = None + hard: Optional[int] = None + + +class ComposeServiceULimits(BaseModel): + nproc: Optional[int] = None + nofile: Optional[ComposeServiceULimitsNoFile] = None + + class ComposeServiceVolume(BaseModel): bind: Optional[dict] = None source: Optional[str] = None @@ -57,27 +80,46 @@ class ComposeServiceVolume(BaseModel): class ComposeConfigService(BaseModel): - deploy: Optional[ServiceDeployConfig] = None blkio_config: Optional[Any] = None - cpu_count: Optional[float] = None - cpu_percent: Optional[float] = None - cpu_shares: Optional[int] = None - cpuset: Optional[str] = None build: Optional[ComposeServiceBuild] = None cap_add: Annotated[Optional[List[str]], Field(default_factory=list)] cap_drop: Annotated[Optional[List[str]], Field(default_factory=list)] - cgroup_parent: Optional[str] = None command: Optional[List[str]] = None - configs: Any = None + cgroup_parent: Optional[str] = None container_name: Optional[str] = None + cpu_count: Optional[float] = None + cpu_percent: Optional[float] = None + cpu_shares: Optional[int] = None + cpuset: Optional[str] = None depends_on: Annotated[Dict[str, DependencyCondition], Field(default_factory=dict)] + deploy: Optional[ServiceDeployConfig] = None + devices: List[str] = None device_cgroup_rules: Annotated[List[str], Field(default_factory=list)] - devices: Any = None - environment: Optional[Dict[str, Optional[str]]] = None + dns: Optional[List[str]] = None + dns_search: Optional[List[str]] = None entrypoint: Optional[List[str]] = None + env_file: Optional[List[str]] = None + environment: Optional[Dict[str, Optional[str]]] = None + expose: Optional[List[str]] = None + external_links: Optional[List[str]] = None + extra_hosts: Optional[List[str]] = None + healthcheck: Optional[ComposeServiceHealthcheck] = None image: Optional[str] = None + init: Optional[bool] = False + isolation: Optional[str] = "default" labels: Annotated[Optional[Dict[str, str]], Field(default_factory=dict)] + network_mode: Optional[str] = None + networks: Optional[Union[Dict[str, Dict[str, Any]], List[str]]] = None + pid: Optional[str] = None ports: Optional[List[ComposeServicePort]] = None + profiles: Optional[List[str]] = None + restart: str = "no" + secrets: Optional[List[str]] = None + stop_grace_period: str = "10s" + stop_signal: str = "SIGTERM" + tmpfs: Optional[List[str]] = None + ulimits: Optional[ComposeServiceULimits] = None + userns_mode: Optional[str] = None volumes: Optional[List[ComposeServiceVolume]] = None From f4e027e950300d533a476287e8c11844851798f5 Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Mon, 2 Oct 2023 10:35:08 +0530 Subject: [PATCH 02/10] Add tests --- .../components/compose/cli_wrapper.py | 3 ++- python_on_whales/components/compose/models.py | 9 ++++---- .../components/test-build-args.yml | 7 +++++- .../components/test_compose.py | 23 +++++-------------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/python_on_whales/components/compose/cli_wrapper.py b/python_on_whales/components/compose/cli_wrapper.py index 5f6ee447..a694fb53 100644 --- a/python_on_whales/components/compose/cli_wrapper.py +++ b/python_on_whales/components/compose/cli_wrapper.py @@ -88,7 +88,8 @@ def config(self, return_json: bool = False) -> Union[ComposeConfig, Dict[str, An if return_json: return json.loads(result) else: - return ComposeConfig(**json.loads(result)) + raw_compose_config = json.loads(result) + return ComposeConfig(**raw_compose_config) def create( self, diff --git a/python_on_whales/components/compose/models.py b/python_on_whales/components/compose/models.py index eedc8d0e..fb514b31 100644 --- a/python_on_whales/components/compose/models.py +++ b/python_on_whales/components/compose/models.py @@ -42,7 +42,6 @@ class ComposeServiceBuild(BaseModel): cache_from: Optional[List[str]] = None labels: Optional[Dict[str, Any]] = None network: Optional[str] = None - shm_size: Optional[str] = None target: Optional[str] = None @@ -106,17 +105,17 @@ class ComposeConfigService(BaseModel): healthcheck: Optional[ComposeServiceHealthcheck] = None image: Optional[str] = None init: Optional[bool] = False - isolation: Optional[str] = "default" + isolation: str = Field(default="default") labels: Annotated[Optional[Dict[str, str]], Field(default_factory=dict)] network_mode: Optional[str] = None - networks: Optional[Union[Dict[str, Dict[str, Any]], List[str]]] = None + networks: Optional[Any] = None pid: Optional[str] = None ports: Optional[List[ComposeServicePort]] = None profiles: Optional[List[str]] = None restart: str = "no" secrets: Optional[List[str]] = None - stop_grace_period: str = "10s" - stop_signal: str = "SIGTERM" + stop_grace_period: str = Field(default="10s") + stop_signal: str = Field(default="SIGTERM") tmpfs: Optional[List[str]] = None ulimits: Optional[ComposeServiceULimits] = None userns_mode: Optional[str] = None diff --git a/tests/python_on_whales/components/test-build-args.yml b/tests/python_on_whales/components/test-build-args.yml index fe23517b..c33f3640 100644 --- a/tests/python_on_whales/components/test-build-args.yml +++ b/tests/python_on_whales/components/test-build-args.yml @@ -1,4 +1,4 @@ -version: "3.7" +version: "3.9" services: my_service: @@ -8,9 +8,14 @@ services: args: python_version: "3.78" python_version_1: "3.78" + cache_from: + - alpine:latest + - corp/web_app:3.14 labels: com.example.description: "Accounting webapp" com.example.department: "Finance" + network: "host" + target: "prod" image: "some_random_image" command: ping -c 7 www.google.com ports: diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index 7e09b6a8..e0de2235 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -908,24 +908,13 @@ def test_build_args(): "python_version": "3.78", "python_version_1": "3.78", } + assert config.services["my_service"].build.cache_from == [ + "alpine:latest", + "corp/web_app:3.14", + ] assert config.services["my_service"].build.labels == { "com.example.description": "Accounting webapp", "com.example.department": "Finance", } - assert config.services["my_service"].image == "some_random_image" - assert config.services["my_service"].command == [ - "ping", - "-c", - "7", - "www.google.com", - ] - - assert config.services["my_service"].ports[0].published == 5000 - assert config.services["my_service"].ports[0].target == 5000 - - assert config.services["my_service"].volumes[0].source == "/tmp" - assert config.services["my_service"].volumes[0].target == "/tmp" - assert config.services["my_service"].volumes[1].source == "dodo" - assert config.services["my_service"].volumes[1].target == "/dodo" - - assert config.services["my_service"].environment == {"DATADOG_HOST": "something"} + assert config.services["my_service"].build.network == "host" + assert config.services["my_service"].build.target == "prod" From 6c0320b2dbbf2be100947fa0370dd2bdf03609ab Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Mon, 2 Oct 2023 10:36:56 +0530 Subject: [PATCH 03/10] Add deleted test --- .../components/test_compose.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index e0de2235..c3692d15 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -918,3 +918,21 @@ def test_build_args(): } assert config.services["my_service"].build.network == "host" assert config.services["my_service"].build.target == "prod" + + assert config.services["my_service"].image == "some_random_image" + assert config.services["my_service"].command == [ + "ping", + "-c", + "7", + "www.google.com", + ] + + assert config.services["my_service"].ports[0].published == 5000 + assert config.services["my_service"].ports[0].target == 5000 + + assert config.services["my_service"].volumes[0].source == "/tmp" + assert config.services["my_service"].volumes[0].target == "/tmp" + assert config.services["my_service"].volumes[1].source == "dodo" + assert config.services["my_service"].volumes[1].target == "/dodo" + + assert config.services["my_service"].environment == {"DATADOG_HOST": "something"} From 47f76d8a15e74e6f18273192269b8c8cd5ee459f Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Mon, 2 Oct 2023 12:30:04 +0530 Subject: [PATCH 04/10] Add remaining test --- python_on_whales/components/compose/models.py | 4 +- .../components/complex-compose.yml | 66 +++++++++++++++++++ .../components/complexe-compose.yml | 32 --------- .../components/test_compose.py | 52 ++++++++++++++- 4 files changed, 117 insertions(+), 37 deletions(-) create mode 100644 tests/python_on_whales/components/complex-compose.yml delete mode 100644 tests/python_on_whales/components/complexe-compose.yml diff --git a/python_on_whales/components/compose/models.py b/python_on_whales/components/compose/models.py index fb514b31..5bc4f9d2 100644 --- a/python_on_whales/components/compose/models.py +++ b/python_on_whales/components/compose/models.py @@ -46,6 +46,7 @@ class ComposeServiceBuild(BaseModel): class ComposeServiceHealthcheck(BaseModel): + disable: Optional[bool] = None interval: Optional[str] = None start_period: Optional[str] = None start_interval: Optional[str] = None @@ -97,7 +98,6 @@ class ComposeConfigService(BaseModel): dns: Optional[List[str]] = None dns_search: Optional[List[str]] = None entrypoint: Optional[List[str]] = None - env_file: Optional[List[str]] = None environment: Optional[Dict[str, Optional[str]]] = None expose: Optional[List[str]] = None external_links: Optional[List[str]] = None @@ -113,7 +113,7 @@ class ComposeConfigService(BaseModel): ports: Optional[List[ComposeServicePort]] = None profiles: Optional[List[str]] = None restart: str = "no" - secrets: Optional[List[str]] = None + secrets: Optional[List[Dict[str, Any]]] = None stop_grace_period: str = Field(default="10s") stop_signal: str = Field(default="SIGTERM") tmpfs: Optional[List[str]] = None diff --git a/tests/python_on_whales/components/complex-compose.yml b/tests/python_on_whales/components/complex-compose.yml new file mode 100644 index 00000000..bdb6567c --- /dev/null +++ b/tests/python_on_whales/components/complex-compose.yml @@ -0,0 +1,66 @@ +version: "3.7" + +services: + my_service: + build: + context: my_service_build + image: some_random_image + command: ping -c 2 www.google.com + ports: + - "5000:5000" + volumes: + - /tmp:/tmp + - dodo:/dodo + environment: + - DATADOG_HOST=something + dns: 8.8.8.8 + dns_search: + - dc1.example.com + - dc2.example.com + expose: + - "5000" + - 8000 + external_links: + - "redis" + extra_hosts: + - "somehost:162.242.195.82" + - "otherhost:50.31.209.229" + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost" ] + interval: 1m30s + timeout: 10s + retries: 3 + start_period: 40s + init: true + isolation: "process" + network_mode: "host" + pid: "host" + secrets: + - my_secret + tmpfs: /run + ulimits: + nproc: 65535 + nofile: + soft: 20000 + hard: 40000 + userns_mode: "host" + deploy: + placement: + constraints: + - node.labels.hello-world == yes + resources: + reservations: + cpus: '1' + memory: 20M + limits: + cpus: '2' + memory: 40M + replicas: 4 + +secrets: + my_secret: + external: true + + +volumes: + dodo: {} diff --git a/tests/python_on_whales/components/complexe-compose.yml b/tests/python_on_whales/components/complexe-compose.yml deleted file mode 100644 index 24a0f62b..00000000 --- a/tests/python_on_whales/components/complexe-compose.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "3.7" - -services: - my_service: - build: - context: my_service_build - image: some_random_image - command: ping -c 2 www.google.com - ports: - - "5000:5000" - volumes: - - /tmp:/tmp - - dodo:/dodo - environment: - - DATADOG_HOST=something - deploy: - placement: - constraints: - - node.labels.hello-world == yes - resources: - reservations: - cpus: '1' - memory: 20M - limits: - cpus: '2' - memory: 40M - replicas: 4 - - - -volumes: - dodo: {} diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index c3692d15..d58ece7b 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -449,15 +449,18 @@ def test_entrypoint_loaded_in_config(): assert docker.compose.config().services["dodo"].entrypoint == ["/bin/sh"] -def test_config_complexe_compose(): +def test_config_complex_compose(): """Checking that the pydantic model does its job""" compose_file = ( - PROJECT_ROOT / "tests/python_on_whales/components/complexe-compose.yml" + PROJECT_ROOT / "tests/python_on_whales/components/complex-compose.yml" ) docker = DockerClient(compose_files=[compose_file], compose_compatibility=True) config = docker.compose.config() - assert config.services["my_service"].build.context == Path("my_service_build") + assert ( + config.services["my_service"].build.context + == (compose_file.parent / "my_service_build").absolute() + ) assert config.services["my_service"].image == "some_random_image" assert config.services["my_service"].command == [ "ping", @@ -475,6 +478,49 @@ def test_config_complexe_compose(): assert config.services["my_service"].volumes[1].target == "/dodo" assert config.services["my_service"].environment == {"DATADOG_HOST": "something"} + + assert config.services["my_service"].dns == ["8.8.8.8"] + assert config.services["my_service"].dns_search == [ + "dc1.example.com", + "dc2.example.com", + ] + + assert config.services["my_service"].expose == ["5000", "8000"] + + assert config.services["my_service"].external_links == ["redis"] + + assert config.services["my_service"].extra_hosts == [ + "otherhost:50.31.209.229", + "somehost:162.242.195.82", + ] + + assert config.services["my_service"].healthcheck.test == [ + "CMD", + "curl", + "-f", + "http://localhost", + ] + assert config.services["my_service"].healthcheck.interval == "1m30s" + assert config.services["my_service"].healthcheck.timeout == "10s" + assert config.services["my_service"].healthcheck.retries == 3 + assert config.services["my_service"].healthcheck.start_period == "40s" + + assert config.services["my_service"].init + assert config.services["my_service"].isolation == "process" + assert config.services["my_service"].network_mode == "host" + assert config.services["my_service"].pid == "host" + assert config.services["my_service"].restart == "no" + assert config.services["my_service"].secrets == [{"source": "my_secret"}] + assert config.services["my_service"].stop_grace_period == "10s" + assert config.services["my_service"].stop_signal == "SIGTERM" + assert config.services["my_service"].tmpfs == ["/run"] + + assert config.services["my_service"].ulimits.nproc == 65535 + assert config.services["my_service"].ulimits.nofile.soft == 20000 + assert config.services["my_service"].ulimits.nofile.hard == 40000 + + assert config.services["my_service"].userns_mode == "host" + assert config.services["my_service"].deploy.placement.constraints == [ "node.labels.hello-world == yes" ] From 975519b9641a0b22cad8a7ce1b31ad08ee260d51 Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Mon, 2 Oct 2023 12:37:29 +0530 Subject: [PATCH 05/10] Fix test --- tests/python_on_whales/components/test_compose.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index d58ece7b..fc8267ed 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -457,10 +457,7 @@ def test_config_complex_compose(): docker = DockerClient(compose_files=[compose_file], compose_compatibility=True) config = docker.compose.config() - assert ( - config.services["my_service"].build.context - == (compose_file.parent / "my_service_build").absolute() - ) + assert config.services["my_service"].build.context == Path("my_service_build") assert config.services["my_service"].image == "some_random_image" assert config.services["my_service"].command == [ "ping", From 01923eb5ee6e6c62a23ce77e271f4cd88aa49e5b Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Mon, 2 Oct 2023 12:56:11 +0530 Subject: [PATCH 06/10] Whitespace --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 609c92ac..14b0d27c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/gabrieldemarmiesse/python-on-whales/blob/master/LICENSE) [![Downloads](https://pepy.tech/badge/python-on-whales/month)](https://pepy.tech/project/python-on-whales) - ------------------------------------------------------------------------ A Docker client for Python, designed to be fun and intuitive! From 09790cc303aafa1f2fb46bc15152664e419c13b5 Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Tue, 3 Oct 2023 11:50:34 +0530 Subject: [PATCH 07/10] Revert --- .../components/complexe-compose.yml | 32 ++++++++++++++ .../components/test_compose.py | 42 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 tests/python_on_whales/components/complexe-compose.yml diff --git a/tests/python_on_whales/components/complexe-compose.yml b/tests/python_on_whales/components/complexe-compose.yml new file mode 100644 index 00000000..24a0f62b --- /dev/null +++ b/tests/python_on_whales/components/complexe-compose.yml @@ -0,0 +1,32 @@ +version: "3.7" + +services: + my_service: + build: + context: my_service_build + image: some_random_image + command: ping -c 2 www.google.com + ports: + - "5000:5000" + volumes: + - /tmp:/tmp + - dodo:/dodo + environment: + - DATADOG_HOST=something + deploy: + placement: + constraints: + - node.labels.hello-world == yes + resources: + reservations: + cpus: '1' + memory: 20M + limits: + cpus: '2' + memory: 40M + replicas: 4 + + + +volumes: + dodo: {} diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index fc8267ed..c4e44086 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -449,6 +449,48 @@ def test_entrypoint_loaded_in_config(): assert docker.compose.config().services["dodo"].entrypoint == ["/bin/sh"] +def test_config_complexe_compose(): + """Checking that the pydantic model does its job""" + compose_file = ( + PROJECT_ROOT / "tests/python_on_whales/components/complexe-compose.yml" + ) + docker = DockerClient(compose_files=[compose_file], compose_compatibility=True) + config = docker.compose.config() + + assert config.services["my_service"].build.context == Path("my_service_build") + assert config.services["my_service"].image == "some_random_image" + assert config.services["my_service"].command == [ + "ping", + "-c", + "2", + "www.google.com", + ] + + assert config.services["my_service"].ports[0].published == 5000 + assert config.services["my_service"].ports[0].target == 5000 + + assert config.services["my_service"].volumes[0].source == "/tmp" + assert config.services["my_service"].volumes[0].target == "/tmp" + assert config.services["my_service"].volumes[1].source == "dodo" + assert config.services["my_service"].volumes[1].target == "/dodo" + + assert config.services["my_service"].environment == {"DATADOG_HOST": "something"} + assert config.services["my_service"].deploy.placement.constraints == [ + "node.labels.hello-world == yes" + ] + assert config.services["my_service"].deploy.resources.limits.cpus == 2 + assert config.services["my_service"].deploy.resources.limits.memory == 41943040 + + assert config.services["my_service"].deploy.resources.reservations.cpus == 1 + assert ( + config.services["my_service"].deploy.resources.reservations.memory == 20971520 + ) + + assert config.services["my_service"].deploy.replicas == 4 + + assert not config.volumes["dodo"].external + + def test_config_complex_compose(): """Checking that the pydantic model does its job""" compose_file = ( From d8c45bcd2c910f48d1a8b82d91e504ca97bddfaa Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Tue, 3 Oct 2023 12:03:16 +0530 Subject: [PATCH 08/10] Revert --- .../components/complexe-compose.yml | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 tests/python_on_whales/components/complexe-compose.yml diff --git a/tests/python_on_whales/components/complexe-compose.yml b/tests/python_on_whales/components/complexe-compose.yml deleted file mode 100644 index 24a0f62b..00000000 --- a/tests/python_on_whales/components/complexe-compose.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "3.7" - -services: - my_service: - build: - context: my_service_build - image: some_random_image - command: ping -c 2 www.google.com - ports: - - "5000:5000" - volumes: - - /tmp:/tmp - - dodo:/dodo - environment: - - DATADOG_HOST=something - deploy: - placement: - constraints: - - node.labels.hello-world == yes - resources: - reservations: - cpus: '1' - memory: 20M - limits: - cpus: '2' - memory: 40M - replicas: 4 - - - -volumes: - dodo: {} From 433fe972550077f4ed73010182d897462a622bec Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Tue, 3 Oct 2023 12:09:02 +0530 Subject: [PATCH 09/10] Update test_compose.py --- .../components/test_compose.py | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index c4e44086..fc8267ed 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -449,48 +449,6 @@ def test_entrypoint_loaded_in_config(): assert docker.compose.config().services["dodo"].entrypoint == ["/bin/sh"] -def test_config_complexe_compose(): - """Checking that the pydantic model does its job""" - compose_file = ( - PROJECT_ROOT / "tests/python_on_whales/components/complexe-compose.yml" - ) - docker = DockerClient(compose_files=[compose_file], compose_compatibility=True) - config = docker.compose.config() - - assert config.services["my_service"].build.context == Path("my_service_build") - assert config.services["my_service"].image == "some_random_image" - assert config.services["my_service"].command == [ - "ping", - "-c", - "2", - "www.google.com", - ] - - assert config.services["my_service"].ports[0].published == 5000 - assert config.services["my_service"].ports[0].target == 5000 - - assert config.services["my_service"].volumes[0].source == "/tmp" - assert config.services["my_service"].volumes[0].target == "/tmp" - assert config.services["my_service"].volumes[1].source == "dodo" - assert config.services["my_service"].volumes[1].target == "/dodo" - - assert config.services["my_service"].environment == {"DATADOG_HOST": "something"} - assert config.services["my_service"].deploy.placement.constraints == [ - "node.labels.hello-world == yes" - ] - assert config.services["my_service"].deploy.resources.limits.cpus == 2 - assert config.services["my_service"].deploy.resources.limits.memory == 41943040 - - assert config.services["my_service"].deploy.resources.reservations.cpus == 1 - assert ( - config.services["my_service"].deploy.resources.reservations.memory == 20971520 - ) - - assert config.services["my_service"].deploy.replicas == 4 - - assert not config.volumes["dodo"].external - - def test_config_complex_compose(): """Checking that the pydantic model does its job""" compose_file = ( From 92de7fd803b98edd2aeb242109de4690c95f6206 Mon Sep 17 00:00:00 2001 From: Jash Parekh Date: Tue, 3 Oct 2023 12:18:49 +0530 Subject: [PATCH 10/10] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 14b0d27c..609c92ac 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/gabrieldemarmiesse/python-on-whales/blob/master/LICENSE) [![Downloads](https://pepy.tech/badge/python-on-whales/month)](https://pepy.tech/project/python-on-whales) + ------------------------------------------------------------------------ A Docker client for Python, designed to be fun and intuitive!