diff --git a/.gitignore b/.gitignore index c670d0f587..db35ac44c6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ test_tube_exp/ # Documentations docs/source/api docs/source/*.md +docs/source/generated # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/docs/.build_docs.sh b/docs/.build_docs.sh index 691f7fc229..ed14a808f8 100644 --- a/docs/.build_docs.sh +++ b/docs/.build_docs.sh @@ -1 +1 @@ -make clean ; make html --debug --jobs 2 SPHINXOPTS="-W" \ No newline at end of file +rm -rf source/generated; make clean ; make html --debug --jobs 2 SPHINXOPTS="-W" \ No newline at end of file diff --git a/docs/source/_static/main.css b/docs/source/_static/main.css new file mode 100644 index 0000000000..7441b775a4 --- /dev/null +++ b/docs/source/_static/main.css @@ -0,0 +1,3 @@ +col { + width: 50% !important; +} \ No newline at end of file diff --git a/docs/source/_templates/classtemplate.rst b/docs/source/_templates/classtemplate.rst new file mode 100644 index 0000000000..398a0ec07c --- /dev/null +++ b/docs/source/_templates/classtemplate.rst @@ -0,0 +1,14 @@ +.. role:: hidden + :class: hidden-section +.. currentmodule:: {{ module }} + + +{{ name | underline }} + +.. autoclass:: {{ name }} + :members: + + +.. + autogenerated from source/_templates/classtemplate.rst + note it does not have :inherited-members: diff --git a/docs/source/callbacks.rst b/docs/source/callbacks.rst index c78d08abc7..d8bbe04bc9 100644 --- a/docs/source/callbacks.rst +++ b/docs/source/callbacks.rst @@ -68,19 +68,6 @@ You can do pretty much anything with callbacks. -------------- -Callback Hooks --------------- - -.. automodule:: pytorch_lightning.callbacks.base - :noindex: - :exclude-members: - _del_model, - _save_model, - _abc_impl, - check_monitor_top_k, - ----------------- - Built-in Callbacks ------------------ Lightning has a few built-in callbacks. @@ -89,58 +76,21 @@ Lightning has a few built-in callbacks. For a richer collection of callbacks, check out our `bolts library `_. ----------------- +.. currentmodule:: pytorch_lightning.callbacks -.. automodule:: pytorch_lightning.callbacks.early_stopping - :noindex: - :exclude-members: - _del_model, - _save_model, - _abc_impl, - check_monitor_top_k, +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst ----------------- - -.. automodule:: pytorch_lightning.callbacks.gpu_stats_monitor - :noindex: - :exclude-members: - _get_gpu_stats, - _get_gpu_stat_keys, - _get_gpu_device_stat_keys, - ----------------- - -.. automodule:: pytorch_lightning.callbacks.gradient_accumulation_scheduler - :noindex: - :exclude-members: - _del_model, - _save_model, - _abc_impl, - check_monitor_top_k, - ----------------- - -.. automodule:: pytorch_lightning.callbacks.lr_monitor - :noindex: - :exclude-members: - _extract_lr, - _find_names - ----------------- - -.. automodule:: pytorch_lightning.callbacks.model_checkpoint - :noindex: - :exclude-members: - _del_model, - _save_model, - _abc_impl, - check_monitor_top_k, - ----------------- - -.. automodule:: pytorch_lightning.callbacks.progress - :noindex: - :exclude-members: + Callback + EarlyStopping + GPUStatsMonitor + GradientAccumulationScheduler + LearningRateMonitor + ModelCheckpoint + ProgressBar + ProgressBarBase ---------- diff --git a/docs/source/conf.py b/docs/source/conf.py index d95ea874d1..e24af41222 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,6 @@ import inspect # import m2r import builtins import pt_lightning_sphinx_theme -from sphinx.ext import apidoc PATH_HERE = os.path.abspath(os.path.dirname(__file__)) PATH_ROOT = os.path.join(PATH_HERE, '..', '..') @@ -138,10 +137,6 @@ language = None # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [ - 'api/pytorch_lightning.rst', - 'api/pl_examples.*', - 'api/pytorch_lightning.accelerators.*', - 'api/modules.rst', 'PULL_REQUEST_TEMPLATE.md', ] @@ -268,39 +263,11 @@ intersphinx_mapping = { todo_include_todos = True -# packages for which sphinx-apidoc should generate the docs (.rst files) -PACKAGES = [ - pytorch_lightning.__name__, - 'pl_examples', -] - -apidoc_output_folder = os.path.join(PATH_HERE, 'api') - - -def run_apidoc(_): - sys.path.insert(0, apidoc_output_folder) - - # delete api-doc files before generating them - if os.path.exists(apidoc_output_folder): - shutil.rmtree(apidoc_output_folder) - - for pkg in PACKAGES: - argv = ['-e', - '-o', apidoc_output_folder, - os.path.join(PATH_ROOT, pkg), - '**/test_*', - '--force', - '--private', - '--module-first'] - - apidoc.main(argv) - - def setup(app): # this is for hiding doctest decoration, # see: http://z4r.github.io/python/2011/12/02/hides-the-prompts-and-output/ app.add_javascript('copybutton.js') - app.connect('builder-inited', run_apidoc) + app.add_css_file('main.css') # copy all notebooks to local folder @@ -382,19 +349,17 @@ def linkcode_resolve(domain, info): % (github_user, github_repo, filename) +autosummary_generate = True autodoc_member_order = 'groupwise' autoclass_content = 'both' # the options are fixed and will be soon in release, # see https://github.com/sphinx-doc/sphinx/issues/5459 autodoc_default_options = { - 'members': None, - 'methods': None, - # 'attributes': None, + 'members': True, + 'methods': True, 'special-members': '__call__', 'exclude-members': '_abc_impl', 'show-inheritance': True, - 'private-members': True, - 'noindex': True, } # Sphinx will add “permalinks” for each heading and description environment as paragraph signs that diff --git a/docs/source/index.rst b/docs/source/index.rst index 03cebc0387..d2d41c2768 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -124,22 +124,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - - - -.. This is here to make sphinx aware of the modules but not throw an error/warning -.. toctree:: - :hidden: - - api/pytorch_lightning.core - api/pytorch_lightning.callbacks - api/pytorch_lightning.loggers - api/pytorch_lightning.metrics - api/pytorch_lightning.overrides - api/pytorch_lightning.profiler - api/pytorch_lightning.trainer - api/pytorch_lightning.utilities - api/pytorch_lightning.tuner - api/pytorch_lightning.plugins - api/pytorch_lightning.distributed - api/pytorch_lightning.cluster_environments diff --git a/pytorch_lightning/callbacks/base.py b/pytorch_lightning/callbacks/base.py index 1011e047b9..cdade99cb5 100644 --- a/pytorch_lightning/callbacks/base.py +++ b/pytorch_lightning/callbacks/base.py @@ -23,6 +23,8 @@ import abc class Callback(abc.ABC): r""" Abstract base class used to build new callbacks. + + Subclass this class and override any of the relevant hooks """ def setup(self, trainer, pl_module, stage: str): diff --git a/pytorch_lightning/callbacks/early_stopping.py b/pytorch_lightning/callbacks/early_stopping.py index 58fc9ec781..ddd142151e 100644 --- a/pytorch_lightning/callbacks/early_stopping.py +++ b/pytorch_lightning/callbacks/early_stopping.py @@ -39,6 +39,7 @@ torch_inf = torch.tensor(np.Inf) class EarlyStopping(Callback): r""" + Monitor a validation metric and stop training when it stops improving. Args: monitor: quantity to be monitored. Default: ``'early_stop_on'``.