Skip to content

Commit beb97ee

Browse files
authored
Expose model default parameters to Jupyter interpreter (#601)
Signed-off-by: Ed Snible <[email protected]>
1 parent e5e474a commit beb97ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/pdl/pdl_notebook_ext.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from IPython.display import HTML, display_html
77

88
from .pdl import InterpreterConfig, exec_str
9+
from .pdl_ast import get_default_model_parameters
910
from .pdl_dumper import block_to_dict
1011
from .pdl_lazy import PdlDict, PdlList
1112

@@ -36,6 +37,10 @@ def pdl(self, line, cell, local_ns):
3637
else:
3738
# local_ns won't be lazy; make it lazy again
3839
scope = local_ns | {"pdl_context": PdlList(local_ns.get("pdl_context", []))}
40+
41+
if "pdl_model_default_parameters" not in scope:
42+
scope["pdl_model_default_parameters"] = get_default_model_parameters()
43+
3944
try:
4045
pdl_output = exec_str(
4146
cell,
@@ -52,8 +57,10 @@ def pdl(self, line, cell, local_ns):
5257
print(err)
5358
return
5459

60+
# (Note that this resolves the lazy pdl_context)
5561
for x, v in pdl_output["scope"].items():
5662
local_ns[x] = v
63+
5764
if args.viewer:
5865
display_html(
5966
self.pdl_viewer(

0 commit comments

Comments
 (0)