Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-27519: Fix couple of issues with history handling #60

Merged
merged 2 commits into from
Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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