Skip to content

Commit 7b4c5a0

Browse files
jieguangzhoublythed
authored andcommitted
Fixed Template substitutions
1 parent 4cf08db commit 7b4c5a0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4545
- Fix support for keys in new queue handler.
4646
- Fix the bug where the query itself changes after encoding
4747
- Fix the dependency error in copy_vectors within vector_index.
48+
- Fix Template substitutions
4849

4950

5051
## [0.2.0](https://github.com/superduper-io/superduper/compare/0.1.3...0.2.0]) (2024-Jun-21)

superduper/base/document.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def to_template(self, **substitutions):
282282

283283
def substitute(x):
284284
if isinstance(x, str):
285-
for k, v in substitutions:
285+
for k, v in substitutions.items():
286286
x = x.replace(k, f'<var:{v}>')
287287
return x
288288
if isinstance(x, dict):

superduper/components/template.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from superduper.base.constant import KEY_BLOBS, KEY_FILES
66
from superduper.base.datalayer import Datalayer
7-
from superduper.base.document import Document
7+
from superduper.base.document import Document, QueryUpdateDocument
88
from superduper.base.leaf import Leaf
99
from superduper.base.variables import _replace_variables
1010
from superduper.components.component import Component, _build_info_from_path
@@ -39,7 +39,9 @@ def __post_init__(self, db, artifacts, substitutions):
3939
self.template = self.template.encode(defaults=False, metadata=False)
4040
self.template = SuperDuperFlatEncode(self.template)
4141
if substitutions is not None:
42-
self.template = self.template.to_template(**substitutions)
42+
self.template = QueryUpdateDocument(self.template).to_template(
43+
**substitutions
44+
)
4345
if self.template_variables is None:
4446
self.template_variables = self.template.variables
4547
super().__post_init__(db, artifacts)

0 commit comments

Comments
 (0)