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 parents update #107

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
11 changes: 6 additions & 5 deletions bionty/core/_add_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ def check_source_in_db(
if not hasattr(registry, "source_id"):
logger.warning(f"no `source` field in the registry {registry.__name__}!")
else:
if n_all is None:
n_all = registry.public(source=source).df().shape[0]
if n_in_db is None:
# all records of the source in the database
n_in_db = registry.filter(source=source).count()
n_all = n_all or registry.public(source=source).df().shape[0]
# all records of the source in the database
n_in_db = n_in_db or registry.filter(source=source).count()
if n_in_db >= n_all:
# make sure in_db is set to True if all records are in the database
source.in_db = True
Expand Down Expand Up @@ -184,6 +182,9 @@ def add_ontology_from_df(
records = create_records(registry, df_new, source_record)
registry.objects.bulk_create(records, ignore_conflicts=ignore_conflicts)

all_records = registry.filter(
source=source_record
).all() # need to update all_records after bulk_create
link_records = create_link_records(registry, df_all, all_records)
ln.save(link_records, ignore_conflicts=ignore_conflicts)

Expand Down
Loading