Skip to content

Commit

Permalink
Auto Update Docs (#118)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #118

This diff adds a python script `update_docs.py` which automatically generates `torcheval.metrics.rst` and `torcheval.metrics.functional.rst`, ensuring the API docs will always be in sync.

I also fixed several errors with the docstrings and missing imports which I found while writing this code.

Reviewed By: ananthsub

Differential Revision: D42404082

fbshipit-source-id: 7c3fabffdb016d6c7528c2c3f3bfacc5e083fd26
  • Loading branch information
bobakfb authored and facebook-github-bot committed Jan 10, 2023
1 parent 94e018d commit 3b7c10b
Show file tree
Hide file tree
Showing 27 changed files with 279 additions and 60 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
- id: check-added-large-files
args: ['--maxkb=500']
- id: end-of-file-fixer
exclude: '.*\.rst'

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7
Expand Down
1 change: 1 addition & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
python update_docs.py
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 changes: 17 additions & 0 deletions docs/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# This script shows how to build the docs.
# 1. First ensure you have the installed requirements for torcheval in `requirements.txt`
# 2. Then make sure you have installed the requirements inside `docs/requirements.txt`
# 3. Finally cd into docs/ and source this script. Sphinx reads through the installed module
# pull docstrings, so this script just installs the current version of torcheval on your
# system before it builds the docs with `make html`
cd .. || exit
pip install --no-build-isolation .
cd docs || exit
make html
32 changes: 16 additions & 16 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ A library with simple and straightforward tooling for model evaluations and a de
3. Is designed with extensibility in mind: you have the freedom to easily create your own metrics and leverage our toolkit.
4. Provides tools for profiling memory and compute requirements for PyTorch based models.

TorchEval Tutorials
-------------------
.. toctree::
:maxdepth: 2
:caption: Examples:

QuickStart Notebook <https://github.com/pytorch/torcheval/blob/main/examples/Introducing_TorchEval.ipynb>
metric_example.rst

QuickStart
===========================================

Expand Down Expand Up @@ -78,6 +69,22 @@ Further Reading
* Check out the distributed example
* Check out how to make your own metric

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

TorchEval Tutorials
-------------------
.. toctree::
:maxdepth: 2
:caption: Examples:

QuickStart Notebook <https://github.com/pytorch/torcheval/blob/main/examples/Introducing_TorchEval.ipynb>
metric_example.rst

TorchEval API
-----------------

Expand All @@ -89,10 +96,3 @@ TorchEval API
torcheval.metrics.functional.rst
torcheval.metrics.toolkit.rst
torcheval.tools.rst

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
34 changes: 27 additions & 7 deletions docs/source/torcheval.metrics.functional.rst
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
.. currentmodule:: torcheval.metrics.functional

Functional Metrics
==================

.. automodule:: torcheval.metrics.functional

Aggregation Metrics
-------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

auc
mean
sum
throughput

Classification Metrics
----------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

binary_accuracy
binary_auprc
binary_auroc
binary_binned_auroc
binary_binned_precision_recall_curve
binary_confusion_matrix
binary_f1_score
binary_normalized_entropy
binary_precision
binary_precision_recall_curve
binary_recall
binary_recall_at_fixed_precision
multiclass_accuracy
multiclass_auprc
multiclass_auroc
multiclass_binned_auroc
multiclass_binned_precision_recall_curve
multiclass_confusion_matrix
multiclass_f1_score
multiclass_precision
multiclass_precision_recall_curve
multiclass_recall
multilabel_accuracy
multilabel_auprc
multilabel_precision_recall_curve
multilabel_recall_at_fixed_precision
topk_multilabel_accuracy


Ranking Metrics
---------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
Expand All @@ -59,11 +65,25 @@ Ranking Metrics
weighted_calibration

Regression Metrics
------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

mean_squared_error
r2_score

Text Metrics
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

bleu_score
perplexity
word_error_rate
word_information_preserved
word_information_lost

34 changes: 27 additions & 7 deletions docs/source/torcheval.metrics.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
.. currentmodule:: torcheval.metrics

Metrics
=============

.. automodule:: torcheval.metrics


Aggregation Metrics
----------------------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

AUC
Cat
Max
Mean
Expand All @@ -21,13 +20,14 @@ Aggregation Metrics
Throughput

Classification Metrics
----------------------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

BinaryAccuracy
BinaryAUPRC
BinaryAUROC
BinaryBinnedAUROC
BinaryBinnedPrecisionRecallCurve
Expand All @@ -37,7 +37,9 @@ Classification Metrics
BinaryPrecision
BinaryPrecisionRecallCurve
BinaryRecall
BinaryRecallAtFixedPrecision
MulticlassAccuracy
MulticlassAUPRC
MulticlassAUROC
MulticlassBinnedAUROC
MulticlassBinnedPrecisionRecallCurve
Expand All @@ -47,10 +49,13 @@ Classification Metrics
MulticlassPrecisionRecallCurve
MulticlassRecall
MultilabelAccuracy
MultilabelAUPRC
MultilabelPrecisionRecallCurve
MultilabelRecallAtFixedPrecision
TopKMultilabelAccuracy

Ranking Metrics
----------------------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
Expand All @@ -62,7 +67,7 @@ Ranking Metrics
WeightedCalibration

Regression Metrics
----------------------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
Expand All @@ -71,8 +76,21 @@ Regression Metrics
MeanSquaredError
R2Score

Text Metrics
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:

BLEUScore
Perplexity
WordErrorRate
WordInformationLost
WordInformationPreserved

Windowed Metrics
----------------------------------
-------------------------------------------------------------------

.. autosummary::
:toctree: generated
Expand All @@ -81,4 +99,6 @@ Windowed Metrics
WindowedBinaryAUROC
WindowedBinaryNormalizedEntropy
WindowedClickThroughRate
WindowedMeanSquaredError
WindowedWeightedCalibration

Loading

0 comments on commit 3b7c10b

Please sign in to comment.