diff --git a/cal_tools/cal_tools/cal_tools.py b/cal_tools/cal_tools/cal_tools.py index 1bf060c3a64ff8978a65624fa6a6e1c3760c22ff..0e106db06f2fa579769f192af90d3cc782e5a273 100644 --- a/cal_tools/cal_tools/cal_tools.py +++ b/cal_tools/cal_tools/cal_tools.py @@ -29,27 +29,33 @@ def combine_report(run_path, calibration): comps = name.split("_") if len(comps) >= 2: comps = "_".join(comps[:-1]), comps[-1] - group, module = comps - if module == "None": - module = "All Modules" + group, conc_param = comps else: - group, module = comps[0], "All Modules" + group, conc_param = comps[0], "None" with open("{}/{}.rst".format(sphinx_path, group), "a") as gfile: - title = "{} - {}".format(calibration, module) - gfile.write(title + "\n") - gfile.write( "=" *len (title) + "\n") - gfile.write("\n") + if conc_param != "None": + title = "{} - Parameter {}".format(calibration, conc_param) + gfile.write(title + "\n") + gfile.write( "=" *len (title) + "\n") + gfile.write("\n") with open("{}/{}".format(run_path, entry), "r") as ifile: for line in ifile.readlines(): - gfile.write(line) + if conc_param == "None": + gfile.write(line) + elif " ".join(calibration.split()) != " ".join(line.split()): + gfile.write(line) gfile.write("\n\n") if isdir("{}/{}".format(run_path, entry)): shutil.copytree("{}/{}".format(run_path, entry), "{}/{}".format(sphinx_path, entry)) return sphinx_path -def make_report(run_path, tmp_path, out_path, project, author, version): +def make_report(run_path, tmp_path, out_path, project, author, version, report_to): run_path = os.path.abspath(run_path) + report_path, report_name = os.path.split(report_to) + if report_path != '': + out_path = report_path + try: import subprocess subprocess.check_call(["sphinx-quickstart", @@ -63,11 +69,23 @@ def make_report(run_path, tmp_path, out_path, project, author, version): "--ext-mathjax", "--makefile", "--no-batchfile", run_path]) + # now conf.py exists in temp folder, so add latex options to remove empty pages + patch_path = "{}".format(os.path.abspath(os.path.dirname(__file__))) + patch_file = ("{}/conf_latex.patch".format(patch_path)) + subprocess.check_call(["patch", + "{}/sphinx_rep/conf.py".format(tmp_path), + patch_file]) + + subprocess.check_call(["sed", + "-i", + "-e", + "s/{}.tex/{}.tex/g".format(project.replace(" ",""), report_name), + "{}/sphinx_rep/conf.py".format(tmp_path)], shell=False) except subprocess.CalledProcessError: raise Exception("Failed to run sphinx-quickbuild. Is sphinx installed?" "Generated simple index.rst instead") - + # quickbuild went well we need to edit the index file from shutil import move @@ -119,7 +137,7 @@ def make_report(run_path, tmp_path, out_path, project, author, version): # shutil.rmtree(tmp_path) -def finalize(joblist, run_path, out_path, project, calibration, author, version): +def finalize(joblist, run_path, out_path, project, calibration, author, version, report_to): print("Waiting on jobs to finish: {}".format(joblist)) @@ -134,7 +152,7 @@ def finalize(joblist, run_path, out_path, project, calibration, author, version) break sleep(10) sphinx_path = combine_report(run_path, calibration) - make_report(sphinx_path, run_path, out_path, project, author, version) + make_report(sphinx_path, run_path, out_path, project, author, version, report_to) diff --git a/cal_tools/cal_tools/conf_latex.patch b/cal_tools/cal_tools/conf_latex.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2259c2d82693c70ffb14ec31547805d72dd4c77 --- /dev/null +++ b/cal_tools/cal_tools/conf_latex.patch @@ -0,0 +1,10 @@ +--- conf_orig.py 2018-08-27 11:53:53.069138000 +0200 ++++ conf_latex.py 2018-08-27 11:53:18.472939000 +0200 +@@ -257,6 +257,7 @@ + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', ++ 'extraclassoptions': ',openany, oneside', + } + + # Grouping the document tree into LaTeX files. List of tuples diff --git a/cal_tools/cal_tools/conf_latex.py b/cal_tools/cal_tools/conf_latex.py new file mode 100644 index 0000000000000000000000000000000000000000..8b0ce452a6345c0766cec73cc35d7cbe465ff14f --- /dev/null +++ b/cal_tools/cal_tools/conf_latex.py @@ -0,0 +1,347 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 'Tutorial Calculation ' documentation build configuration file, created by +# sphinx-quickstart on Thu Aug 23 12:23:00 2018. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# 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.ext.intersphinx', + 'sphinx.ext.mathjax', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = '\'Tutorial Calculation \'' +copyright = '2018, \'Astrid Muennich\'' +author = '\'Astrid Muennich\'' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '' +# The full version, including alpha/beta/rc tags. +release = '' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- 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 = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. +# "<project> v<release> documentation" by default. +# +# html_title = '\'Tutorial Calculation \' v' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# 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'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'TutorialCalculationdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', + 'extraclassoptions': ',openany, oneside', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'TutorialCalculation.tex', '\'Tutorial Calculation \' Documentation', + '\'Astrid Muennich\'', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'tutorialcalculation', '\'Tutorial Calculation \' Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'TutorialCalculation', '\'Tutorial Calculation \' Documentation', + author, 'TutorialCalculation', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/cal_tools/cal_tools/conf_orig.py b/cal_tools/cal_tools/conf_orig.py new file mode 100644 index 0000000000000000000000000000000000000000..5074430ad326f5b22dff8cb009190d9033bcdbfd --- /dev/null +++ b/cal_tools/cal_tools/conf_orig.py @@ -0,0 +1,346 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 'Tutorial Calculation ' documentation build configuration file, created by +# sphinx-quickstart on Thu Aug 23 12:23:00 2018. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# 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.ext.intersphinx', + 'sphinx.ext.mathjax', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = '\'Tutorial Calculation \'' +copyright = '2018, \'Astrid Muennich\'' +author = '\'Astrid Muennich\'' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '' +# The full version, including alpha/beta/rc tags. +release = '' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- 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 = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. +# "<project> v<release> documentation" by default. +# +# html_title = '\'Tutorial Calculation \' v' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# 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'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'TutorialCalculationdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'TutorialCalculation.tex', '\'Tutorial Calculation \' Documentation', + '\'Astrid Muennich\'', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'tutorialcalculation', '\'Tutorial Calculation \' Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'TutorialCalculation', '\'Tutorial Calculation \' Documentation', + author, 'TutorialCalculation', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/docs/source/conf.py b/docs/source/conf.py index 2d12d2d83092f961e8ded13adc53f89a069b3996..3dedb841bc822aaa2274c81dc8d463ce8d785da5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -31,12 +31,22 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', ] +import sys +import os +from subprocess import Popen + +sys.path.append(os.path.abspath("../pycalibration/")) +p = Popen(["./makeAllDocs.sh"]) +p.communicate() + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -259,6 +269,7 @@ latex_elements = { # Latex figure (float) alignment # # 'figure_align': 'htbp', + 'extraclassoptions': 'openany, oneside', } # Grouping the document tree into LaTeX files. List of tuples @@ -266,7 +277,7 @@ latex_elements = { # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'EuropeanXFELOfflineCalibration.tex', 'European XFEL Offline Calibration Documentation', - 'The European XFEL Detector Group', 'manual'), + 'The European XFEL Detector Group', 'manual', True), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/docs/source/index.rst b/docs/source/index.rst index a55b1f41d11a73757b1b68786f0a410d99e28860..561aa4a85f1308d921af058aa6bba98131d6ccf8 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,6 +18,7 @@ Contents: available_notebooks advanced tutorial + _notebooks/index Indices and tables diff --git a/docs/source/makeAllDocs.sh b/docs/source/makeAllDocs.sh new file mode 100755 index 0000000000000000000000000000000000000000..f1c2d96b063a72af2b033bb0c3d7a60120b97964 --- /dev/null +++ b/docs/source/makeAllDocs.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# first convert notebooks to rst files +# the list of notebooks to convert: + +notebooks=(calversion) + +cd _notebooks + +echo "Tutorial Example"> index.rst +echo "================">> index.rst +echo "" >> index.rst +echo "Tutorial Notebook:" >> index.rst +echo "" >> index.rst +echo ".. toctree::" >> index.rst +echo " :maxdepth: 5" >> index.rst +echo " :titlesonly:" >> index.rst +echo "" >> index.rst + +for nb in ${notebooks[*]} +do + jupyter nbconvert --to rst ../../../notebooks/Tutorial/${nb}.ipynb --output-dir=./ + ##fix code blocks + sed -i.bak 's/code::/code-block::/g' ${nb}.rst + sed -i.bak 's/ipython3/python/g' ${nb}.rst + sed -i.bak 's/raw:: latex/math::/g' ${nb}.rst + sed -i.bak 's/``/`/g' ${nb}.rst + mv ${nb}.rst ${nb}.rst.end + echo ".. _${nb}:" > ${nb}.rst + cat ${nb}.rst.end >> ${nb}.rst + rm ${nb}.rst.end + echo " ${nb}" >> index.rst +done +rm *.bak + +#cd .. rm api/* sphinx-apidoc -o ./api/ -E ../../iCalibrationDB/ + diff --git a/notebooks/Tutorial/calversion.ipynb b/notebooks/Tutorial/calversion.ipynb index 14933bab4ff9399154c657de68c43ae2f98dac2e..7f81d1b26540b4cf1f9c3ecbff0d362556c57d5c 100644 --- a/notebooks/Tutorial/calversion.ipynb +++ b/notebooks/Tutorial/calversion.ipynb @@ -6,7 +6,9 @@ "source": [ "# Tutorial Calculation #\n", "\n", - "Author: Astrid Muennich, Version 0.1\n", + "Author: Astrid Muennich\n", + "\n", + "Version: 0.1\n", "\n", "A small example how to adapt a notebook to run with the offline calibration package \"pycalibation\".\n", "\n", diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index 96860b64069c1e7fe9cd868a602635b9564e7457..fd3321668913b1b6b617f9462f692c44f3ddc059 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -44,6 +44,10 @@ def make_initial_parser(): action="store_true", default=False, help="Do not run as a cluster job") + + parser.add_argument('--report-to', type=str, + help='Filename (and optionally path) for output report') + return parser parser = make_initial_parser() @@ -340,7 +344,6 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None, params = parameter_values(parms, **args) new_nb = replace_definitions(nb, params, execute=False) base_name = nbname.replace(".ipynb", "") - new_name = "{}_{}.ipynb".format(os.path.basename(base_name), suffix) nbpath = "{}/{}".format(temp_path, new_name) @@ -449,7 +452,9 @@ def run(): author = "anonymous" if not version: version = "" - + + title = title.rstrip() + run_uuid = uuid4() # check that a modules field is present if we run concurrently @@ -466,7 +471,20 @@ def run(): # create a temporary output directory to work in run_tmp_path = "{}/slurm_tmp_{}".format(temp_path, run_uuid) os.makedirs(run_tmp_path) - + + # Write all input parameters to rst file to be included to final report + parms = parameter_values(parms, **args) + with open("{}/slurm_tmp_{}/InputParameters.rst".format(temp_path, run_uuid), "w") as finfile: + finfile.write("Input Parameters \n") + finfile.write("================ \n") + for p in parms: + finfile.write("{} \n\n".format(p.comment)) + finfile.write(".. parsed-literal::\n") + if p.type is str: + finfile.write(" {} = '{}' \n\n".format(p.name, p.value)) + else: + finfile.write(" {} = {} \n\n".format(p.name, p.value)) + # wait on all jobs to run and then finalize the run by creating a report from the notebooks out_path = "{}/{}/{}/{}".format(report_path, detector.upper(), caltype.upper(), datetime.now().isoformat()) if try_report_to_output: @@ -484,11 +502,16 @@ def run(): os.makedirs(out_path) cmd = ('"from cal_tools.cal_tools import finalize; ' + 'finalize({{joblist}}, \'{run_path}\', \'{out_path}\', '+ - '\'{project}\', \'{calibration}\', \'{author}\', \'{version}\')"') + '\'{project}\', \'{calibration}\', \'{author}\', ' + '\'{version}\', \'{report_to}\')"') + report_to = title.replace(" ","") + if args["report_to"] is not None: + report_to = args["report_to"] + fmtcmd = cmd.format(run_path=run_tmp_path, out_path=out_path, project=title, calibration=title, - author=author, version=version) + author=author, version=version, report_to=report_to) joblist = [] if concurrency.get("parameter", None) is None: diff --git a/xfel_calibrate/notebooks.py b/xfel_calibrate/notebooks.py index 1b2d7ae1d784782f28b2e835dafec39fcebff63f..09f6e6f76a94dcbadee4fcd9c8ba0f8bba772527 100644 --- a/xfel_calibrate/notebooks.py +++ b/xfel_calibrate/notebooks.py @@ -96,7 +96,7 @@ notebooks = { "notebook": "notebooks/Tutorial/calversion.ipynb", "concurrency": {"parameter": "random_seed", "default concurrency": None, - "cluster cores": 32}, + "cluster cores": 4}, }, }, }