From aeb33ed3f61e2516cd6d099538eca8cc5a9361da Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Sun, 15 Oct 2023 19:33:23 -0400 Subject: [PATCH] Print missing fields for failed compute env creation --- chrisomatic/core/computeenvs.py | 5 +++-- chrisomatic/spec/common.py | 6 +++--- poetry.lock | 6 +++--- pyproject.toml | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/chrisomatic/core/computeenvs.py b/chrisomatic/core/computeenvs.py index 79a9503..a1446a6 100644 --- a/chrisomatic/core/computeenvs.py +++ b/chrisomatic/core/computeenvs.py @@ -32,8 +32,9 @@ async def run(self, status: Channel) -> tuple[Outcome, Optional[ComputeResource] f'Existing "{preexisting.name}" ' "is different from given_config." ) return Outcome.FAILED, preexisting - if not self.given.is_some(): - status.replace(f'No configuration for "{self.given.name}"') + missing = self.given.get_missing() + if missing: + status.replace(f"Missing configurations: {missing}") return Outcome.FAILED, None created_compute_resource = await self.cube.create_compute_resource( name=self.given.name, diff --git a/chrisomatic/spec/common.py b/chrisomatic/spec/common.py index be6619b..036bd24 100644 --- a/chrisomatic/spec/common.py +++ b/chrisomatic/spec/common.py @@ -2,7 +2,7 @@ from serde import serde from aiochris.types import Username, Password, ComputeResourceName, PfconUrl -from dataclasses import dataclass, astuple +from dataclasses import dataclass, astuple, asdict @serde @@ -29,8 +29,8 @@ class ComputeResource: description: Optional[str] = None innetwork: Optional[bool] = None - def is_some(self) -> bool: - return all(f is not None for f in astuple(self)) + def get_missing(self) -> list[str]: + return [k for k, v in asdict(self).items() if v is None] @serde diff --git a/poetry.lock b/poetry.lock index 460d670..f603949 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1112,13 +1112,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" -version = "3.4.0" +version = "3.5.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false python-versions = ">=3.8" files = [ - {file = "pre_commit-3.4.0-py2.py3-none-any.whl", hash = "sha256:96d529a951f8b677f730a7212442027e8ba53f9b04d217c4c67dc56c393ad945"}, - {file = "pre_commit-3.4.0.tar.gz", hash = "sha256:6bbd5129a64cad4c0dfaeeb12cd8f7ea7e15b77028d985341478c8af3c759522"}, + {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, + {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 40d1919..004190b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "chrisomatic" -version = "0.7.0" +version = "0.7.1" description = "ChRIS backend provisioner with Powerpointlessness" authors = ["Jennings Zhang "] license = "MIT"