Skip to content

Commit

Permalink
Merge pull request #60 from lsst/tickets/DM-27519
Browse files Browse the repository at this point in the history
DM-27519: Fix couple of issues with history handling
  • Loading branch information
andy-slac committed Nov 15, 2020
2 parents 2b7511a + 3eaedab commit a51b5d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: pytest -r a -v -n 3 --open-files

- name: Install documenteer
run: pip install documenteer[pipelines]
run: pip install 'documenteer[pipelines]<0.6'

- name: Build documentation
working-directory: ./doc
Expand Down
17 changes: 9 additions & 8 deletions python/lsst/pex/config/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def format(config, name=None, writeSourceLine=True, prefix="", verbose=False):
print(format(config, name))

outputs = []
for value, stack, label in config.history[name]:
for value, stack, label in config.history.get(name, []):
output = []
for frame in stack:
if frame.function in ("__new__", "__set__", "__setattr__", "execfile", "wrapper") or \
Expand All @@ -219,14 +219,15 @@ def format(config, name=None, writeSourceLine=True, prefix="", verbose=False):

outputs.append([value, output])

# Find the maximum widths of the value and file:lineNo fields.
if writeSourceLine:
sourceLengths = []
for value, output in outputs:
sourceLengths.append(max([len(x[0][0]) for x in output]))
sourceLength = max(sourceLengths)
if outputs:
# Find the maximum widths of the value and file:lineNo fields.
if writeSourceLine:
sourceLengths = []
for value, output in outputs:
sourceLengths.append(max([len(x[0][0]) for x in output]))
sourceLength = max(sourceLengths)

valueLength = len(prefix) + max([len(str(value)) for value, output in outputs])
valueLength = len(prefix) + max([len(str(value)) for value, output in outputs])

# Generate the config history content.
msg = []
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/pex/config/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from .config import Config, Field
from .listField import ListField, List
from .configField import ConfigField
from .callStack import getCallerFrame, getCallStack
from .callStack import getCallerFrame, getCallStack, StackFrame

_dtypeMap = {
"bool": bool,
Expand Down Expand Up @@ -281,8 +281,8 @@ def setDefaults(self):
r = self.Control()
# Indicate in the history that these values came from C++, even
# if we can't say which line
self.readControl(r, __at=[(ctrl.__name__ + " C++", 0, "setDefaults", "")], __label="defaults",
__reset=True)
self.readControl(r, __at=[StackFrame(ctrl.__name__ + " C++", 0, "setDefaults", "")],
__label="defaults", __reset=True)
except Exception:
pass # if we can't instantiate the Control, don't set defaults

Expand Down

0 comments on commit a51b5d4

Please sign in to comment.