@@ -199,7 +199,9 @@ def num_selected_entries(self) -> int | None:
199199 total += v .num_selected_entries
200200 return total
201201
202- def limit_steps (self , max_steps : int | slice | None , per_file : bool = False ) -> Self :
202+ def limit_steps (
203+ self , max_steps : int | slice | None , per_file : bool = False
204+ ) -> Self :
203205 """Limit the steps. pass per_file=True to limit steps per file, otherwise limits across all files cumulatively"""
204206
205207 if max_steps is None :
@@ -208,7 +210,10 @@ def limit_steps(self, max_steps: int | slice | None, per_file: bool = False) ->
208210 return type (self )({k : v .limit_steps (max_steps ) for k , v in self .items ()})
209211 else :
210212 from coffea .dataset_tools .manipulations import _concatenated_step_slice
211- steps_by_file = _concatenated_step_slice ({k : v .steps for k , v in self .items ()}, max_steps )
213+
214+ steps_by_file = _concatenated_step_slice (
215+ {k : v .steps for k , v in self .items ()}, max_steps
216+ )
212217 new_dict = {}
213218 for k , v in self .items ():
214219 if len (steps_by_file [k ]) > 0 :
@@ -398,6 +403,12 @@ def _check_form(self) -> bool | None:
398403 else :
399404 return None
400405
406+ def _valid_format (self ) -> bool :
407+ _formats = {"root" , "parquet" }
408+ return self .format in _formats or all (
409+ fmt in _formats for fmt in self .format .split ("|" )
410+ )
411+
401412 def set_check_format (self ) -> bool :
402413 """Set and/or alidate the format if manually specified"""
403414 if self .format is None :
@@ -411,9 +422,7 @@ def set_check_format(self) -> bool:
411422 self .format = "|" .join (union )
412423
413424 # validate the format, if present
414- if not ModelFactory .valid_format (self .format ):
415- return False
416- return True
425+ return self ._valid_format ()
417426
418427 @model_validator (mode = "after" )
419428 def post_validate (self ) -> Self :
@@ -523,17 +532,17 @@ def steps(self) -> dict[str, list[StepPair]] | None:
523532 """Get the steps per dataset file, if available."""
524533 return {k : v .steps for k , v in self .items ()}
525534
526- def limit_steps (
527- self , max_steps : int | slice , per_file : bool = False
528- ) -> Self :
535+ def limit_steps (self , max_steps : int | slice , per_file : bool = False ) -> Self :
529536 """Limit the steps"""
530537 spec = copy .deepcopy (self )
531538 # handle both per_file True and False by passthrough
532539 for k , v in spec .items ():
533540 spec [k ] = v .limit_steps (max_steps , per_file = per_file )
534541 return type (self )(spec )
535542
536- def limit_files (self , max_files : int | slice | None , per_dataset : bool = True ) -> Self :
543+ def limit_files (
544+ self , max_files : int | slice | None , per_dataset : bool = True
545+ ) -> Self :
537546 """Limit the number of files."""
538547 spec = copy .deepcopy (self )
539548 if per_dataset :
@@ -595,21 +604,9 @@ def identify_file_format(name_or_directory: str) -> str:
595604
596605
597606class ModelFactory :
598- _formats = {"root" , "parquet" }
599-
600607 def __init__ (self ):
601608 pass
602609
603- @classmethod
604- def valid_format (cls , format : str | DatasetSpec ) -> bool :
605- if isinstance (format , DatasetSpec ):
606- test_format = format .format
607- else :
608- test_format = format
609- return test_format in cls ._formats or all (
610- fmt in cls ._formats for fmt in test_format .split ("|" )
611- )
612-
613610 @classmethod
614611 def attempt_promotion (
615612 cls ,
@@ -694,7 +691,7 @@ def dict_to_datasetspec(cls, input: dict[str, Any], verbose=False) -> DatasetSpe
694691 def datasetspec_to_dict (
695692 cls ,
696693 input : DatasetSpec ,
697- coerce_filespec_to_dict = True ,
694+ coerce_filespec_to_dict : bool = True ,
698695 ) -> dict [str , Any ]:
699696 assert isinstance (
700697 input , DatasetSpec
0 commit comments