Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: 2.7.2 #19

Merged
merged 10 commits into from
Aug 17, 2024
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions deploy/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -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)}": ""
]
}
20 changes: 0 additions & 20 deletions deploy/docker-bake.json

This file was deleted.

22 changes: 14 additions & 8 deletions invocations/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,24 +66,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,
)
14 changes: 10 additions & 4 deletions testgen/ui/services/form_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = []
Expand All @@ -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(
Expand Down