From 071ba590a88bdefa3a62852b4d3bc510630ece87 Mon Sep 17 00:00:00 2001 From: Duncan Blythe Date: Thu, 2 Jan 2025 14:18:29 +0100 Subject: [PATCH] Fix edit endpoint --- superduper/components/component.py | 7 +------ superduper/components/template.py | 2 +- superduper/rest/build.py | 9 +++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/superduper/components/component.py b/superduper/components/component.py index ddedc6007..489973be4 100644 --- a/superduper/components/component.py +++ b/superduper/components/component.py @@ -260,7 +260,7 @@ def _find_refs(r): def get_children(self, deep: bool = False) -> t.List["Component"]: """Get all the children of the component.""" - r = self.dict().encode(leaves_to_keep=Component) + r = self.dict().encode(leaves_to_keep=(Component,)) out = [v for v in r['_builds'].values() if isinstance(v, Component)] lookup = {} for v in out: @@ -890,11 +890,6 @@ def decode(cls, r, db: t.Optional[t.Any] = None, reference: bool = False): assert r['version'] is not None return db.load(r['type_id'], r['identifier'], r['version']) - def __setattr__(self, k, v): - if k in dc.fields(self): - self.changed.add(k) - return super().__setattr__(k, v) - def info(self, verbosity: int = 1): """Method to display the component information. diff --git a/superduper/components/template.py b/superduper/components/template.py index 6d0e7704f..fffd59df7 100644 --- a/superduper/components/template.py +++ b/superduper/components/template.py @@ -92,7 +92,7 @@ def form_template(self): 'types': self.types, 'schema': self.schema, **{k: v for k, v in self.template.items() if k != 'identifier'}, - '_template_name': self.identifier, + 'build_template': self.identifier, } diff --git a/superduper/rest/build.py b/superduper/rest/build.py index dbc731945..1b541de10 100644 --- a/superduper/rest/build.py +++ b/superduper/rest/build.py @@ -150,7 +150,16 @@ def db_upload(raw: bytes = File(...), db: 'Datalayer' = DatalayerDependency()): def _process_db_apply(db, component, id: str | None = None): def _apply(): nonlocal component + variables = None + build_template = component['build_template'] + if '_variables' in component: + variables = component['_variables'] + component = Document.decode(component, db=db).unpack() + if variables: + component.build_template = build_template + component.build_variables = variables + db.apply(component, force=True) if id: