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

🎨 Let Curator.validate() throw an error #2417

Merged
merged 5 commits into from
Feb 2, 2025
Merged

🎨 Let Curator.validate() throw an error #2417

merged 5 commits into from
Feb 2, 2025

Conversation

falexwolf
Copy link
Member

@falexwolf falexwolf commented Feb 2, 2025

Is part of a sequence of PRs that refactors the curators:


The new-style curators are now consistent with pydantic and pandera in that they raise informative errors upon .validate() rather than returning False.

Say, there is a typo in the "T cell" label:

with pytest.raises(ln.errors.ValidationError) as err:
    curator.validate()
message = """1 term is not validated: 'T_cell'
    → fix typos, remove non-existent values, or save terms via .add_new_from("cell_type_by_expert")"""
assert err.exconly() == f"lamindb.errors.ValidationError: {message}"

Or a column is missing from a DataFrame (via pandera under-the-hood):

with pytest.raises(ln.errors.ValidationError) as err:
    curator.validate()
message = "column 'cell_type_by_model' not in dataframe. Columns in dataframe: ['date', 'cell_type_by_expert']"
assert err.exconly() == f"lamindb.errors.ValidationError: {message}"

The old-style family of CatCurator classes keeps returning a boolean upon .validate() for backward compatibility.

Also: lamindb.core.exceptions got moved to lamindb.errors.

See internal Slack thread.

@falexwolf falexwolf changed the title Erroronvalidate 🎨 Let Curator.validate() error and return None instead of False upon failure Feb 2, 2025
@falexwolf falexwolf changed the title 🎨 Let Curator.validate() error and return None instead of False upon failure 🎨 Let Curator.validate() throw an error, CatCurator.validate() continues to return a boolean Feb 2, 2025
@falexwolf falexwolf changed the title 🎨 Let Curator.validate() throw an error, CatCurator.validate() continues to return a boolean 🎨 Let Curator.validate() throw an error Feb 2, 2025
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.54%. Comparing base (d503387) to head (4625552).
Report is 36 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2417      +/-   ##
==========================================
- Coverage   91.71%   91.54%   -0.18%     
==========================================
  Files          62       63       +1     
  Lines        9138     9569     +431     
==========================================
+ Hits         8381     8760     +379     
- Misses        757      809      +52     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Feb 2, 2025

@falexwolf falexwolf merged commit 12c7cb9 into main Feb 2, 2025
16 of 17 checks passed
@falexwolf falexwolf deleted the erroronvalidate branch February 2, 2025 13:54
@github-actions github-actions bot temporarily deployed to pull request February 2, 2025 13:57 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant