From 7a83e34fc446de5d6e27855bbae6053fc0653963 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Thu, 15 Dec 2022 18:58:26 -0500 Subject: [PATCH 1/4] FIX: Reflect strawberry.enum changes --- migas_server/types.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/migas_server/types.py b/migas_server/types.py index 539defd..be9ca7a 100644 --- a/migas_server/types.py +++ b/migas_server/types.py @@ -52,32 +52,33 @@ @strawberry.enum class Container(Enum): - unknown = 0 - docker = 1 - apptainer = 2 + unknown = 'unknown' + docker = 'docker' + apptainer = 'apptainer' @strawberry.enum class User(Enum): - general = 0 - dev = 1 - ci = 2 + general = 'general' + dev = 'dev' + ci = 'ci' @strawberry.enum class Status(Enum): - R = 'running' - running = strawberry.enum_value('running') - C = 'completed' - completed = strawberry.enum_value('completed') - F = 'failed' - failed = strawberry.enum_value('failed') - S = 'suspended' + R = 'R' + running = strawberry.enum_value('R') + C = 'C' + completed = strawberry.enum_value('C') + F = 'F' + failed = strawberry.enum_value('F') + S = 'S' suspended = strawberry.enum_value('suspended') - pending = strawberry.enum_value('running', deprecation_reason="Changed to `running`") - success = strawberry.enum_value('completed', deprecation_reason="Changed to `completed`") - error = strawberry.enum_value('error', deprecation_reason="Changed to `failed`") + # Deprecations, to be removed in 0.4.0 + pending = strawberry.enum_value('R', deprecation_reason="Pending is now running") + success = strawberry.enum_value('C', deprecation_reason="Success is now completed") + error = strawberry.enum_value('F', deprecation_reason="Error is now failed") # @strawberry.type @@ -92,7 +93,7 @@ class Status(Enum): @strawberry.type class Process: - status: Status = Status.pending + status: Status = Status.running status_desc: str | None = None error_type: str | None = None error_desc: str | None = None @@ -163,7 +164,7 @@ async def serialize(data: dict) -> dict: if isinstance(v, _BaseVersion): data[k] = str(v) elif isinstance(v, Enum): - data[k] = v.name + data[k] = v.value # datetime ok? elif isinstance(v, (Context, Process)): data[k] = await serialize(v.__dict__) From ac0d158a18ac89aac435b4c8bf973ddc9f801605 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Thu, 15 Dec 2022 19:04:33 -0500 Subject: [PATCH 2/4] dep: ensure fixed environment for deployments --- stable-requirements.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 stable-requirements.txt diff --git a/stable-requirements.txt b/stable-requirements.txt new file mode 100644 index 0000000..3a6b52b --- /dev/null +++ b/stable-requirements.txt @@ -0,0 +1,8 @@ +aiohttp==3.8.3 +asyncpg==0.27.0 +fastapi==0.88.0 +redis==4.4.0 +sqlalchemy==1.4.45 +starlette==0.22.0 +strawberry-graphql==0.151.0 +. \ No newline at end of file From a29f5337e33f17a1cb87849dca9bbc2312bb8fac Mon Sep 17 00:00:00 2001 From: mathiasg Date: Thu, 15 Dec 2022 19:12:52 -0500 Subject: [PATCH 3/4] TST: Add test for status value --- migas_server/tests/test_types.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 migas_server/tests/test_types.py diff --git a/migas_server/tests/test_types.py b/migas_server/tests/test_types.py new file mode 100644 index 0000000..7a060aa --- /dev/null +++ b/migas_server/tests/test_types.py @@ -0,0 +1,13 @@ +import pytest + +from migas_server import types + +@pytest.mark.parametrize('names', 'val', [ + (['running', 'R'], 'R'), + (['completed', 'C'], 'C'), + (['failed', 'F'], 'F'), + (['suspended', 'S'], 'S'), +]) +def test_status(names, val): + for name in names: + assert getattr(types.Status, name).value == val From a7a486e63bb103ea695bb68774a2a248e8e77067 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Thu, 15 Dec 2022 19:24:08 -0500 Subject: [PATCH 4/4] FIX: Missed value set, thanks to the new test :) --- migas_server/tests/test_types.py | 2 +- migas_server/types.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migas_server/tests/test_types.py b/migas_server/tests/test_types.py index 7a060aa..bbba1fe 100644 --- a/migas_server/tests/test_types.py +++ b/migas_server/tests/test_types.py @@ -2,7 +2,7 @@ from migas_server import types -@pytest.mark.parametrize('names', 'val', [ +@pytest.mark.parametrize('names,val', [ (['running', 'R'], 'R'), (['completed', 'C'], 'C'), (['failed', 'F'], 'F'), diff --git a/migas_server/types.py b/migas_server/types.py index be9ca7a..938231f 100644 --- a/migas_server/types.py +++ b/migas_server/types.py @@ -73,7 +73,7 @@ class Status(Enum): F = 'F' failed = strawberry.enum_value('F') S = 'S' - suspended = strawberry.enum_value('suspended') + suspended = strawberry.enum_value('S') # Deprecations, to be removed in 0.4.0 pending = strawberry.enum_value('R', deprecation_reason="Pending is now running")