@@ -380,7 +380,13 @@ def _preprocess_sample(
380380
381381 @classmethod
382382 def validate (
383- cls , data : Mapping [str , FrameType ], / , * , cast : bool = False , eager : bool = True
383+ cls ,
384+ data : Mapping [str , FrameType ],
385+ / ,
386+ * ,
387+ cast : bool = False ,
388+ eager : bool = True ,
389+ ** kwargs : Any ,
384390 ) -> Self :
385391 """Validate that a set of data frames satisfy the collection's invariants.
386392
@@ -400,6 +406,8 @@ def validate(
400406 :meth:`~polars.LazyFrame.collect` on the individual member or
401407 :meth:`collect_all` on the collection. Note that, in the latter case,
402408 information from error messages is limited.
409+ kwargs: Keyword arguments passed directly to :meth:`polars.collect_all` and
410+ :meth:`polars.LazyFrame.collect` when `eager=True`.
403411
404412 Raises:
405413 ValueError: If an insufficient set of input data frames is provided, i.e. if
@@ -421,7 +429,7 @@ def validate(
421429 if eager :
422430 # If we perform the validation eagerly, we call filter and check the failure
423431 # information to properly construct a useful error message.
424- filtered , failures = cls .filter (data , cast = cast , eager = True )
432+ filtered , failures = cls .filter (data , cast = cast , eager = True , ** kwargs )
425433 if any (len (failure ) > 0 for failure in failures .values ()):
426434 errors : dict [str , str ] = {}
427435 for member , failure in failures .items ():
@@ -489,7 +497,9 @@ def validate(
489497 return cls ._init (members )
490498
491499 @classmethod
492- def is_valid (cls , data : Mapping [str , FrameType ], / , * , cast : bool = False ) -> bool :
500+ def is_valid (
501+ cls , data : Mapping [str , FrameType ], / , * , cast : bool = False , ** kwargs : Any
502+ ) -> bool :
493503 """Utility method to check whether :meth:`validate` raises an exception.
494504
495505 Args:
@@ -498,6 +508,8 @@ def is_valid(cls, data: Mapping[str, FrameType], /, *, cast: bool = False) -> bo
498508 the member as key.
499509 cast: Whether columns with a wrong data type in the member data frame are
500510 cast to their schemas' defined data types if possible.
511+ kwargs: Keyword arguments passed directly to :meth:`polars.collect_all` and
512+ :meth:`polars.LazyFrame.collect`.
501513
502514 Returns:
503515 Whether the provided members satisfy the invariants of the collection.
@@ -512,7 +524,7 @@ def is_valid(cls, data: Mapping[str, FrameType], /, *, cast: bool = False) -> bo
512524 members : dict [str , pl .LazyFrame ] = {}
513525 for member , schema in cls .member_schemas ().items ():
514526 if member in data :
515- if not schema .is_valid (data [member ], cast = cast ):
527+ if not schema .is_valid (data [member ], cast = cast , ** kwargs ):
516528 return False
517529 members [member ] = data [member ].lazy ()
518530
@@ -523,9 +535,12 @@ def is_valid(cls, data: Mapping[str, FrameType], /, *, cast: bool = False) -> bo
523535 keep = [filter .logic (result_cls ).select (primary_key ) for filter in filters ]
524536 joined = _join_all (* keep , on = primary_key , how = "inner" )
525537 removed_rows = pl .collect_all (
526- data [member ].lazy ().join (joined , on = primary_key , how = "anti" )
527- for member in cls .members ()
528- if member in data
538+ (
539+ data [member ].lazy ().join (joined , on = primary_key , how = "anti" )
540+ for member in cls .members ()
541+ if member in data
542+ ),
543+ ** kwargs ,
529544 )
530545 return all (df .is_empty () for df in removed_rows )
531546
@@ -535,7 +550,13 @@ def is_valid(cls, data: Mapping[str, FrameType], /, *, cast: bool = False) -> bo
535550
536551 @classmethod
537552 def filter (
538- cls , data : Mapping [str , FrameType ], / , * , cast : bool = False , eager : bool = True
553+ cls ,
554+ data : Mapping [str , FrameType ],
555+ / ,
556+ * ,
557+ cast : bool = False ,
558+ eager : bool = True ,
559+ ** kwargs : Any ,
539560 ) -> CollectionFilterResult [Self ]:
540561 """Filter the members data frame by their schemas and the collection's filters.
541562
@@ -551,6 +572,8 @@ def filter(
551572 eager: Whether the filter operation should be performed eagerly.
552573 Note that until https://github.com/pola-rs/polars/pull/24129 is
553574 released, eagerly filtering can provide significant speedups.
575+ kwargs: Keyword arguments passed directly to :meth:`polars.collect_all` and
576+ :meth:`polars.LazyFrame.collect` when `eager=True`.
554577
555578 Returns:
556579 A named tuple with fields `result` and `failure`. The `result` field
@@ -593,7 +616,7 @@ class HospitalInvoiceData(dy.Collection):
593616 continue
594617
595618 member_result , failures [member_name ] = member .schema .filter (
596- data [member_name ].lazy (), cast = cast , eager = eager
619+ data [member_name ].lazy (), cast = cast , eager = eager , ** kwargs
597620 )
598621 results [member_name ] = member_result .lazy ()
599622
@@ -609,7 +632,7 @@ class HospitalInvoiceData(dy.Collection):
609632 name : filter .logic (result_cls ).select (primary_key )
610633 for name , filter in filters .items ()
611634 }
612- keep = collect_all_if (keep , eager )
635+ keep = collect_all_if (keep , eager , ** kwargs )
613636
614637 drop : dict [str , pl .LazyFrame ] = {
615638 f"{ failure_propagating_member } |failure_propagation" : (
@@ -619,7 +642,7 @@ class HospitalInvoiceData(dy.Collection):
619642 )
620643 for failure_propagating_member in failure_propagating_members
621644 }
622- drop = collect_all_if (drop , eager )
645+ drop = collect_all_if (drop , eager , ** kwargs )
623646
624647 # Now we can iterate over the results and left-join onto each individual
625648 # filter to obtain independent boolean indicators of whether to keep the row.
@@ -647,7 +670,7 @@ class HospitalInvoiceData(dy.Collection):
647670
648671 lfs_with_eval [member_name ] = lf_with_eval
649672
650- lfs_with_eval = collect_all_if (lfs_with_eval , eager )
673+ lfs_with_eval = collect_all_if (lfs_with_eval , eager , ** kwargs )
651674 for member_name , lf_with_eval in lfs_with_eval .items ():
652675 member_info = cls .members ()[member_name ]
653676
@@ -714,7 +737,7 @@ class HospitalInvoiceData(dy.Collection):
714737
715738 result = CollectionFilterResult (cls ._init (results ), failures )
716739 if eager :
717- return result .collect_all ()
740+ return result .collect_all (** kwargs )
718741 return result
719742
720743 def join (
@@ -822,7 +845,7 @@ def collect_all(self, **kwargs: Any) -> Self:
822845 The same collection with all members collected once. Members annotated
823846 with :class:`~dataframely.DataFrame` are returned as DataFrames, while
824847 members annotated with :class:`~dataframely.LazyFrame` are returned as
825- "shallow-lazy" frames (obtained by calling `` .collect().lazy()` `).
848+ "shallow-lazy" frames (obtained by calling `.collect().lazy()`).
826849 """
827850 lazy_dict = self .to_dict ()
828851 dfs = pl .collect_all (lazy_dict .values (), ** kwargs )
0 commit comments