Skip to content

Commit

Permalink
Reduce template nesting to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
blythed committed Nov 13, 2024
1 parent 46c5288 commit dedb031
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 285 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

**Before you create a Pull Request, remember to update the Changelog with your changes.**

## Changes Since Last Release
## Changes Since Last Release

#### Changed defaults / behaviours

Expand Down
13 changes: 9 additions & 4 deletions superduper/base/datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,15 @@ def load(
)
c = Document.decode(info, db=self)
c.db = self
if c.cache:
logging.info(f'Adding {c.huuid} to cache')
self.cluster.cache.put(c)
else:
try:
c = self.cluster.cache[type_id, identifier]
logging.info(f'Component {uuid} was found in cache...')
logging.debug(
f'Component {(type_id, identifier)} was found in cache...'
)
except KeyError:
logging.info(
f'Component ({type_id}, {identifier}) not found in cache, '
Expand All @@ -617,9 +622,9 @@ def load(
c = Document.decode(info, db=self)
c.db = self

if c.cache:
logging.info(f'Adding {c.huuid} to cache')
self.cluster.cache.put(c)
if c.cache:
logging.info(f'Adding {c.huuid} to cache')
self.cluster.cache.put(c)
return c

def _remove_component_version(
Expand Down
11 changes: 7 additions & 4 deletions superduper/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,11 @@ def export(
if not os.path.exists(path):
os.makedirs(path)

r = self.encode(defaults=defaults, metadata=metadata)
r = self.dict(defaults=defaults, metadata=metadata).encode(
defaults=defaults, metadata=metadata
)
if not metadata:
del r['uuid']

def rewrite_keys(r, keys):
if isinstance(r, dict):
Expand All @@ -691,9 +695,8 @@ def rewrite_keys(r, keys):
return r

if hr:
r = rewrite_keys(
r, {k: f"blob_{i}" for i, k in enumerate(r.get(KEY_BLOBS))}
)
blobs = r.get(KEY_BLOBS, {})
r = rewrite_keys(r, {k: f"blob_{i}" for i, k in enumerate(blobs)})

if r.get(KEY_BLOBS):
self._save_blobs_for_export(r[KEY_BLOBS], path)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 21 additions & 9 deletions templates/simple_rag/build.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2024-Nov-11 11:49:18.44| INFO | superduper.misc.plugins:13 | Loading plugin: mongodb\n",
"2024-Nov-11 11:49:18.49| INFO | superduper.base.datalayer:76 | Building Data Layer\n",
"2024-Nov-11 11:49:18.49| INFO | superduper.base.build:184 | Configuration: \n",
"2024-Nov-13 14:21:13.80| INFO | superduper.misc.plugins:13 | Loading plugin: mongodb\n",
"2024-Nov-13 14:21:13.85| INFO | superduper.base.datalayer:68 | Building Data Layer\n",
"2024-Nov-13 14:21:13.85| INFO | superduper.base.build:184 | Configuration: \n",
" +---------------+--------------+\n",
"| Configuration | Value |\n",
"+---------------+--------------+\n",
Expand Down Expand Up @@ -436,7 +436,16 @@
"execution_count": 16,
"id": "e6787c78-4b14-4a72-818b-450408a74331",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2024-Nov-13 14:21:14.69| INFO | superduper.components.application:39 | Resorting components based on topological order.\n",
"2024-Nov-13 14:21:14.70| INFO | superduper.components.application:56 | New order of components: <generator object topological_sort at 0x12de6bd80>\n"
]
}
],
"source": [
"from superduper import Application\n",
"\n",
Expand Down Expand Up @@ -487,10 +496,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2024-Nov-11 11:49:19.42| WARNING | superduper.base.document:479 | Leaf listener:chunker already exists\n",
"2024-Nov-11 11:49:19.42| WARNING | superduper.base.document:479 | Leaf model:chunker already exists\n",
"2024-Nov-11 11:49:19.43| WARNING | superduper.base.document:479 | Leaf datatype:dill already exists\n",
"2024-Nov-11 11:49:19.43| WARNING | superduper.base.document:479 | Leaf var-table-name-select-var-id-field-x already exists\n"
"2024-Nov-13 14:21:14.70| WARNING | superduper.components.listener:74 | output_table not found in listener.dict()\n",
"2024-Nov-13 14:21:14.71| WARNING | superduper.components.listener:74 | output_table not found in listener.dict()\n",
"2024-Nov-13 14:21:14.71| WARNING | superduper.base.document:565 | Leaf listener:chunker already exists\n",
"2024-Nov-13 14:21:14.71| WARNING | superduper.components.listener:74 | output_table not found in listener.dict()\n",
"2024-Nov-13 14:21:14.71| WARNING | superduper.base.document:565 | Leaf model:chunker already exists\n",
"2024-Nov-13 14:21:14.72| WARNING | superduper.base.document:565 | Leaf datatype:dill already exists\n",
"2024-Nov-13 14:21:14.72| WARNING | superduper.base.document:565 | Leaf var-table-name-select-var-id-field-x already exists\n"
]
}
],
Expand Down Expand Up @@ -561,7 +573,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2024-Nov-11 11:49:19.43| WARNING | superduper.base.document:479 | Leaf str already exists\n"
"2024-Nov-13 14:21:14.72| WARNING | superduper.base.document:565 | Leaf str already exists\n"
]
}
],
Expand Down
Loading

0 comments on commit dedb031

Please sign in to comment.