From b21f2d8c040111a151b72a2dabd73907446ec261 Mon Sep 17 00:00:00 2001 From: Namya LG <53875297+Namyalg@users.noreply.github.com> Date: Thu, 10 Mar 2022 00:00:53 +0530 Subject: [PATCH 1/5] Update base.yml --- .github/workflows/base.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 4bda0cd0..ede19709 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -1,8 +1,8 @@ name: Build base images for FLINT and GCBM -on: - schedule: - - cron: "0 0 * * MON" +# on: +# schedule: +# - cron: "0 0 * * MON" # This would be a one-time trigger; Remove after the images are pushed to GHCR! push: From 90aebd5969106d9b7159704cf6df9230515dbfd5 Mon Sep 17 00:00:00 2001 From: Namya LG <53875297+Namyalg@users.noreply.github.com> Date: Thu, 10 Mar 2022 00:01:13 +0530 Subject: [PATCH 2/5] Update docker.yml --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2e537de8..9757c933 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ name: Test & publish FLINT Cloud images on: - schedule: - - cron: "0 0 * * MON" +# schedule: +# - cron: "0 0 * * MON" push: branches: [ master ] # Publish semver tags as releases. From 406374c54abf540534d2bdba5b777b950cf3c436 Mon Sep 17 00:00:00 2001 From: Namya LG Date: Mon, 14 Mar 2022 18:59:45 +0530 Subject: [PATCH 3/5] modified base.yml --- .github/workflows/base.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index ede19709..4bda0cd0 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -1,8 +1,8 @@ name: Build base images for FLINT and GCBM -# on: -# schedule: -# - cron: "0 0 * * MON" +on: + schedule: + - cron: "0 0 * * MON" # This would be a one-time trigger; Remove after the images are pushed to GHCR! push: From b4501b48f793a67ccdcaf0ee0a25c34c5553986b Mon Sep 17 00:00:00 2001 From: Namya LG Date: Sun, 20 Mar 2022 14:27:27 +0530 Subject: [PATCH 4/5] Update docker.yml --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0e49ae30..afbe104d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ name: Test & publish FLINT Cloud images on: -# schedule: -# - cron: "0 0 * * MON" + schedule: + - cron: "0 0 * * MON" push: branches: [ master ] # Publish semver tags as releases. From d21f2e7eb85da988afcbd37bcef96e7179eedd31 Mon Sep 17 00:00:00 2001 From: Namya LG Date: Fri, 2 Sep 2022 13:33:16 +0530 Subject: [PATCH 5/5] feat: endpoint to rename an attribute name in a table --- local/rest_api_gcbm/app.py | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/local/rest_api_gcbm/app.py b/local/rest_api_gcbm/app.py index 7184d3d7..5ee5a6ae 100644 --- a/local/rest_api_gcbm/app.py +++ b/local/rest_api_gcbm/app.py @@ -630,6 +630,58 @@ def send_table(): return resp, 200 +def rename(connection, table_name, old_new_names): + for old_name, new_name in old_new_names.items(): + try: + rename = ( + "ALTER TABLE " + + table_name + + " RENAME COLUMN " + + old_name + + " TO " + + new_name + ) + connection.execute(rename) + except Exception as exception: + return {"status" : 0, "message" : str(exception)} + return {"status" : 1, "message" : "success"} + +@app.route("/gcbm/attribute/rename", methods=['POST']) +def rename_attributes(): + """ + Rename an attribute in a table + --- + tags: + - gcbm + responses: + 200: + parameters: + - in: Params + values : JSON + JSON format: + title : name-of-simulation + tables : JSON + table_1 : JSON + old_name_1 : new_name_1 + old_name_2 : new_name_2 + description: If all the requests are successful, return status 1, else return status as 0 and the error + """ + payload = request.get_json() + title = payload["title"] + input_dir = f"{os.getcwd()}/input/{title}/db/" + connection = sqlite3.connect(f"{input_dir}/gcbm_input.db") + + # For each table_name in the payload, rename the attributes + for table_name in payload['tables']: + old_new_names = payload['tables'][table_name] + response = rename(connection, table_name, old_new_names) + + # Report an error immediately if any of the requests fail + if response['status'] == 0: + return {'status' : 0, 'message' : "Error in table " + table_name + " " + response['message']} + return {"status" : 1, "message" : "success"} + + @app.route("/gcbm/dynamic", methods=["POST"]) def gcbm_dynamic(): """