Skip to content

Commit 759151d

Browse files
committed
add docs
1 parent 97e36b8 commit 759151d

File tree

14 files changed

+531
-239
lines changed

14 files changed

+531
-239
lines changed

.readthedocs.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
3+
sphinx:
4+
configuration: docs/source/conf.py
5+
fail_on_warning: true
6+
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3.10"
11+
12+
python:
13+
install:
14+
- method: pip
15+
path: .
16+
extra_requirements:
17+
- dev

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ format-check :
1313
.PHONY : type-check
1414
type-check :
1515
mypy .
16+
17+
.PHONY : docs
18+
docs :
19+
rm -rf docs/build/
20+
sphinx-autobuild -b html --watch src/olmo_core/ --watch README.md docs/source/ docs/build/
21+
22+
.PHONY : build
23+
build :
24+
rm -rf *.egg-info/
25+
python -m build

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?= -W
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.https://www.sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/_static/css/custom.css

Whitespace-only changes.

docs/source/_static/favicon.ico

15 KB
Binary file not shown.
20.1 KB
Loading

docs/source/conf.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
import logging
8+
import os
9+
import sys
10+
from datetime import datetime
11+
12+
# -- Path setup --------------------------------------------------------------
13+
14+
# If extensions (or modules to document with autodoc) are in another directory,
15+
# add these directories to sys.path here. If the directory is relative to the
16+
# documentation root, use os.path.abspath to make it absolute, like shown here.
17+
#
18+
sys.path.insert(0, os.path.abspath("../../"))
19+
20+
from olmo_core.version import VERSION, VERSION_SHORT # noqa: E402
21+
22+
# -- Project information -----------------------------------------------------
23+
24+
project = "OLMo-core"
25+
copyright = f"{datetime.today().year}, Allen Institute for Artificial Intelligence"
26+
author = "Allen Institute for Artificial Intelligence"
27+
version = VERSION_SHORT
28+
release = VERSION
29+
30+
31+
# -- General configuration ---------------------------------------------------
32+
33+
# Add any Sphinx extension module names here, as strings. They can be
34+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
35+
# ones.
36+
extensions = [
37+
"sphinx.ext.autodoc",
38+
"sphinx.ext.napoleon",
39+
"myst_parser",
40+
"sphinx.ext.intersphinx",
41+
"sphinx.ext.viewcode",
42+
"sphinx_copybutton",
43+
"sphinx_autodoc_typehints",
44+
]
45+
46+
# Tell myst-parser to assign header anchors for h1-h3.
47+
myst_heading_anchors = 3
48+
49+
suppress_warnings = ["myst.header"]
50+
51+
# Add any paths that contain templates here, relative to this directory.
52+
templates_path = ["_templates"]
53+
54+
# List of patterns, relative to source directory, that match files and
55+
# directories to ignore when looking for source files.
56+
# This pattern also affects html_static_path and html_extra_path.
57+
exclude_patterns = ["_build"]
58+
59+
source_suffix = [".rst", ".md"]
60+
61+
intersphinx_mapping = {
62+
"python": ("https://docs.python.org/3", None),
63+
"docker": ("https://docker-py.readthedocs.io/en/stable/", None),
64+
"requests": ("https://requests.readthedocs.io/en/stable/", None),
65+
}
66+
67+
# By default, sort documented members by type within classes and modules.
68+
autodoc_member_order = "bysource"
69+
autodoc_default_options = {"show-inheritance": True, "undoc-members": True}
70+
71+
# Include default values when documenting parameter types.
72+
typehints_defaults = "comma"
73+
74+
copybutton_prompt_text = r">>> |\.\.\. "
75+
copybutton_prompt_is_regexp = True
76+
77+
# -- Options for HTML output -------------------------------------------------
78+
79+
# The theme to use for HTML and HTML Help pages. See the documentation for
80+
# a list of builtin themes.
81+
#
82+
html_theme = "furo"
83+
84+
html_title = f"OLMo-core v{VERSION}"
85+
86+
# Add any paths that contain custom static files (such as style sheets) here,
87+
# relative to this directory. They are copied after the builtin static files,
88+
# so a file named "default.css" will overwrite the builtin "default.css".
89+
html_static_path = ["_static"]
90+
91+
html_css_files = ["css/custom.css"]
92+
93+
html_favicon = "_static/favicon.ico"
94+
95+
html_theme_options = {
96+
"light_logo": "olmo-full-color.png",
97+
"dark_logo": "olmo-full-color.png",
98+
"footer_icons": [
99+
{
100+
"name": "GitHub",
101+
"url": "https://github.com/allenai/OLMo-core",
102+
"html": """
103+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
104+
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
105+
</svg>
106+
""", # noqa: E501
107+
"class": "",
108+
},
109+
],
110+
}
111+
112+
# -- Hack to get rid of stupid warnings from sphinx_autodoc_typehints --------
113+
114+
115+
class ShutupSphinxAutodocTypehintsFilter(logging.Filter):
116+
def filter(self, record: logging.LogRecord) -> bool:
117+
if "Cannot resolve forward reference" in record.msg:
118+
return False
119+
if "Failed guarded type import" in record.msg:
120+
return False
121+
return True
122+
123+
124+
logging.getLogger("sphinx.sphinx_autodoc_typehints").addFilter(ShutupSphinxAutodocTypehintsFilter())
125+
126+
127+
def autodoc_skip_member(app, what, name, obj, skip, options):
128+
"""
129+
Skip documenting these Pydantic-specific attributes.
130+
"""
131+
del app, what, obj, skip, options
132+
exclude = name in {"model_config", "model_fields", "model_computed_fields"}
133+
return True if exclude else None
134+
135+
136+
def setup(app):
137+
app.connect("autodoc-skip-member", autodoc_skip_member)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributed.checkpoint
2+
======================
3+
4+
.. automodule:: olmo_core.distributed.checkpoint
5+
:members: save_model_and_optim_state, load_model_and_optim_state, Checkpointer, StorageMetadata, TensorStorageMetadata
6+
:member-order: bysource

0 commit comments

Comments
 (0)