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

🎨 Improve saving validated output #2140

Merged
merged 3 commits into from
Nov 7, 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
12 changes: 7 additions & 5 deletions lamindb/_curate.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def _update_registry(self, categorical: str, validated_only: bool = True, **kwar
def _update_registry_all(self, validated_only: bool = True, **kwargs):
"""Save labels for all features."""
for name in self.fields.keys():
logger.info(f"saving validated records of '{name}'")
self._update_registry(name, validated_only=validated_only, **kwargs)

def validate(self, organism: str | None = None) -> bool:
Expand Down Expand Up @@ -513,10 +512,8 @@ def _save_from_var_index(

def _update_registry_all(self, validated_only: bool = True, **kwargs):
"""Save labels for all features."""
logger.info("saving validated records of 'var_index'")
self._save_from_var_index(validated_only=validated_only, **self._kwargs)
for name in self._obs_fields.keys():
logger.info(f"saving validated terms of '{name}'")
self._update_registry(name, validated_only=validated_only, **self._kwargs)

def add_new_from_var_index(self, organism: str | None = None, **kwargs):
Expand Down Expand Up @@ -1230,7 +1227,7 @@ def _log_mapping_info():
if n_non_validated == 0:
if n_validated == 0:
logger.indent = ""
logger.success(f"{key} is validated against {colors.italic(model_field)}")
logger.success(f"'{key}' is validated against {colors.italic(model_field)}")
return True, []
else:
# validated values still need to be saved to the current instance
Expand Down Expand Up @@ -1506,9 +1503,14 @@ def update_registry(

public_records = [r for r in existing_and_public_records if r._state.adding]
# here we check to only save the public records if they are from the specified source
# we check the uid because r.source and soruce can be from different instances
# we check the uid because r.source and source can be from different instances
if source:
public_records = [r for r in public_records if r.source.uid == source.uid]

if public_records:
Zethson marked this conversation as resolved.
Show resolved Hide resolved
settings.verbosity = "info"
logger.info(f"saving validated records of '{key}'")
settings.verbosity = "error"
ln_save(public_records)
labels_saved["from public"] = [
getattr(r, field.field.name) for r in public_records
Expand Down
Loading