Skip to content

Commit ef7ebed

Browse files
authored
Update docs action (#311)
* Update env * Update action to fail on warnings * Fix api.rst warning * Add a few aliases * More docstring cleanup * Add langchain ref * Minor fixes * More doc links * More fixes * More fixes * More link updates * More doc fixes * Update method skipping logic * Typo fix * More docs fixes * Throw warnings * Use pdoc instead of pdev * Update deprecated field * More skip methods * Add pyptoject toml watch * Add conditionals on workflow * Add env options directly to command * Use pixi command, which now has opts in the env var * Bump elm version * Minor conf update * Copilot review updates * Update command name
1 parent 4f39584 commit ef7ebed

38 files changed

Lines changed: 439 additions & 344 deletions

.github/workflows/docs.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ permissions: write-all
44

55
on:
66
pull_request:
7+
paths:
8+
- compass/**
9+
- .github/workflows/docs.yml
10+
- pyproject.toml
11+
- pixi.lock
712
push:
813
branches: [main]
14+
paths:
15+
- compass/**
16+
- .github/workflows/docs.yml
17+
- pyproject.toml
18+
- pixi.lock
919
release:
1020
types: [created, published]
1121
workflow_dispatch:
@@ -26,15 +36,11 @@ jobs:
2636
with:
2737
pixi-version: v0.50.2
2838
locked: true
29-
cache: false
39+
cache: false # Don't use cache because we use the ``pdoc`` environment
3040
environments: pdoc
3141

3242
- name: Build Docs
33-
# Make documentation with warnings as errors.
34-
# The stricter Sphinx options below are currently disabled due to known documentation warnings.
35-
# Once all warnings are resolved, consider enabling this line to catch documentation issues early.
36-
# run: SPHINXOPTS="-W --keep-going -n" pixi run -e pdoc make-html
37-
run: pixi run -e pdoc make-html
43+
run: pixi run -e pdoc python-doc # This errors on warnings
3844

3945
- name: deploy
4046
uses: peaceiris/actions-gh-pages@v4.0.0

.github/workflows/lint-python.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ on:
66
- 'gh-pages'
77
paths:
88
- compass/**
9-
- pyproject.toml
109
- .github/workflows/lint-python.yml
10+
- pyproject.toml
11+
- pixi.lock
1112
pull_request:
1213
paths:
1314
- compass/**
14-
- pyproject.toml
1515
- .github/workflows/lint-python.yml
16+
- pyproject.toml
17+
- pixi.lock
1618

1719
jobs:
1820
lint:

compass/common/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def setup_graph_no_nodes(d_tree_name="Unknown Decision Tree", **kwargs):
6666
6767
Returns
6868
-------
69-
nx.DiGraph
69+
networkx.DiGraph
7070
Graph with no nodes but with global keywords set.
7171
"""
7272
feat = kwargs.get("feature_id", kwargs.get("feature", kwargs.get("url")))
@@ -180,7 +180,7 @@ def setup_base_setback_graph(**kwargs):
180180
181181
Returns
182182
-------
183-
nx.DiGraph
183+
networkx.DiGraph
184184
Graph instance that can be used to initialize an
185185
`elm.tree.DecisionTree`.
186186
"""
@@ -256,7 +256,7 @@ def setup_participating_owner(**kwargs):
256256
257257
Returns
258258
-------
259-
nx.DiGraph
259+
networkx.DiGraph
260260
Graph instance that can be used to initialize an
261261
`elm.tree.DecisionTree`.
262262
"""
@@ -373,7 +373,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
373373
374374
Returns
375375
-------
376-
nx.DiGraph
376+
networkx.DiGraph
377377
Graph instance that can be used to initialize an
378378
`elm.tree.DecisionTree`.
379379
"""
@@ -762,7 +762,7 @@ def setup_graph_permitted_use_districts(**kwargs):
762762
763763
Returns
764764
-------
765-
nx.DiGraph
765+
networkx.DiGraph
766766
Graph instance that can be used to initialize an
767767
`elm.tree.DecisionTree`.
768768
"""
@@ -858,14 +858,15 @@ class BaseTextExtractor:
858858
"the relevant content appears within a table, return the entire "
859859
"table, including headers and footers, exactly as formatted."
860860
)
861+
"""System message for text extraction LLM calls"""
861862
_USAGE_LABEL = LLMUsageCategory.DOCUMENT_ORDINANCE_SUMMARY
862863

863864
def __init__(self, llm_caller):
864865
"""
865866
866867
Parameters
867868
----------
868-
llm_caller : compass.llm.LLMCaller
869+
llm_caller : LLMCaller
869870
LLM Caller instance used to extract ordinance info with.
870871
"""
871872
self.llm_caller = llm_caller

compass/common/tree.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ class AsyncDecisionTree(DecisionTree):
3131
graph.
3232
Key Relationships:
3333
Inherits from :class:`~elm.tree.DecisionTree` to add ``async``
34-
capabilities. Uses a
35-
:class:`~compass.llm.calling.ChatLLMCaller` for LLm queries.
34+
capabilities. Uses a ChatLLMCaller for LLm queries.
3635
"""
3736

3837
def __init__(self, graph, usage_sub_label=None):
3938
"""
4039
4140
Parameters
4241
----------
43-
graph : nx.DiGraph
42+
graph : networkx.DiGraph
4443
Directed acyclic graph where nodes are LLM prompts and edges
4544
are logical transitions based on the response. Must have
4645
high-level graph attribute "chat_llm_caller" which is a
@@ -138,7 +137,7 @@ async def async_run(self, node0="init"):
138137
139138
Returns
140139
-------
141-
out : str | None
140+
out : str or None
142141
Final response from LLM at the leaf node or ``None`` if an
143142
``AttributeError`` was raised during execution.
144143
"""

compass/extraction/apply.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,19 @@ async def check_for_ordinance_info(
3232
Parameters
3333
----------
3434
doc : elm.web.document.BaseDocument
35-
A document potentially containing ordinance information. Note
36-
that if the document's attrs contains the
37-
``"contains_ord_info"`` key, it will not be processed. To force
38-
a document to be processed by this function, remove that key
39-
from the documents attrs.
35+
A document instance (PDF, HTML, etc) potentially containing
36+
ordinance information. Note that if the document's ``attrs``
37+
has the ``"contains_ord_info"`` key, it will not be processed.
38+
To force a document to be processed by this function, remove
39+
that key from the documents ``attrs``.
4040
tech : str
4141
Technology of interest (e.g. "solar", "wind", etc). This is
4242
used to set up some document validation decision trees.
43-
text_splitter : obj
44-
Instance of an object that implements a `split_text` method.
45-
The method should take text as input (str) and return a list
46-
of text chunks. Langchain's text splitters should work for this
47-
input.
48-
usage_tracker : compass.services.usage.UsageTracker, optional
43+
text_splitter : LCTextSplitter, optional
44+
Optional Langchain text splitter (or subclass instance), or any
45+
object that implements a `split_text` method. The method should
46+
take text as input (str) and return a list of text chunks.
47+
usage_tracker : UsageTracker, optional
4948
Optional tracker instance to monitor token usage during
5049
LLM calls. By default, ``None``.
5150
@@ -131,7 +130,7 @@ async def extract_date(doc, model_config, usage_tracker=None):
131130
----------
132131
doc : elm.web.document.BaseDocument
133132
A document potentially containing date information.
134-
usage_tracker : compass.services.usage.UsageTracker, optional
133+
usage_tracker : UsageTracker, optional
135134
Optional tracker instance to monitor token usage during
136135
LLM calls. By default, ``None``.
137136
@@ -165,20 +164,17 @@ async def extract_ordinance_text_with_llm(
165164
doc : elm.web.document.BaseDocument
166165
A document known to contain ordinance information. This means it
167166
must contain an ``"ordinance_text"`` key in the attrs. You can
168-
run :func:`~compass.extraction.apply.check_for_ordinance_info`
167+
run :func:`check_for_ordinance_info`
169168
to have this attribute populated automatically for documents
170169
that are found to contain ordinance data. Note that if the
171170
document's attrs does not contain the ``"ordinance_text"``
172171
key, you will get an error.
173-
text_splitter : obj
174-
Instance of an object that implements a `split_text` method.
175-
The method should take text as input (str) and return a list
176-
of text chunks. Langchain's text splitters should work for this
177-
input.
178-
extractor : compass.extraction.ordinance.WindOrdinanceTextExtractor
179-
Instance of
180-
:class:`~compass.extraction.ordinance.WindOrdinanceTextExtractor`
181-
used for ordinance text extraction.
172+
text_splitter : LCTextSplitter, optional
173+
Optional Langchain text splitter (or subclass instance), or any
174+
object that implements a `split_text` method. The method should
175+
take text as input (str) and return a list of text chunks.
176+
extractor : WindOrdinanceTextExtractor
177+
Object used for ordinance text extraction.
182178
original_text_key : str
183179
String corresponding to the `doc.attrs` key containing the
184180
original text (before extraction).
@@ -237,11 +233,10 @@ async def extract_ordinance_text_with_ngram_validation(
237233
that are found to contain ordinance data. Note that if the
238234
document's attrs does not contain the ``"ordinance_text"``
239235
key, it will not be processed.
240-
text_splitter : obj
241-
Instance of an object that implements a `split_text` method.
242-
The method should take text as input (str) and return a list
243-
of text chunks. Langchain's text splitters should work for this
244-
input.
236+
text_splitter : LCTextSplitter, optional
237+
Optional Langchain text splitter (or subclass instance), or any
238+
object that implements a `split_text` method. The method should
239+
take text as input (str) and return a list of text chunks.
245240
original_text_key : str
246241
String corresponding to the `doc.attrs` key containing the
247242
original text (before extraction).

compass/extraction/date.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,19 @@ class DateExtractor:
3535
"if you are confident that they represent the latest date this "
3636
"ordinance was enacted/updated"
3737
)
38+
"""System message for date extraction LLM calls"""
3839

3940
def __init__(self, structured_llm_caller, text_splitter=None):
4041
"""
4142
4243
Parameters
4344
----------
44-
structured_llm_caller : compass.llm.StructuredLLMCaller
45-
StructuredLLMCaller instance. Used for structured validation
46-
queries.
47-
text_splitter : TextSplitter, optional
48-
Optional
49-
:class:`langchain_text_splitters.character.TextSplitter`
50-
text splitter instance to attach to doc (used for
51-
splitting out pages in an HTML document).
45+
structured_llm_caller : StructuredLLMCaller
46+
Instance used for structured validation queries.
47+
text_splitter : LCTextSplitter, optional
48+
Optional text splitter (or subclass instance, or any object
49+
that implements a `split_text` method) to attach to doc
50+
(used for splitting out pages in an HTML document).
5251
By default, ``None``.
5352
"""
5453
self.slc = structured_llm_caller

compass/extraction/features.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SetbackFeatures:
3333
],
3434
"water": ["lakes", "reservoirs", "streams", "rivers", "wetlands"],
3535
}
36+
"""Aliases for mutually-exclusive setback features"""
3637
FEATURES_AS_IGNORE = {
3738
"structures": "structures",
3839
"property line": "property lines",
@@ -41,6 +42,7 @@ class SetbackFeatures:
4142
"transmission": "transmission lines",
4243
"water": "wetlands",
4344
}
45+
"""Features as they should appear in ignore phrases"""
4446
FEATURE_CLARIFICATIONS = {
4547
"structures": "",
4648
"property line": (
@@ -54,6 +56,7 @@ class SetbackFeatures:
5456
"transmission": "",
5557
"water": "",
5658
}
59+
"""Clarifications to add to feature prompts"""
5760

5861
def __init__(self):
5962
self._validate_descriptions()

compass/extraction/solar/graphs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def setup_graph_sef_types(**kwargs):
1818
1919
Returns
2020
-------
21-
nx.DiGraph
21+
networkx.DiGraph
2222
Graph instance that can be used to initialize an
2323
`elm.tree.DecisionTree`.
2424
"""
@@ -156,7 +156,7 @@ def setup_multiplier(**kwargs):
156156
157157
Returns
158158
-------
159-
nx.DiGraph
159+
networkx.DiGraph
160160
Graph instance that can be used to initialize an
161161
`elm.tree.DecisionTree`.
162162
"""

0 commit comments

Comments
 (0)