From 1d67a045c92b5336889e2ee24a09289fac558de1 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Mon, 27 Jul 2020 22:20:00 -0500 Subject: [PATCH 01/15] Add Sphinx Doc --- docs/source/_static/development.rst | 0 docs/source/api.rst | 2 ++ docs/source/cli.rst | 2 ++ docs/source/conf.py | 56 +++++++++++++++++++++++++++++ docs/source/development.rst | 2 ++ docs/source/examples.rst | 2 ++ docs/source/faq.rst | 2 ++ docs/source/index.rst | 30 ++++++++++++++++ docs/source/installation.rst | 2 ++ docs/source/intro.rst | 3 ++ 10 files changed, 101 insertions(+) create mode 100644 docs/source/_static/development.rst create mode 100644 docs/source/api.rst create mode 100644 docs/source/cli.rst create mode 100644 docs/source/conf.py create mode 100644 docs/source/development.rst create mode 100644 docs/source/examples.rst create mode 100644 docs/source/faq.rst create mode 100644 docs/source/index.rst create mode 100644 docs/source/installation.rst create mode 100644 docs/source/intro.rst diff --git a/docs/source/_static/development.rst b/docs/source/_static/development.rst new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..f943ce2 --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,2 @@ +Python API +========== diff --git a/docs/source/cli.rst b/docs/source/cli.rst new file mode 100644 index 0000000..ef7c087 --- /dev/null +++ b/docs/source/cli.rst @@ -0,0 +1,2 @@ +Command Line API +================ diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..2d70b24 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,56 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# 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('.')) + + +# -- Project information ----------------------------------------------------- + +project = "pyhf-benchmark" +copyright = "2020, Bo Zheng" +author = "Bo Zheng" + +# The full version, including alpha/beta/rc tags +release = "0.0.1" + + +# -- 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 = ["m2r2"] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- 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 = "sphinx_rtd_theme" + +# 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"] + +source_suffix = [".rst", ".md"] diff --git a/docs/source/development.rst b/docs/source/development.rst new file mode 100644 index 0000000..ab0c3b3 --- /dev/null +++ b/docs/source/development.rst @@ -0,0 +1,2 @@ +Development +=========== diff --git a/docs/source/examples.rst b/docs/source/examples.rst new file mode 100644 index 0000000..bac945d --- /dev/null +++ b/docs/source/examples.rst @@ -0,0 +1,2 @@ +Examples +======== diff --git a/docs/source/faq.rst b/docs/source/faq.rst new file mode 100644 index 0000000..cde88d8 --- /dev/null +++ b/docs/source/faq.rst @@ -0,0 +1,2 @@ +FAQ +=== diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..ae5a63e --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,30 @@ +.. pyhf-benchmark documentation master file, created by + sphinx-quickstart on Mon Jul 27 21:00:57 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +.. toctree:: + :hidden: + + intro + examples + installation + development + faq + cli + api + +.. raw:: html + + Fork me on GitHub + +.. mdinclude:: ../../README.md + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/source/installation.rst b/docs/source/installation.rst new file mode 100644 index 0000000..11e4437 --- /dev/null +++ b/docs/source/installation.rst @@ -0,0 +1,2 @@ +Installation +============ diff --git a/docs/source/intro.rst b/docs/source/intro.rst new file mode 100644 index 0000000..e8b5eb2 --- /dev/null +++ b/docs/source/intro.rst @@ -0,0 +1,3 @@ +Introduction +============ + From 6ccdca700c573eaeb1282e93ef1f543dec5850bc Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Mon, 27 Jul 2020 22:22:08 -0500 Subject: [PATCH 02/15] Clear static --- docs/source/_static/development.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 docs/source/_static/development.rst diff --git a/docs/source/_static/development.rst b/docs/source/_static/development.rst deleted file mode 100644 index e69de29..0000000 From 839702c7bbf96e9fd2124d3fd978eaf5fb28f9d8 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Mon, 27 Jul 2020 22:34:45 -0500 Subject: [PATCH 03/15] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aab5333..0ec1867 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Options: ## Authors -`pyhf-benchmark` is openly developed by [Bo Zheng](https://iris-hep.org/fellows/BoZheng.html) and the [`pyhf` dev team](https://scikit-hep.org/pyhf/#authors). +`pyhf-benchmark` is openly developed by [Bo Zheng](https://iris-hep.org/fellows/BoZheng.html) and the [pyhf dev team](https://scikit-hep.org/pyhf/#authors). Please check the [contribution statistics for a list of contributors.](https://github.com/pyhf/pyhf-benchmark/graphs/contributors) From 09e4be66245b25a746aa56b9165454b319227cbc Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Mon, 27 Jul 2020 22:20:00 -0500 Subject: [PATCH 04/15] Add Sphinx Doc --- docs/source/_static/development.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/source/_static/development.rst diff --git a/docs/source/_static/development.rst b/docs/source/_static/development.rst new file mode 100644 index 0000000..e69de29 From c9308b44762a6dd717f9c53bed41eff49e789569 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Mon, 27 Jul 2020 22:22:08 -0500 Subject: [PATCH 05/15] Clear static --- docs/source/_static/development.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 docs/source/_static/development.rst diff --git a/docs/source/_static/development.rst b/docs/source/_static/development.rst deleted file mode 100644 index e69de29..0000000 From c91e60e830cf9b432a6c3b271d76eb310d488215 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Fri, 14 Aug 2020 11:27:36 -0500 Subject: [PATCH 06/15] Add comments --- src/pyhf_benchmark/jsonlfile.py | 27 +++++++++++++++- src/pyhf_benchmark/load.py | 26 ++++++++++++++-- src/pyhf_benchmark/manager.py | 21 +++++++++++++ src/pyhf_benchmark/mle.py | 14 ++++++++- src/pyhf_benchmark/plot.py | 55 +++++++++++++++++++++++++++++++++ src/pyhf_benchmark/run.py | 6 ++-- src/pyhf_benchmark/stats.py | 42 +++++++++++++++++++++++-- src/pyhf_benchmark/util.py | 8 +++++ 8 files changed, 190 insertions(+), 9 deletions(-) diff --git a/src/pyhf_benchmark/jsonlfile.py b/src/pyhf_benchmark/jsonlfile.py index e9f6d8f..e6b060b 100644 --- a/src/pyhf_benchmark/jsonlfile.py +++ b/src/pyhf_benchmark/jsonlfile.py @@ -5,9 +5,15 @@ class JsonlEventsFile(object): - """Used to store events during a run. """ + """Used to store information of CPU and GPU work status during a run.""" def __init__(self, start_time, fname, out_dir="."): + """ + Args: + start_time: Start time of a run + fname: output JSON filename + out_dir: output directory + """ self._start_time = start_time self.fname = out_dir / fname self.buffer = [] @@ -21,6 +27,9 @@ def __init__(self, start_time, fname, out_dir="."): self.load() def load(self): + """ + Load output JSON file and set file pointer to the end of the file. + """ last_row = {} with self.fname.open("r+") as f: for line in f: @@ -33,6 +42,12 @@ def load(self): self._start_time -= last_row["_runtime"] def flatten(self, dictionary): + """ + Flatten nested dictionary. + + Args: + dictionary: CPU and GPU work status contents + """ if isinstance(dictionary, dict): for k, v in list(dictionary.items()): if isinstance(v, dict): @@ -42,7 +57,14 @@ def flatten(self, dictionary): dictionary[k + "." + k2] = v2 def track(self, event, properties, timestamp=None): + """ + Flush work status back to output file. + Args: + event: Event name + properties: CPU and GPU work status contents + timestamp: Time stamp + """ self.lock.acquire() try: row = {} @@ -58,6 +80,9 @@ def track(self, event, properties, timestamp=None): os.fsync(self._file.fileno()) def close(self): + """ + Close output file and release the lock. + """ self.lock.acquire() try: if self._file: diff --git a/src/pyhf_benchmark/load.py b/src/pyhf_benchmark/load.py index cbd35c7..93db59c 100644 --- a/src/pyhf_benchmark/load.py +++ b/src/pyhf_benchmark/load.py @@ -6,7 +6,15 @@ def download(url): - """Download online data""" + """ + Download online data. + + Args: + url: URL for downloaded dataset + + Returns: + directory_name: directory for downloaded dataset + """ response = requests.get(url, stream=True) assert response.status_code == 200 @@ -25,10 +33,24 @@ def download(url): def open_local_file(file_path): - """Open local source files""" + """ + Open local source files + + Args: + file_path: Local path for downloaded dataset + + Returns: + directory_name: directory for local dataset + """ directory_name = Path("../data/" + file_path) return directory_name def delete_downloaded_file(directory_name): + """ + Delete downloaded dataset. + + Args: + directory_name: directory for downloaded dataset + """ shutil.rmtree(directory_name) diff --git a/src/pyhf_benchmark/manager.py b/src/pyhf_benchmark/manager.py index 09fe2a7..412cc7f 100644 --- a/src/pyhf_benchmark/manager.py +++ b/src/pyhf_benchmark/manager.py @@ -5,7 +5,13 @@ class RunManager(object): + """Manages a run's process and plot the running results.""" + def __init__(self, meta=None): + """ + Args: + meta: Meta information for a run + """ self._stat = [] self._meta = meta self._start_time = time.time() @@ -15,16 +21,31 @@ def __init__(self, meta=None): ) def start(self, meta=None): + """ + Start a new run. + + Args: + meta: Meta information for a run + + Returns: + + """ system = SystemStats(meta, self.directory) self.times += 1 self._stat.append(system) system.start() def close(self): + """ + End a run and plot the results. + """ system = self._stat.pop(0) system.shutdown() plot(system.dir) def shutdown(self): + """ + End a run and plot the results. + """ if self.times > 1: plot_comb(self.directory) diff --git a/src/pyhf_benchmark/mle.py b/src/pyhf_benchmark/mle.py index a679ac6..e590197 100644 --- a/src/pyhf_benchmark/mle.py +++ b/src/pyhf_benchmark/mle.py @@ -4,7 +4,17 @@ def get_bkg_and_signal(directory_name, model_point): - """Load background and signal""" + """ + Load background and signal + + Args: + directory_name: directory name for Background and PatchSet files + model_point: Model point + + Returns: + background_only: The JSON for the background only model + signal_patch_json: The JSON Patch for the signal model + """ bkgonly_path = directory_name / Path("BkgOnly.json") signal_path = directory_name / Path("patchset.json") @@ -33,9 +43,11 @@ def calculate_CLs(bkgonly_json, signal_patch_json): """ Calculate the observed CLs and the expected CLs band from a background only and signal patch. + Args: bkgonly_json: The JSON for the background only model signal_patch_json: The JSON Patch for the signal model + Returns: CLs_obs: The observed CLs value CLs_exp: List of the expected CLs value band diff --git a/src/pyhf_benchmark/plot.py b/src/pyhf_benchmark/plot.py index 14a2c2a..229fe55 100644 --- a/src/pyhf_benchmark/plot.py +++ b/src/pyhf_benchmark/plot.py @@ -48,6 +48,15 @@ def load(directory_name): + """ + Load output JSON file. + + Args: + directory_name: Local path for output JSON file + + Returns: + CPU and GPU work status in Pandas DataFrame format + """ path = directory_name / "events.jsonl" output_dic = {} @@ -69,6 +78,16 @@ def load(directory_name): def load_all(directory_name): + """ + Load output JSON file if one run contains multiple running results. + + Args: + directory_name: Local path for output JSON file + + Returns: + contents: Storage for work status + backends: Storage for backends information + """ list_of_paths = directory_name.glob("*") contents = [] backends = [] @@ -80,6 +99,16 @@ def load_all(directory_name): def subplot(y_label, column, output, directory, filename): + """ + Plot each metrics for the running results. + + Args: + y_label: Y axis Name + column: Value for Y axis + output: CPU and GPU work status contents + directory: Directory for plot file + filename: Filename for plot file + """ fig, ax = plt.subplots() x_value = output["_runtime"] if y_label == "Network Traffic (bytes)": @@ -98,6 +127,20 @@ def subplot(y_label, column, output, directory, filename): def subplot_comb(y_label, column, outputs, backends, directory, filename): + """ + Plot each metrics for the running results if multiple lines are plotted in one graph. + + Args: + y_label: Y axis Name + column: Value for Y axis + outputs: CPU and GPU work status contents + backends: Backends information + directory: Directory for plot file + filename: Filename for plot file + + Returns: + + """ fig, ax = plt.subplots() ax.set_xlabel("Time (minutes)") ax.set_ylabel(y_label) @@ -117,6 +160,12 @@ def subplot_comb(y_label, column, outputs, backends, directory, filename): def plot(directory): + """ + Plot CPU and GPU metrics for a run. + + Args: + directory: Directory for plot file + """ output = load(directory) idx = 0 while idx < len(ylabels): @@ -127,6 +176,12 @@ def plot(directory): def plot_comb(directory): + """ + Plot CPU and GPU metrics for a run if multiple lines are plotted in one graph. + + Args: + directory: Directory for plot file + """ outputs, backends = load_all(directory) idx = 0 while idx < len(ylabels): diff --git a/src/pyhf_benchmark/run.py b/src/pyhf_benchmark/run.py index 9fedb8d..f2e8935 100644 --- a/src/pyhf_benchmark/run.py +++ b/src/pyhf_benchmark/run.py @@ -37,14 +37,14 @@ @click.option("-n", "--number", "number", help="Number.", default="0", required=False) @click.option("-mm", "--mode", "mode", help="Mode.", default="fast", required=False) def run(computation, backend, path, url, model_point, number, mode): - """ + r""" Automatic process of taking pyhf computation. Usage: $ pyhf-benchmark run -c [-b] [-p] [-u] [-m] [-n] [-mm] - Examples: + Examples: $ pyhf-benchmark run -c mle -b numpy -u https://www.hepdata.net/record/resource/1267798?view=true -m [750,100] $ pyhf-benchmark run -c mle -u https://www.hepdata.net/record/resource/1267798?view=true -m [750,100] @@ -53,7 +53,7 @@ def run(computation, backend, path, url, model_point, number, mode): $ pyhf-benchmark run -c interpolation -b numpy -n 0 -mm slow - More information: + More information: https://github.com/pyhf/pyhf-benchmark diff --git a/src/pyhf_benchmark/stats.py b/src/pyhf_benchmark/stats.py index 6531a89..9c84990 100644 --- a/src/pyhf_benchmark/stats.py +++ b/src/pyhf_benchmark/stats.py @@ -11,6 +11,15 @@ def gpu_in_use_by_this_process(gpu_handle): + """ + Check if there is a GPU used by a process. + + Args: + gpu_handle: NVML Device handle + + Returns: + True or False + """ if not psutil: return False @@ -40,7 +49,14 @@ def gpu_in_use_by_this_process(gpu_handle): class SystemStats(object): + """CPU and GPU work status for each time stamp.""" + def __init__(self, meta=None, directory="."): + """ + Args: + meta: Meta data for a run. + directory: Output file Directory. + """ try: pynvml.nvmlInit() self.gpu_count = pynvml.nvmlDeviceGetCount() @@ -75,6 +91,9 @@ def __init__(self, meta=None, directory="."): ) def start(self): + """ + Start a thread to record CPU and GPU work status. + """ self._thread.start() @property @@ -87,15 +106,22 @@ def dir(self): @property def sample_rate_seconds(self): - """Sample system stats every this many seconds, default to 2""" + """ + Sample system stats every this many seconds, default to 2 + """ return self._sample_rate_seconds @property def samples_to_average(self): - """The number of samples to average before pushing, default to 3""" + """ + The number of samples to average before pushing, default to 3 + """ return self._samples_to_average def _thread_body(self): + """ + Control the logic of record and flush CPU and GPU work status. + """ while True: stats = self.stats() for stat, value in stats.items(): @@ -117,6 +143,9 @@ def _thread_body(self): break def shutdown(self): + """ + End the thread. + """ self._shutdown = True try: self._thread.join() @@ -125,6 +154,9 @@ def shutdown(self): pass def flush(self): + """ + Flush CPU and GPU work status back to output file for after a time interval. + """ stats = self.stats() for stat, value in stats.items(): if isinstance(value, Number): @@ -135,6 +167,12 @@ def flush(self): self.sampler = {} def stats(self): + """ + Record CPU and GPU work status after a time interval. + + Returns: + stats: CPU and GPU work status + """ stats = {} for i in range(0, self.gpu_count): handle = pynvml.nvmlDeviceGetHandleByIndex(i) diff --git a/src/pyhf_benchmark/util.py b/src/pyhf_benchmark/util.py index a67a57c..b7a9926 100644 --- a/src/pyhf_benchmark/util.py +++ b/src/pyhf_benchmark/util.py @@ -5,6 +5,14 @@ def random_histosets_alphasets_pair(): + """ + Generate random dataset for interpolation computation. + + Returns: + h: Histogram data + a: Alpha data + """ + def generate_shapes(histogramssets, alphasets): h_shape = [len(histogramssets), 0, 0, 0] a_shape = (len(alphasets), max(map(len, alphasets))) From 1645959b2e3f587bd5074b27e3e1cf4508adbe88 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Fri, 14 Aug 2020 16:53:48 -0500 Subject: [PATCH 07/15] Add cli python API --- docs/.ackrc | 1 + docs/Makefile | 25 ++++++ docs/make.bat | 35 +++++++++ docs/source/_templates/modifierclass.rst | 30 ++++++++ docs/source/api.rst | 96 ++++++++++++++++++++++++ docs/source/cli.rst | 4 + docs/source/conf.py | 46 +++++++++++- docs/source/development.rst | 60 ++++++++++++++- docs/source/examples.rst | 13 ++++ docs/source/exts/xref.py | 47 ++++++++++++ 10 files changed, 354 insertions(+), 3 deletions(-) create mode 100644 docs/.ackrc create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/_templates/modifierclass.rst create mode 100644 docs/source/exts/xref.py diff --git a/docs/.ackrc b/docs/.ackrc new file mode 100644 index 0000000..3796f7d --- /dev/null +++ b/docs/.ackrc @@ -0,0 +1 @@ +--ignore-directory=docs/_generated \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d14e46f --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,25 @@ +# 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 +GENERATEDDIR = _generated + +# 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) + +.PHONY: clean +clean: + rm -rf $(GENERATEDDIR)/* \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /dev/null +++ b/docs/make.bat @@ -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 + +if "%1" == "" goto help + +%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.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/_templates/modifierclass.rst b/docs/source/_templates/modifierclass.rst new file mode 100644 index 0000000..8e46efd --- /dev/null +++ b/docs/source/_templates/modifierclass.rst @@ -0,0 +1,30 @@ +:github_url: https://github.com/pyhf/pyhf-benchmark/blob/master/{{module | replace(".", "/") }} + +{{ name | escape | underline}} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ name }} + :show-inheritance: + + {% block attributes %} + {% if attributes %} + .. rubric:: Attributes + + {% for item in attributes %} + .. autoattribute:: {{ name }}.{{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block methods %} + {% if methods %} + .. rubric:: Methods + + {% for item in methods %} + {% if item not in inherited_members %} + .. automethod:: {{ name }}.{{ item }} + {% endif %} + {%- endfor %} + {% endif %} + {% endblock %} diff --git a/docs/source/api.rst b/docs/source/api.rst index f943ce2..6b72a9b 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -1,2 +1,98 @@ Python API ========== + +Run +----------------------------------------- + +.. currentmodule:: pyhf_benchmark.run + +.. autosummary:: + :toctree: _generated/ + + run + +Load +----------------------------------------- + +.. currentmodule:: pyhf_benchmark.load + +.. autosummary:: + :toctree: _generated/ + + download + open_local_file + delete_downloaded_file + +Maximum Likelihood Computation +----------------------------------------- + +.. currentmodule:: pyhf_benchmark.mle + +.. autosummary:: + :toctree: _generated/ + + get_bkg_and_signal + calculate_CLs + +Plot +-------- + +.. currentmodule:: pyhf_benchmark.plot + +.. autosummary:: + :toctree: _generated/ + + load + load_all + plot + subplot + plot_comb + subplot_comb + +Manager +---------- + +.. currentmodule:: pyhf_benchmark.manager + +.. autosummary:: + :toctree: _generated/ + :nosignatures: + :template: modifierclass.rst + + RunManager + +SystemStats +------------- + +.. currentmodule:: pyhf_benchmark.stats + +.. autosummary:: + :toctree: _generated/ + :nosignatures: + :template: modifierclass.rst + + SystemStats + gpu_in_use_by_this_process + +JsonlEventsFile +----------------- + +.. currentmodule:: pyhf_benchmark.jsonlfile + +.. autosummary:: + :toctree: _generated/ + :nosignatures: + :template: modifierclass.rst + + JsonlEventsFile + + +Utilities +--------- + +.. currentmodule:: pyhf_benchmark.util + +.. autosummary:: + :toctree: _generated/ + + random_histosets_alphasets_pair diff --git a/docs/source/cli.rst b/docs/source/cli.rst index ef7c087..4775d38 100644 --- a/docs/source/cli.rst +++ b/docs/source/cli.rst @@ -1,2 +1,6 @@ Command Line API ================ + +.. click:: pyhf_benchmark.cli.cli:pyhf_benchmark + :prog: pyhf_benchmark + :show-nested: diff --git a/docs/source/conf.py b/docs/source/conf.py index 2d70b24..b2fb30a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,6 +13,17 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) +from pathlib import Path +import sys + +sys.path.insert(0, str(Path("../src").resolve())) +sys.path.insert(1, str(Path("./exts").resolve())) + + +def setup(app): + app.add_css_file( + "https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.2/gh-fork-ribbon.min.css" + ) # -- Project information ----------------------------------------------------- @@ -30,7 +41,23 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["m2r2"] +extensions = [ + "m2r2", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", + "sphinxcontrib.bibtex", + "sphinx.ext.napoleon", + "sphinx_click.ext", + "nbsphinx", + "sphinx_issues", + "sphinx_copybutton", + "xref", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -41,6 +68,23 @@ exclude_patterns = [] +# external links +xref_links = {"arXiv:1007.1727": ("[1007.1727]", "https://arxiv.org/abs/1007.1727")} + +# Github repo +issues_github_path = "scikit-hep/pyhf/pyhf-benchmark" + +# Generate the API documentation when building +autosummary_generate = True +numpydoc_show_class_members = False + +# 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 + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for diff --git a/docs/source/development.rst b/docs/source/development.rst index ab0c3b3..a1e052a 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -1,2 +1,58 @@ -Development -=========== +Developing +========== + +To develop, we suggest using `virtual environments `__ together with ``pip`` or using `pipenv `__. Once the environment is activated, clone the repo from GitHub + +.. code-block:: console + + git clone https://github.com/pyhf/pyhf-benchmark.git + +and install all necessary packages for development + +.. code-block:: console + + python -m pip install --ignore-installed -U -e .[complete] + +Then setup the Git pre-commit hook for `Black `__ by running + +.. code-block:: console + + pre-commit install + +Testing +------- + +TestPyPI +~~~~~~~~ + +``pyhf-benchmark`` tests packaging and distributing by publishing each commit to +``master`` to `TestPyPI `__. +In addition, installation of the latest test release from TestPyPI can be tested +with + +.. code-block:: bash + + python -m pip install --extra-index-url https://test.pypi.org/simple/ --pre pyhf-benchmark + +.. note:: + + This adds TestPyPI as `an additional package index to search `__ + when installing ``pyhf-benchmark`` specifically. + PyPI will still be the default package index ``pip`` will attempt to install + from for all dependencies. + +Publishing +---------- + +Publishing to `PyPI `__ and `TestPyPI `__ +is automated through the `PyPA's PyPI publish GitHub Action `__ +and the ``pyhf-benchmark`` `Tag Creator GitHub Actions workflow `__. +A release can be created from any PR created by a core developer by adding a +``bumpversion`` tag to it that corresponds to the release type: +`major `__, +`minor `__, +`patch `__. +Once the PR is tagged with the label, the GitHub Actions bot will post a comment +with information on the actions it will take once the PR is merged. When the PR +has been reviewed, approved, and merged, the Tag Creator workflow will automatically +create a new release with ``bumpversion`` and then deploy the release to PyPI. diff --git a/docs/source/examples.rst b/docs/source/examples.rst index bac945d..38e5131 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -1,2 +1,15 @@ Examples ======== + +Try out in Binder! |Binder| + +.. |Binder| image:: https://mybinder.org/badge_logo.svg + :target: https://mybinder.org/v2/gh/scikit-hep/pyhf/master?filepath=docs%2Fexamples%2Fnotebooks%2Fbinderexample%2FStatisticalAnalysis.ipynb + +Notebooks: + +.. toctree:: + :maxdepth: 2 + :glob: + + examples/notebooks/* diff --git a/docs/source/exts/xref.py b/docs/source/exts/xref.py new file mode 100644 index 0000000..8c92629 --- /dev/null +++ b/docs/source/exts/xref.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +from docutils import nodes + +from sphinx.util import caption_ref_re + + +def xref(text, options=None, content=None): + # avoid mutable defaults + _ = {} if options is None else options + _ = [] if content is None else content + + title = target = text + # titleistarget = True + # look if explicit title and target are given with `foo ` syntax + brace = text.find("<") + if brace != -1: + # titleistarget = False + m = caption_ref_re.match(text) + if m: + target = m.group(2) + title = m.group(1) + else: + # fallback: everything after '<' is the target + target = text[brace + 1 :] + title = text[:brace] + + link = xref.links[target] + + if brace != -1: + pnode = nodes.reference(target, title, refuri=link[1]) + else: + pnode = nodes.reference(target, link[0], refuri=link[1]) + + return [pnode], [] + + +def get_refs(app): + + xref.links = app.config.xref_links + + +def setup(app): + + app.add_config_value("xref_links", {}, True) + app.add_role("xref", xref) + app.connect("builder-inited", get_refs) From 79e67426196b9289c6d8ccea7339662fec13e6c9 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Mon, 17 Aug 2020 11:01:59 -0500 Subject: [PATCH 08/15] Add ipython demo --- docs/source/examples.rst | 2 +- docs/source/examples/notebooks/demo.ipynb | 317 ++++++++++++++++++++++ 2 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 docs/source/examples/notebooks/demo.ipynb diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 38e5131..a4150cb 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -4,7 +4,7 @@ Examples Try out in Binder! |Binder| .. |Binder| image:: https://mybinder.org/badge_logo.svg - :target: https://mybinder.org/v2/gh/scikit-hep/pyhf/master?filepath=docs%2Fexamples%2Fnotebooks%2Fbinderexample%2FStatisticalAnalysis.ipynb + :target: examples/notebooks/demo.ipynb Notebooks: diff --git a/docs/source/examples/notebooks/demo.ipynb b/docs/source/examples/notebooks/demo.ipynb new file mode 100644 index 0000000..008d7aa --- /dev/null +++ b/docs/source/examples/notebooks/demo.ipynb @@ -0,0 +1,317 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "# Check pyhf-benchmark version" + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pyhf-benchmark, version 0.0.1\n" + ] + } + ], + "source": [ + "pyhf-benchmark --version" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test performance of CPU for maximum likelihood computation using numpy backend" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "pycharm": { + "is_executing": true + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dataset: 1Lbb-likelihoods-hepdata\n", + "Backend set to: numpy\n", + "\n", + "Starting fit\n", + "\n", + "fit 1Lbb-likelihoods-hepdata in 0:00:22.935410 seconds\n", + "\n", + "CLs_obs: 0.06628434618085545\n", + "CLs_exp: [9.517591120621866e-05, 0.0010228903813534387, 0.00946311787745848, 0.06581424960195661, 0.28239514754522566]\n" + ] + } + ], + "source": [ + "pyhf-benchmark run -c mle -b numpy -u https://www.hepdata.net/record/resource/1267798?view=true -m [750,100]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "run_20200817_1597677709\n" + ] + } + ], + "source": [ + "cd output/\n", + "ls" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1Lbb-likelihoods-hepdata_mle_numpy\n" + ] + } + ], + "source": [ + "cd run_20200817_1597677709\n", + "ls" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU_Threads.png\t\t\tProc_Memory_MB.png\n", + "CPU_Utilization.png\t\tProc_Memory_Percent.png\n", + "Disk_IO_Utilization.png\t\tProc_Memory_available.png\n", + "Memory_Utilization.png\t\tevents.jsonl\n", + "Network_Traffic.png\n" + ] + } + ], + "source": [ + "cd 1Lbb-likelihoods-hepdata_mle_numpy\n", + "ls" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test performance of CPU for maximum likelihood computation using numpy, jax, tensorflow and pytorch backends" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dataset: 1Lbb-likelihoods-hepdata\n", + "Backend set to: numpy\n", + "\n", + "Starting fit\n", + "\n", + "fit 1Lbb-likelihoods-hepdata in 0:00:22.913646 seconds\n", + "\n", + "CLs_obs: 0.06628434618085545\n", + "CLs_exp: [9.517591120621866e-05, 0.0010228903813534387, 0.00946311787745848, 0.06581424960195661, 0.28239514754522566]\n", + "Backend set to: jax\n", + "\n", + "Starting fit\n", + "\n", + "fit 1Lbb-likelihoods-hepdata in 0:00:21.528265 seconds\n", + "\n", + "CLs_obs: 0.0662840218994314\n", + "CLs_exp: [9.516724344736203e-05, 0.0010228157686477024, 0.009462595024861676, 0.06581172517487545, 0.2823886518706529]\n", + "Backend set to: tensorflow\n", + "\n", + "Starting fit\n", + "\n", + "WARNING:tensorflow:From /opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/array_grad.py:644: _EagerTensorBase.cpu (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", + "Instructions for updating:\n", + "Use tf.identity instead.\n", + "WARNING:tensorflow:From /opt/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/math_grad.py:297: setdiff1d (from tensorflow.python.ops.array_ops) is deprecated and will be removed after 2018-11-30.\n", + "Instructions for updating:\n", + "This op will be removed after the deprecation date. Please switch to tf.sets.difference().\n", + "fit 1Lbb-likelihoods-hepdata in 0:00:12.043619 seconds\n", + "\n", + "CLs_obs: 0.0662931278347969\n", + "CLs_exp: [9.5105112e-05 1.0222825e-03 9.4588548e-03 6.5793678e-02 2.8234217e-01]\n", + "Backend set to: pytorch\n", + "\n", + "Starting fit\n", + "\n", + "fit 1Lbb-likelihoods-hepdata in 0:00:05.200849 seconds\n", + "\n", + "CLs_obs: 0.0662882849574089\n", + "CLs_exp: [9.481733286520466e-05, 0.001019802875816822, 0.009441475383937359, 0.06570970267057419, 0.2821260690689087]\n" + ] + } + ], + "source": [ + "pyhf-benchmark run -c mle -b [numpy,jax,tensorflow,pytorch] -u https://www.hepdata.net/record/resource/1267798?view=true -m [750,100]" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "run_20200817_1597677709\trun_20200817_1597678017\n" + ] + } + ], + "source": [ + "cd output/\n", + "ls" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1Lbb-likelihoods-hepdata_mle_jax\tDisk_IO_Utilization.png\n", + "1Lbb-likelihoods-hepdata_mle_numpy\tMemory_Utilization.png\n", + "1Lbb-likelihoods-hepdata_mle_pytorch\tNetwork_Traffic.png\n", + "1Lbb-likelihoods-hepdata_mle_tensorflow\tProc_Memory_MB.png\n", + "CPU_Threads.png\t\t\t\tProc_Memory_Percent.png\n", + "CPU_Utilization.png\t\t\tProc_Memory_available.png\n" + ] + } + ], + "source": [ + "cd run_20200817_1597678017\n", + "ls" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test performance of CPU for interpolation computation using numpy backend" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [], + "source": [ + "pyhf-benchmark run -c interpolation -b numpy -n 0 -mm slow" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "run_20200817_1597677709\trun_20200817_1597678017\trun_20200817_1597678299\n" + ] + } + ], + "source": [ + "cd output/\n", + "ls" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Random_interpolation_numpy\n" + ] + } + ], + "source": [ + "cd run_20200817_1597678299\n", + "ls" + ] + } + ], + "metadata": { + "kernelspec": { + "name": "python3", + "language": "python", + "display_name": "Python 3" + }, + "language_info": { + "codemirror_mode": "shell", + "file_extension": ".sh", + "mimetype": "text/x-sh", + "name": "bash" + }, + "pycharm": { + "stem_cell": { + "cell_type": "raw", + "source": [ + "Demo\n", + "==============" + ], + "metadata": { + "collapsed": false + } + } + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} \ No newline at end of file From 591532cccae65e2a09db90e570cf57921274a103 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 19 Aug 2020 15:06:42 -0500 Subject: [PATCH 09/15] Add GHA workflow for CI --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4f81a1..9c3e570 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,3 +43,41 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml flags: unittests + + docs: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install --ignore-installed -U -q --no-cache-dir -e .[docs] + python -m pip list + sudo apt-get update + sudo apt-get -qq install pandoc + - name: Test and build docs + run: | + python -m doctest README.rst + python setup.py build_sphinx + touch docs/_build/html/.nojekyll + - name: Deploy docs to GitHub Pages + if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/_build/html + force_orphan: true + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' + commit_message: Deploy to GitHub pages From ff49ec762fa52622870be71ed412e266ffe59d21 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 19 Aug 2020 15:14:46 -0500 Subject: [PATCH 10/15] Remove doctest of README --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c3e570..2c515b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,13 +62,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --ignore-installed -U -q --no-cache-dir -e .[docs] + python -m pip install -q --no-cache-dir --use-feature=2020-resolver -e .[docs] python -m pip list sudo apt-get update sudo apt-get -qq install pandoc - name: Test and build docs run: | - python -m doctest README.rst python setup.py build_sphinx touch docs/_build/html/.nojekyll - name: Deploy docs to GitHub Pages From 173ac85e8566f805fea4515cfffe154a74244f50 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 19 Aug 2020 16:02:45 -0500 Subject: [PATCH 11/15] Fix YAML indent --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c515b5..c35775f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: file: ./coverage.xml flags: unittests - docs: + docs: runs-on: ubuntu-latest strategy: From a3bbd6273987aa2f155a9418a57e12c34602c8f0 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Wed, 19 Aug 2020 17:15:49 -0500 Subject: [PATCH 12/15] Change README style --- README.rst | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..0099d02 --- /dev/null +++ b/README.rst @@ -0,0 +1,82 @@ +pyhf-benchmark +============== + +|GitHub Project| |GitHub Actions Status: CI| |Code Coverage| |Code +style: black| + +Benchmarking of hardware acceleration of ``pyhf`` + +Environment +----------- + +For the time being, until a library can be created, use the +``requirements.txt`` to also serve setup duty in your virtual +environment in addition to providing a reproducible benchmarking +environment. + +:: + + (pyhf-benchmark) $ python -m pip install -r requirements.txt + +Usage +----- + +:: + + $ pyhf-benchmark run --help + Usage: pyhf-benchmark run [OPTIONS] + + Automatic process of taking pyhf computation. + + Usage: + + $ pyhf-benchmark run -c [-b] [-p] [-u] [-m] [-n] [-mm] + + Examples: + + $ pyhf-benchmark run -c mle -b numpy -u https://www.hepdata.net/record/resource/1267798?view=true -m [750,100] | + $ pyhf-benchmark run -c mle -u https://www.hepdata.net/record/resource/1267798?view=true -m [750,100] | + $ pyhf-benchmark run -c mle -b numpy -p 1Lbb-likelihoods-hepdata -m [750,100] | + $ pyhf-benchmark run -c interpolation -b jax -n 0 -mm fast | + $ pyhf-benchmark run -c interpolation -b numpy -n 0 -mm slow | + + More information: + + https://github.com/pyhf/pyhf-benchmark + + + + Options: + -c, -computation TEXT Type of computation [required] + -b, --backend TEXT Name of the pyhf backend to run with. + -p, --path TEXT Local path of workspace. + -u, --url TEXT Online data link. + -m, --model-point TEXT Model point. + -n, --number TEXT Number. + -mm, --mode TEXT Mode. + -h, --help Show this message and exit. + +Authors +------- + +``pyhf-benchmark`` is openly developed by `Bo +Zheng `__ and the `pyhf dev +team `__. + +Please check the `contribution statistics for a list of +contributors. `__ + +Acknowledgements +---------------- + +Bo Zheng was awarded an `IRIS-HEP +Fellowship `__ for this work. + +.. |GitHub Project| image:: https://img.shields.io/badge/GitHub--blue?style=social&logo=GitHub + :target: https://github.com/pyhf/pyhf-benchmark +.. |GitHub Actions Status: CI| image:: https://github.com/pyhf/pyhf-benchmark/workflows/CI/badge.svg?branch=master + :target: https://github.com/pyhf/pyhf-benchmark/actions?query=workflow%3ACI+branch%3Amaster +.. |Code Coverage| image:: https://codecov.io/gh/pyhf/pyhf-benchmark/graph/badge.svg?branch=master + :target: https://codecov.io/gh/pyhf/pyhf-benchmark?branch=master +.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black From e3976f39cec4edf0ffd20f74b350b2bbac697845 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Wed, 19 Aug 2020 17:17:23 -0500 Subject: [PATCH 13/15] Resolve review --- docs/source/conf.py | 3 +- docs/source/development.rst | 58 +---------------------------------- docs/source/index.rst | 2 +- setup.cfg | 4 +-- src/pyhf_benchmark/manager.py | 3 -- src/pyhf_benchmark/plot.py | 3 -- 6 files changed, 5 insertions(+), 68 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b2fb30a..1786222 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -42,7 +42,6 @@ def setup(app): # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - "m2r2", "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.coverage", @@ -72,7 +71,7 @@ def setup(app): xref_links = {"arXiv:1007.1727": ("[1007.1727]", "https://arxiv.org/abs/1007.1727")} # Github repo -issues_github_path = "scikit-hep/pyhf/pyhf-benchmark" +issues_github_path = "pyhf/pyhf-benchmark" # Generate the API documentation when building autosummary_generate = True diff --git a/docs/source/development.rst b/docs/source/development.rst index a1e052a..0b330ac 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -1,58 +1,2 @@ -Developing -========== - -To develop, we suggest using `virtual environments `__ together with ``pip`` or using `pipenv `__. Once the environment is activated, clone the repo from GitHub - -.. code-block:: console - - git clone https://github.com/pyhf/pyhf-benchmark.git - -and install all necessary packages for development - -.. code-block:: console - - python -m pip install --ignore-installed -U -e .[complete] - -Then setup the Git pre-commit hook for `Black `__ by running - -.. code-block:: console - - pre-commit install - Testing -------- - -TestPyPI -~~~~~~~~ - -``pyhf-benchmark`` tests packaging and distributing by publishing each commit to -``master`` to `TestPyPI `__. -In addition, installation of the latest test release from TestPyPI can be tested -with - -.. code-block:: bash - - python -m pip install --extra-index-url https://test.pypi.org/simple/ --pre pyhf-benchmark - -.. note:: - - This adds TestPyPI as `an additional package index to search `__ - when installing ``pyhf-benchmark`` specifically. - PyPI will still be the default package index ``pip`` will attempt to install - from for all dependencies. - -Publishing ----------- - -Publishing to `PyPI `__ and `TestPyPI `__ -is automated through the `PyPA's PyPI publish GitHub Action `__ -and the ``pyhf-benchmark`` `Tag Creator GitHub Actions workflow `__. -A release can be created from any PR created by a core developer by adding a -``bumpversion`` tag to it that corresponds to the release type: -`major `__, -`minor `__, -`patch `__. -Once the PR is tagged with the label, the GitHub Actions bot will post a comment -with information on the actions it will take once the PR is merged. When the PR -has been reviewed, approved, and merged, the Tag Creator workflow will automatically -create a new release with ``bumpversion`` and then deploy the release to PyPI. +------- \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index ae5a63e..723a9ed 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,7 +18,7 @@ Fork me on GitHub -.. mdinclude:: ../../README.md +.. include:: ../../README.rst diff --git a/setup.cfg b/setup.cfg index 9a4f96b..9ce98f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,8 +2,8 @@ name = pyhf_benchmark version = 0.0.1 description = Benchmarking of hardware acceleration of pyhf -long_description = file: README.md -long_description_content_type = text/markdown +long_description = file: README.rst +long_description_content_type = text/x-rst url = https://github.com/pyhf/pyhf-benchmark author = Bo Zheng, Lukas Heinrich, Matthew Feickert, Giordon Stark author_email = bozheng96@gmail.com, lukas.heinrich@cern.ch, matthew.feickert@cern.ch, gstark@cern.ch diff --git a/src/pyhf_benchmark/manager.py b/src/pyhf_benchmark/manager.py index 412cc7f..19b5bab 100644 --- a/src/pyhf_benchmark/manager.py +++ b/src/pyhf_benchmark/manager.py @@ -26,9 +26,6 @@ def start(self, meta=None): Args: meta: Meta information for a run - - Returns: - """ system = SystemStats(meta, self.directory) self.times += 1 diff --git a/src/pyhf_benchmark/plot.py b/src/pyhf_benchmark/plot.py index 229fe55..32bdd47 100644 --- a/src/pyhf_benchmark/plot.py +++ b/src/pyhf_benchmark/plot.py @@ -137,9 +137,6 @@ def subplot_comb(y_label, column, outputs, backends, directory, filename): backends: Backends information directory: Directory for plot file filename: Filename for plot file - - Returns: - """ fig, ax = plt.subplots() ax.set_xlabel("Time (minutes)") From 8ec3751d93920f912305077ec7b4d9aade7242f5 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Wed, 19 Aug 2020 17:17:39 -0500 Subject: [PATCH 14/15] Add extra doc --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index c8df5b1..e6c5b1c 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,13 @@ + ["check-manifest", "bumpversion~=0.5", "pre-commit", "twine",] ) ) +extras_require["docs"] = sorted( + set( + [ + + ] + ) +) extras_require["complete"] = sorted(set(sum(extras_require.values(), []))) setuptools.setup(extras_require=extras_require,) From 4883ed02e33a54c2bdaf6e4f75d00462d042a824 Mon Sep 17 00:00:00 2001 From: Bo Zheng Date: Wed, 19 Aug 2020 17:23:25 -0500 Subject: [PATCH 15/15] Add doc exts --- setup.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/setup.py b/setup.py index e6c5b1c..1d944ad 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,7 @@ + ["check-manifest", "bumpversion~=0.5", "pre-commit", "twine",] ) ) -extras_require["docs"] = sorted( - set( - [ - - ] - ) -) +extras_require["docs"] = sorted(set(["sphinx"])) extras_require["complete"] = sorted(set(sum(extras_require.values(), []))) setuptools.setup(extras_require=extras_require,)