Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug in the update mechanism that fails when the parent refere… #2701

Merged
merged 1 commit into from
Dec 26, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix crontab drop method.
- Fix job status update.
- Fix a random bug caused by queue thread-safety issues when OSS used crontab.
- Fix the bug in the update mechanism that fails when the parent references an existing child.

## [0.4.0](https://github.com/superduper-io/superduper/compare/0.4.0...0.3.0]) (2024-Nov-02)

Expand Down
12 changes: 11 additions & 1 deletion superduper/base/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def replace_existing(x):
r['query'] = r['query'].replace(uuid, non_breaking_changes[uuid])
for i, doc in enumerate(r['documents']):
replace = {}
if not isinstance(doc, Document):
doc = Document(doc)
doc = doc.map(
lambda x: replace_existing(x),
condition=lambda x: isinstance(x, str),
Expand Down Expand Up @@ -259,13 +261,17 @@ def replace_existing(x):
this_diff = Document(current_serialized, schema=current_serialized.schema).diff(
serialized
)

logging.info(f'Found identical {object.huuid}')

if not this_diff:
# if no change then update the component
# to have the same info as the "existing" version

non_breaking_changes[object.uuid] = current.uuid
if object.uuid != current.uuid:
# This happens if the developer performs "surgery"
# on an already instantiated object (uuid is not rebuilt)
non_breaking_changes[object.uuid] = current.uuid

current.handle_update_or_same(object)

Expand Down Expand Up @@ -335,6 +341,10 @@ def replace_existing(x):
logging.info(f'Found update {object.huuid}')

except FileNotFoundError:
# Also replace the existing components with references
serialized = serialized.map(
replace_existing, lambda x: isinstance(x, str) or isinstance(x, Query)
)
serialized['version'] = 0
serialized = object.dict().update(serialized)

Expand Down
Loading