Skip to content

Commit

Permalink
Fixed Template substitutions
Browse files Browse the repository at this point in the history
  • Loading branch information
jieguangzhou authored and blythed committed Jul 12, 2024
1 parent 4cf08db commit 7b4c5a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix support for keys in new queue handler.
- Fix the bug where the query itself changes after encoding
- Fix the dependency error in copy_vectors within vector_index.
- Fix Template substitutions


## [0.2.0](https://github.com/superduper-io/superduper/compare/0.1.3...0.2.0]) (2024-Jun-21)
Expand Down
2 changes: 1 addition & 1 deletion superduper/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def to_template(self, **substitutions):

def substitute(x):
if isinstance(x, str):
for k, v in substitutions:
for k, v in substitutions.items():
x = x.replace(k, f'<var:{v}>')
return x
if isinstance(x, dict):
Expand Down
6 changes: 4 additions & 2 deletions superduper/components/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from superduper.base.constant import KEY_BLOBS, KEY_FILES
from superduper.base.datalayer import Datalayer
from superduper.base.document import Document
from superduper.base.document import Document, QueryUpdateDocument
from superduper.base.leaf import Leaf
from superduper.base.variables import _replace_variables
from superduper.components.component import Component, _build_info_from_path
Expand Down Expand Up @@ -39,7 +39,9 @@ def __post_init__(self, db, artifacts, substitutions):
self.template = self.template.encode(defaults=False, metadata=False)
self.template = SuperDuperFlatEncode(self.template)
if substitutions is not None:
self.template = self.template.to_template(**substitutions)
self.template = QueryUpdateDocument(self.template).to_template(
**substitutions
)
if self.template_variables is None:
self.template_variables = self.template.variables
super().__post_init__(db, artifacts)
Expand Down

0 comments on commit 7b4c5a0

Please sign in to comment.