From a6df9ef4d78c6ffd3f44f1173d511d68eab6e9da Mon Sep 17 00:00:00 2001 From: Vincent Raymond Date: Tue, 30 Apr 2024 03:33:18 -0400 Subject: [PATCH] [ci] Quality of life updates (#888) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary of Changes - Makes the `Can Produce` field in the model coverage reports clearer by specifying which target is being generated. - Adds color to "✓" and "✗" characters to make it clearer at a glance if a particular file could be ingested - Updated the default values of Environment Variables in skema.rest to remove dependency on Lum.AI deployment - Adds mathjax server to ci to support tests that previously relied on lum deployment ### Related issues Resolves #882 Resolves #883 Resolves #885 --------- Co-authored-by: Gus Hahn-Powell --- .github/workflows/tests-and-docs.yml | 23 ++++++++++++++++--- .../model_coverage_report/base.html | 6 +++++ .../model_coverage_report/html_builder.py | 8 +++++-- skema/rest/proxies.py | 5 ++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests-and-docs.yml b/.github/workflows/tests-and-docs.yml index 0f3b4bb0386..a860a35e725 100644 --- a/.github/workflows/tests-and-docs.yml +++ b/.github/workflows/tests-and-docs.yml @@ -19,6 +19,10 @@ env: # unfortunately, there doesn't seem to be a way # to reference SKEMA_RS_PORT in SKEMA_RS_ADDESS ... SKEMA_RS_ADDESS: "http://127.0.0.1:8001" + SKEMA_MATHJAX_PROTOCOL: "http://" + SKEMA_MATHJAX_HOST: "127.0.0.1" + SKEMA_MATHJAX_PORT: "8031" + SKEMA_MATHJAX_ADDRESS: "http://127.0.0.1:8031" jobs: docs: @@ -71,6 +75,10 @@ jobs: with: distribution: temurin java-version: 11 + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: 18 # Install dependencies - name: System-wide deps run: | @@ -137,8 +145,15 @@ jobs: cargo build --release --bin skema_service ./target/release/skema_service & echo "results for ${SKEMA_RS_HOST}:${SKEMA_RS_PORT}/version: `curl -s ${SKEMA_RS_HOST}:${SKEMA_RS_PORT}/version`" - - # NOTE: moved to runbefore the Python unit tests, so we can use the model coverage report results in testing + - name: Install MathJax service deps + working-directory: ./skema/img2mml/data_generation + run: | + npm install + - name: "Launch Mathjax in background for testing" + working-directory: ./skema/img2mml/data_generation + run: | + npm start & + # NOTE: moved to run before the Python unit tests, so we can use the model coverage report results in testing - name: "Code2fn model coverage reports" run: python skema/program_analysis/model_coverage_report/model_coverage_report.py $GITHUB_WORKSPACE/docs/coverage/code2fn_coverage/ all @@ -149,7 +164,9 @@ jobs: run: | echo "SKEMA_RS_ADDESS: $SKEMA_RS_ADDESS" python -c "import requests; print(requests.get('$SKEMA_RS_ADDESS/version').text)" - SKEMA_RS_ADDRESS=$SKEMA_RS_ADDESS pytest -vvv + echo "SKEMA_MATHJAX_ADDRESS: $SKEMA_MATHJAX_ADDRESS" + python -c "import requests; print(requests.get('$SKEMA_MATHJAX_ADDRESS/version').text)" + SKEMA_RS_ADDESS=$SKEMA_RS_ADDESS SKEMA_MATHJAX_ADDRESS=$SKEMA_MATHJAX_ADDRESS pytest -vvv - name: "Unit tests for Rust components" working-directory: ./skema/skema-rs diff --git a/skema/program_analysis/model_coverage_report/base.html b/skema/program_analysis/model_coverage_report/base.html index a997aa466ad..e8415cc6167 100644 --- a/skema/program_analysis/model_coverage_report/base.html +++ b/skema/program_analysis/model_coverage_report/base.html @@ -17,6 +17,12 @@ .hidden { display: none; } + .green { + color: green + } + .red { + color: red + } table { width: 100%; border-collapse: collapse; diff --git a/skema/program_analysis/model_coverage_report/html_builder.py b/skema/program_analysis/model_coverage_report/html_builder.py index 1fa5fcf144c..e3b0cc458b6 100644 --- a/skema/program_analysis/model_coverage_report/html_builder.py +++ b/skema/program_analysis/model_coverage_report/html_builder.py @@ -21,6 +21,10 @@ def add_table_header_field(self, table_header_tag, field_name: str): def add_table_data_field(self, table_row_tag, field_data: str, anchored=False, anchor_text=None): """Adds a new field to a table row""" field_tag = self.soup.new_tag("td") + if field_data == "✓": + field_tag["class"] = "green" + elif field_data == "✗": + field_tag["class"] = "red" if anchored: anchor_tag = self.soup.new_tag("a") @@ -53,7 +57,7 @@ def add_model_developer(): new_model_table_header_basic = self.soup.new_tag("tr") self.add_table_header_field(new_model_table_header_basic, "File Name") self.add_table_header_field(new_model_table_header_basic, "Num Lines") - self.add_table_header_field(new_model_table_header_basic, "Can Ingest") + self.add_table_header_field(new_model_table_header_basic, "Can Produce Gromet") self.add_table_header_field(new_model_table_header_basic, "Tree-Sitter Parse Tree") self.add_table_header_field(new_model_table_header_basic, "CAST") self.add_table_header_field(new_model_table_header_basic, "Gromet") @@ -89,7 +93,7 @@ def add_model_consumer(): new_model_table_header_basic = self.soup.new_tag("tr") self.add_table_header_field(new_model_table_header_basic, "File Name") - self.add_table_header_field(new_model_table_header_basic, "Can Ingest") + self.add_table_header_field(new_model_table_header_basic, "Can Produce AMR") self.add_table_header_field(new_model_table_header_basic, "AMR") # Append the elements to each other diff --git a/skema/rest/proxies.py b/skema/rest/proxies.py index 37423e53c99..bd4ba0095de 100644 --- a/skema/rest/proxies.py +++ b/skema/rest/proxies.py @@ -10,7 +10,7 @@ SKEMA_GRAPH_DB_PROTO = os.environ.get("SKEMA_GRAPH_DB_PROTO", "bolt://") SKEMA_GRAPH_DB_HOST = os.environ.get("SKEMA_GRAPH_DB_HOST", "127.0.0.1") SKEMA_GRAPH_DB_PORT = os.environ.get("SKEMA_GRAPH_DB_PORT", "7687") -SKEMA_RS_ADDESS = os.environ.get("SKEMA_RS_ADDRESS", "https://skema-rs.askem.lum.ai") +SKEMA_RS_ADDESS = os.environ.get("SKEMA_RS_ADDRESS", "http://127.0.0.1:8001") SKEMA_OPENAI_KEY = os.environ.get("SKEMA_OPENAI_KEY", "YOU_FORGOT_TO_SET_SKEMA_OPENAI_KEY") # MathJAX service @@ -19,8 +19,7 @@ SKEMA_MATHJAX_PORT = str(os.environ.get("SKEMA_MATHJAX_PORT", 8031)) SKEMA_MATHJAX_ADDRESS = os.environ.get( "SKEMA_MATHJAX_ADDRESS", - "https://mathjax.askem.lum.ai" - #f"{SKEMA_MATHJAX_PROTOCOL}{SKEMA_MATHJAX_HOST}:{SKEMA_MATHJAX_PORT}", + f"{SKEMA_MATHJAX_PROTOCOL}{SKEMA_MATHJAX_HOST}:{SKEMA_MATHJAX_PORT}", ) # Text Reading services