From 158511244cb758267d42880d6ca1a98a7b72d925 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 16 Oct 2023 09:24:00 +0200 Subject: [PATCH 1/4] [eve] Specifying --with-cc and -cxx breaks petsc build. --- scripts/cmake/DependenciesExternalProject.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/cmake/DependenciesExternalProject.cmake b/scripts/cmake/DependenciesExternalProject.cmake index 417ab7db6b5..03673bf9e67 100644 --- a/scripts/cmake/DependenciesExternalProject.cmake +++ b/scripts/cmake/DependenciesExternalProject.cmake @@ -132,13 +132,14 @@ if(OGS_USE_PETSC) if(NOT "--download-fc" IN_LIST OGS_PETSC_CONFIG_OPTIONS) list(APPEND _configure_opts --with-fc=0) endif() - if(DEFINED ENV{CC}) - list(APPEND _configure_opts --with-cc=$ENV{CC}) + if(NOT "${HOSTNAME}" MATCHES "frontend.*") + if(DEFINED ENV{CC}) + list(APPEND _configure_opts --with-cc=$ENV{CC}) + endif() + if(DEFINED ENV{CXX}) + list(APPEND _configure_opts --with-cxx=$ENV{CXX}) + endif() endif() - if(DEFINED ENV{CXX}) - list(APPEND _configure_opts --with-cxx=$ENV{CXX}) - endif() - message(STATUS "config opts: ${_configure_opts}") unset(ENV{PETSC_DIR}) BuildExternalProject( From 4f967b600b6f25cf38d7e11e4a17d5ab185c7343 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 16 Oct 2023 10:15:14 +0200 Subject: [PATCH 2/4] [nb] Specific frontmatter format ignored on SKIP_WEB notebooks. --- Tests/Data/Notebooks/testrunner.py | 125 ++++++++++++++--------------- 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/Tests/Data/Notebooks/testrunner.py b/Tests/Data/Notebooks/testrunner.py index 2d2af801499..8b60f1fd578 100644 --- a/Tests/Data/Notebooks/testrunner.py +++ b/Tests/Data/Notebooks/testrunner.py @@ -73,6 +73,66 @@ def save_to_website(exec_notebook_file, web_path): shutil.copytree(figures_path, symlink_figures_path) +def check_and_modify_frontmatter(): + # Check frontmatter has its own cell + first_cell = nb["cells"][0] + if ( + first_cell.cell_type == "markdown" + and first_cell.source.startswith("+++") + and not first_cell.source.endswith("+++") + ): + print( + f"Error: {notebook_filename} notebook metadata is not a separate cell (in markdown: separate by two newlines)!" + ) + success = False + + # Modify metadata + first_cell = nb["cells"][0] + if first_cell.source.startswith("---"): + print( + f"Error: {notebook_filename} frontmatter is not in TOML format! Use +++ delimitiers!" + ) + success = False + first_cell.source = first_cell.source.replace("+++\n", "+++\nnotebook = true\n", 1) + + # Insert Jupyter header with notebook source and binderhub link in second cell + repo = "https://gitlab.opengeosys.org/ogs/ogs" + branch = "master" + if "CI_MERGE_REQUEST_SOURCE_PROJECT_URL" in os.environ: + repo = os.environ["CI_MERGE_REQUEST_SOURCE_PROJECT_URL"] + branch = os.environ["CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"] + binder_link = f"https://mybinder.org/v2/gh/bilke/binder-ogs-requirements/master?urlpath=git-pull%3Frepo={repo}%26urlpath=lab/tree/ogs/{notebook_file_path_relative}%26branch={branch}" + text = f""" +
+

+ + This page is based on a Jupyter notebook.""" + if is_jupytext: + download_file_name = ( + Path(convert_notebook_file) + .rename(Path(convert_notebook_file).with_suffix(".ipynb")) + .name + ) + text += f""" +""" + text += f""" + + + +""" + text += f"""

\n\n""" + + second_cell = nb["cells"][1] + if second_cell.cell_type == "markdown": + second_cell.source = text + second_cell.source + else: + # Insert a new markdown cell + nb["cells"].insert(1, nbformat.v4.new_markdown_cell(text)) + + # Script arguments parser = argparse.ArgumentParser(description="Jupyter notebook testrunner.") parser.add_argument("notebooks", metavar="N", nargs="+", help="Notebooks to test.") @@ -152,69 +212,8 @@ def save_to_website(exec_notebook_file, web_path): # Write new notebook with open(convert_notebook_file, "w", encoding="utf-8") as f: - repo = "https://gitlab.opengeosys.org/ogs/ogs" - branch = "master" - if "CI_MERGE_REQUEST_SOURCE_PROJECT_URL" in os.environ: - repo = os.environ["CI_MERGE_REQUEST_SOURCE_PROJECT_URL"] - branch = os.environ["CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"] - - # Check frontmatter has its own cell - first_cell = nb["cells"][0] - if ( - first_cell.cell_type == "markdown" - and first_cell.source.startswith("+++") - and not first_cell.source.endswith("+++") - ): - print( - f"Error: {notebook_filename} notebook metadata is not a separate cell (in markdown: separate by two newlines)!" - ) - success = False - - # Check second cell is markdown - second_cell = nb["cells"][1] - if second_cell.cell_type != "markdown": - print( - f"Error: {notebook_filename} first cell after the frontmatter needs to be a markdown cell! Move the first Python cell below." - ) - success = False - - # Modify metadata - first_cell = nb["cells"][0] - if first_cell.source.startswith("---"): - print( - f"Error: {notebook_filename} frontmatter is not in TOML format! Use +++ delimitiers!" - ) - success = False - first_cell.source = first_cell.source.replace( - "+++\n", "+++\nnotebook = true\n", 1 - ) - - # Insert Jupyter header with notebook source and binderhub link - binder_link = f"https://mybinder.org/v2/gh/bilke/binder-ogs-requirements/master?urlpath=git-pull%3Frepo={repo}%26urlpath=lab/tree/ogs/{notebook_file_path_relative}%26branch={branch}" - text = f""" -
-

- - This page is based on a Jupyter notebook.""" - if is_jupytext: - download_file_name = ( - Path(convert_notebook_file) - .rename(Path(convert_notebook_file).with_suffix(".ipynb")) - .name - ) - text += f""" -""" - text += f""" - - - -""" - text += f"""

\n\n""" - second_cell.source = text + second_cell.source - + if args.hugo: + check_and_modify_frontmatter() nbformat.write(nb, f) status_string = "" From 29cade5727423294aeb8beae60d722226e878aba Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 16 Oct 2023 10:33:46 +0200 Subject: [PATCH 3/4] [ci] Generate web preview on testrunner and markdown notebook changes. --- scripts/ci/jobs/web-preview.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ci/jobs/web-preview.yml b/scripts/ci/jobs/web-preview.yml index 2314945f8f3..c504e908320 100644 --- a/scripts/ci/jobs/web-preview.yml +++ b/scripts/ci/jobs/web-preview.yml @@ -26,6 +26,8 @@ preview web site: - scripts/ci/jobs/web.yml - scripts/ci/jobs/web-preview.yml - Tests/Data/**/*.ipynb + - Tests/Data/**/*.md + - Tests/Data/Notebooks/testrunner.py artifacts: paths: - web/public From 254dcfd3e6636278ddd553865b9e1592384bd3fb Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 16 Oct 2023 10:45:56 +0200 Subject: [PATCH 4/4] [ci] Fix regex for web only pipelines. --- scripts/ci/extends/template-build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/extends/template-build-linux.yml b/scripts/ci/extends/template-build-linux.yml index ee5ab676da3..a535a375b0d 100644 --- a/scripts/ci/extends/template-build-linux.yml +++ b/scripts/ci/extends/template-build-linux.yml @@ -76,7 +76,7 @@ ctest_arguments="${ctest_arguments} -LE large" fi - if [[ "$CI_MERGE_REQUEST_LABELS" =~ [.*web\ only.*] ]]; then + if [[ "$CI_MERGE_REQUEST_LABELS" =~ .*web\ only.* ]]; then ctest_arguments="${ctest_arguments} -R nb-" fi