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

Benchmark reports #2

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ src/tranquilo_dev/slidev/public/bld_paper/
src/tranquilo_dev/slidev/public/bld_slidev/*
src/tranquilo_dev/slidev/public/bld_slidev/

# docs
docs/source/bld/*
docs/source/_static/bld/*
docs/source/index.md

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
20 changes: 20 additions & 0 deletions docs/rtd_environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: tranquilo-dev-docs
channels:
- conda-forge
- nodefaults
dependencies:
- python=3.11
- pip
- setuptools_scm
- toml
- black
- sphinx
- sphinxcontrib-bibtex
- sphinx-copybutton
- sphinx-panels
- ipython
- ipython_genutils
- nbsphinx
- pydata-sphinx-theme<=0.12.0
- myst-parser
60 changes: 60 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "tranquilo-dev"
author = "Janos Gabler, Tim Mensinger, Sebastian Gsell and Mariam Petrosyan"
release = "2023"
copyright = f"2023, {author}" # noqa: A001

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

extensions = [
"sphinx_copybutton",
"sphinx_panels",
"nbsphinx",
"myst_parser",
]


myst_enable_extensions = [
"colon_fence",
"dollarmath",
]

source_suffix = [".md"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.

html_theme = "pydata_sphinx_theme"


html_theme_options = {
"navbar_start": [],
"navbar_center": ["navbar-nav"],
"navbar_end": ["navbar-icon-links"],
"navbar_persistent": ["search-button"],
"navigation_with_keys": False,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
7 changes: 6 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ dependencies:
- pytask<0.4
- black
- nb_black
- pre-commit
- pdbpp
- pre-commit
- pytask >=0.2.3
- pytest
- pytest-cov
- pytest-xdist
- sphinx
- setuptools_scm
- toml
# Misc End

- pip:
- black
- blackcellmagic
- kaleido
- snakemd

# install this project locally
- -e .
Expand Down
50 changes: 50 additions & 0 deletions src/tranquilo_dev/benchmark_report/task_copy_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import shutil

import estimagic as em
import pytask
from tranquilo_dev.config import BLD
from tranquilo_dev.config import PLOT_CONFIG
from tranquilo_dev.config import PROBLEM_SETS
from tranquilo_dev.config import SPHINX_STATIC_BLD


SPHINX_FIGURES = SPHINX_STATIC_BLD / "figures"
BLD_FIGURES = BLD / "figures"

for name, info in PLOT_CONFIG.items():

for plot_type in ["profile", "deviation"]:
source_file = BLD_FIGURES / f"{plot_type}_plots" / f"{name}.svg"
dest_file = SPHINX_FIGURES / f"{plot_type}_plots" / f"{name}.svg"

@pytask.mark.depends_on(source_file)
@pytask.mark.produces(dest_file)
@pytask.mark.task(id=f"copy_{plot_type}_plot_{name}")
def task_copy_file(depends_on, produces):
shutil.copyfile(depends_on, produces)

plot_type = "convergence"
source_files = {}
dest_files = {}

problems = em.get_benchmark_problems(**PROBLEM_SETS[info["problem_name"]])
for problem in problems.keys():
source_files[problem] = (
BLD_FIGURES
/ f"{plot_type}_plots" # noqa: W503
/ f"{name}" # noqa: W503
/ f"{problem}.svg" # noqa: W503
)
dest_files[problem] = (
SPHINX_FIGURES
/ f"{plot_type}_plots" # noqa: W503
/ f"{name}" # noqa: W503
/ f"{problem}.svg" # noqa: W503
)

@pytask.mark.depends_on(source_files)
@pytask.mark.produces(dest_files)
@pytask.mark.task(id=f"copy_{plot_type}_plots_{name}")
def task_copy_files_convergence_plots(depends_on, produces):
for key in depends_on.keys():
shutil.copyfile(depends_on[key], produces[key])
31 changes: 31 additions & 0 deletions src/tranquilo_dev/benchmark_report/task_create_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytask
import snakemd
from tranquilo_dev.config import PLOT_CONFIG
from tranquilo_dev.config import SPHINX
from tranquilo_dev.config import SPHINX_PAGES_BLD


DEPS = {}
for name in PLOT_CONFIG.keys():
DEPS[name] = SPHINX_PAGES_BLD / f"{name}.md"


@pytask.mark.depends_on(DEPS)
@pytask.mark.produces(SPHINX / "index.md")
def task_create_index(produces):
doc = snakemd.new_doc()

doc.add_heading("Welcome to tranquilo-dev's benchmark reports!")
doc.add_paragraph("This is the index page of the benchmark reports.")

pages = "\n".join([f"bld/{name}" for name in PLOT_CONFIG.keys()])

doc.add_raw(f"```{{toctree}} \n--- \nmaxdepth: 1 \n--- \n{pages}\n```")

doc.add_paragraph(
"""
{ref}`search`
"""
)

doc.dump(produces.parent / "index")
Loading