Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions pdl-live-react/src/pdl_ast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2406,16 +2406,6 @@ export type PdlModelInput =
*
*/
export type Platform = "granite-io"
/**
* Backend name and configuration.
*
*/
export type Backend =
| LocalizedExpression
| string
| {
[k: string]: unknown
}
/**
* Parameters sent to the model.
*
Expand Down Expand Up @@ -3220,7 +3210,7 @@ export interface GraniteioModelBlock {
pdl__usage?: PdlUsage | null
pdl__model_input?: PdlModelInput
platform?: Platform
backend: Backend
backend: unknown
processor?: unknown
parameters?: Parameters
}
Expand Down
5 changes: 2 additions & 3 deletions pdl-live-react/src/pdl_ast_utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { match, P } from "ts-pattern"

import { Backend, PdlBlock } from "./pdl_ast"
import { PdlBlock } from "./pdl_ast"
import { ExpressionT, isArgs } from "./helpers"

export function map_block_children(
Expand Down Expand Up @@ -72,8 +72,7 @@ export function map_block_children(
const parameters: Parameters = block.parameters
? f_expr(block.parameters)
: undefined
// @ts-expect-error: f_expr does not preserve the type of the expression
const backend: Backend = f_expr(block.backend)
const backend = f_expr(block.backend)
const processor = block.processor ? f_expr(block.processor) : undefined
return {
...block,
Expand Down
3 changes: 2 additions & 1 deletion src/pdl/pdl-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4612,7 +4612,8 @@
{
"additionalProperties": true,
"type": "object"
}
},
{}
],
"description": "Backend name and configuration.\n ",
"title": "Backend"
Expand Down
2 changes: 1 addition & 1 deletion src/pdl/pdl_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class GraniteioModelBlock(ModelBlock):
model: ExpressionType[str]
"""Model name used by the backend.
"""
backend: ExpressionType[str | dict[str, Any | object]]
backend: ExpressionType[str | dict[str, Any] | object]
"""Backend name and configuration.
"""
processor: Optional[ExpressionType[str | object]] = None
Expand Down
9 changes: 6 additions & 3 deletions src/pdl/pdl_notebook_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

from .pdl import InterpreterConfig, exec_str
from .pdl_ast import get_default_model_parameters
from .pdl_context import DependentContext
from .pdl_dumper import block_to_dict
from .pdl_lazy import PdlDict, PdlList
from .pdl_lazy import PdlDict


@magics_class
Expand All @@ -33,10 +34,12 @@ def pdl(self, line, cell, local_ns):
line = line.strip()
args = parse_argstring(self.pdl, line)
if args.reset_context:
scope = local_ns | {"pdl_context": PdlList([])}
scope = local_ns | {"pdl_context": DependentContext([])}
else:
# local_ns won't be lazy; make it lazy again
scope = local_ns | {"pdl_context": PdlList(local_ns.get("pdl_context", []))}
scope = local_ns | {
"pdl_context": local_ns.get("pdl_context", DependentContext([]))
}

if "pdl_model_default_parameters" not in scope:
scope["pdl_model_default_parameters"] = get_default_model_parameters()
Expand Down