From 805afed371e71608fea469ddb10be6a6e828b76d Mon Sep 17 00:00:00 2001 From: Aarthy Adityan Date: Thu, 25 Jul 2024 17:39:11 -0400 Subject: [PATCH 1/3] ci(docker): update inv script and buildx file to support QA image --- deploy/docker-bake.hcl | 23 +++++++++++++++++++++++ deploy/docker-bake.json | 20 -------------------- invocations/dev.py | 22 ++++++++++++++-------- 3 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 deploy/docker-bake.hcl delete mode 100644 deploy/docker-bake.json diff --git a/deploy/docker-bake.hcl b/deploy/docker-bake.hcl new file mode 100644 index 0000000..0eaecde --- /dev/null +++ b/deploy/docker-bake.hcl @@ -0,0 +1,23 @@ +variable "TESTGEN_VERSION" {} +variable "PUBLIC_RELEASE" { + default = false +} + +function "docker_repo" { + params = [] + result = PUBLIC_RELEASE ? "datakitchen/dataops-testgen" : "datakitchen/dataops-testgen-qa" +} + +target "testgen" { + args = { + TESTGEN_VERSION = "${TESTGEN_VERSION}" + } + context = "." + dockerfile = "Dockerfile" + platforms = ["linux/amd64", "linux/arm64"] + tags = [ + "${docker_repo()}:v${TESTGEN_VERSION}", + PUBLIC_RELEASE ? "${docker_repo()}:v${index(regex("([0-9]+.[0-9]+).[0-9]+", TESTGEN_VERSION), 0)}": "", + PUBLIC_RELEASE ? "${docker_repo()}:v${index(regex("([0-9]+).[0-9]+.[0-9]+", TESTGEN_VERSION), 0)}": "" + ] +} diff --git a/deploy/docker-bake.json b/deploy/docker-bake.json deleted file mode 100644 index e5f0c61..0000000 --- a/deploy/docker-bake.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "variable": { - "TESTGEN_VERSION": {} - }, - "target": { - "testgen": { - "args": { - "TESTGEN_VERSION": "${TESTGEN_VERSION}" - }, - "dockerfile": "Dockerfile", - "tags": [ - "datakitchen/dataops-testgen:v${TESTGEN_VERSION}", - "datakitchen/dataops-testgen:v${index(regex(\"([0-9]+\\\\.[0-9]+)\\\\.[0-9]+\", TESTGEN_VERSION), 0)}", - "datakitchen/dataops-testgen:v${index(regex(\"([0-9]+)\\\\.[0-9]+\\\\.[0-9]+\", TESTGEN_VERSION), 0)}" - ], - "context": ".", - "platforms": ["linux/amd64", "linux/arm64"] - } - } -} diff --git a/invocations/dev.py b/invocations/dev.py index 731c19b..f8fc9a7 100644 --- a/invocations/dev.py +++ b/invocations/dev.py @@ -2,6 +2,7 @@ from os.path import exists, join from shutil import rmtree, which +from typing import Literal import tomli from invoke.context import Context @@ -67,24 +68,29 @@ def clean(ctx: Context) -> None: @task(pre=(required_tools,)) -def build_public_image(ctx: Context, version: str, push: bool = False, local: bool = False) -> None: +def build_public_image(ctx: Context, version: str, target: Literal["local", "qa", "release"]) -> None: """Builds and pushes the TestGen image""" use_cmd = f"docker buildx use {DOCKER_BUILDER_NAME}" - if push and local: - raise Exit("Cannot use --local and --push at the same time.") - + valid_targets = ["local", "qa", "release"] + if target not in valid_targets: + raise Exit(f"--target must be one of [{', '.join(valid_targets)}].") + if (result := ctx.run(use_cmd, hide=True, warn=True)) and not result.ok: ctx.run(f"docker buildx create --name {DOCKER_BUILDER_NAME} --platform {DOCKER_BUILDER_PLATFORMS}") ctx.run(use_cmd) extra_args = [] - if push: + if target in ["release", "qa"]: extra_args.append("--push") - elif local: + else: extra_args.extend(("--load", "--set=*.platform=$BUILDPLATFORM")) + ctx.run( - f"docker buildx bake -f deploy/docker-bake.json testgen {' '.join(extra_args)} ", - env={"TESTGEN_VERSION": version}, + f"docker buildx bake -f deploy/docker-bake.hcl testgen {' '.join(extra_args)} ", + env={ + "TESTGEN_VERSION": version, + "PUBLIC_RELEASE": str(target == "release"), + }, echo=True, ) From 996881c1a447258507f06e254263407c8c3953db Mon Sep 17 00:00:00 2001 From: Ricardo Boni Date: Tue, 6 Aug 2024 17:01:24 -0400 Subject: [PATCH 2/3] fix(ui): read user is able to update test configuration via forms Added a second check before updating the database --- testgen/ui/services/form_service.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/testgen/ui/services/form_service.py b/testgen/ui/services/form_service.py index 16bda64..e18bf43 100644 --- a/testgen/ui/services/form_service.py +++ b/testgen/ui/services/form_service.py @@ -373,13 +373,15 @@ def ut_prettify_header(str_header, expand=False): return str_new -def reset_post_updates(str_message=None, as_toast=False, clear_cache=True, lst_cached_functions=None): +def reset_post_updates(str_message=None, as_toast=False, clear_cache=True, lst_cached_functions=None, style="success"): if str_message: if as_toast: st.toast(str_message) + elif style in ("error", "warning", "info", "success"): + getattr(st, style)(str_message) else: st.success(str_message) - sleep(0.5) + sleep(1.5) if clear_cache: if lst_cached_functions: @@ -727,9 +729,10 @@ def render_edit_form( else: # If Hidden, add directly to dct_mods for updates dct_mods[column] = row_selected[column] - submit = st.form_submit_button("Save Changes", disabled=authentication_service.current_user_has_read_role()) + edit_allowed = authentication_service.current_user_has_edit_role() + submit = st.form_submit_button("Save Changes", disabled=not edit_allowed) - if submit: + if submit and edit_allowed: # Construct SQL UPDATE statement based on the changed columns changes = [] keys = [] @@ -747,6 +750,9 @@ def render_edit_form( ) db.execute_sql(str_sql) reset_post_updates("Changes have been saved.") + elif submit: + reset_post_updates("The current user does not have permission to save changes.", style="warning") + def render_insert_form( From 0395db5693e171f3c538b9ae0153d58beab201b9 Mon Sep 17 00:00:00 2001 From: Alex Fernandez Date: Fri, 16 Aug 2024 12:12:07 -0300 Subject: [PATCH 3/3] change setting to avoid StreamBufferFullError --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5aff6ba..dc7faea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ RUN TG_METADATA_DB_USER=- TG_METADATA_DB_PASSWORD=- TG_METADATA_DB_HOST=- TG_MET ARG TESTGEN_VERSION ENV TESTGEN_VERSION=v$TESTGEN_VERSION -ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=2 +ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=200 WORKDIR /dk