-
Notifications
You must be signed in to change notification settings - Fork 18
✨ Add .artifacts_load(), .artifacts_open(), .artifacts_mapped() to QuerySet
#2546
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
Conversation
|
Why not just |
Sure.
Hm, i wanted to emphasize that it works only for query sets of artifacts. You don't like it? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2546 +/- ##
==========================================
- Coverage 92.42% 92.06% -0.36%
==========================================
Files 60 58 -2
Lines 9989 8638 -1351
==========================================
- Hits 9232 7953 -1279
+ Misses 757 685 -72 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Also a thing to discuss. Now i raise an error if the model of a query set is not |
b2173b7 to
41e056b
Compare
QuerySet.artifacts_open() and QuerySet.artifacts_mapped().artifacts_load(), .artifacts_open(), .artifacts_mapped() to QuerySet
0a98baa to
6ceaf0c
Compare
6ceaf0c to
06b53cf
Compare
|
Deployment URL: https://dbb6b8d1.lamindb.pages.dev |
I think the error is good! Querying the related would be too implicit in this case. |
falexwolf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a class ArtifactQuerySet if we want to do this.
We cannot bloat the generic QuerySet API with methods that won't make sense for almost all query sets, can we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think backed = ln.Artifact.filter(suffix=".parquet").open() would be a lot prettier here 😊
| # Why is that? - Sergei | ||
| if len(suffixes) != 1: | ||
| raise ValueError( | ||
| "Can only load collections where all artifacts have the same suffix" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error needs to also adapt to different functions, right? Now it's not only loading collections, can also be Queryset
| Returns an in-memory concatenated `DataFrame` or `AnnData` object. | ||
| See also {meth}`~lamindb.models.Collecton.load`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the ref link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add Example:: to the docstring?
|
|
||
|
|
||
| def _load_concat_artifacts( | ||
| artifacts: list[Artifact], join: Literal["inner", "outer"] = "outer", **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**kwargs → **concat_kwargs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please no **kwargs at all!
|
Quite generally the name choice If we have |
|
Also: we have to find a way of getting rid of monkey-patching Django's QuerySet. I can't think of a simple solution so far but it's pretty annoying that we have this in our codebase (same for QueryManager). |
Yes, but it is much harder to implement as we have to account for cases where |
I know it's much harder. But we have to invest the effort now. No more new hacks. They'll all just bite us. We gotta keep focusin on removing the hacks of the early days to improve quality and performance.
That'd be great! |
|
To do this properly, i need something like this #2637 first. |
|
Makes total sense! |
|
Continued here #2743 |
Adds
QuerySet.artifacts_load(),QuerySet.artifacts_open(),QuerySet.artifacts_mapped()that do the same asCollection.load(),Collection.open(),Collection.mapped()for query sets of artifacts. This allows to avoid creating collections if only some loading or opening is needed.Use: