Belle II Software development
SubjobSplitter Class Reference
Inheritance diagram for SubjobSplitter:
ArgumentsSplitter MaxFilesSplitter MaxSubjobsSplitter

Public Member Functions

 __init__ (self, *, arguments_generator=None)
 
 create_subjobs (self, job)
 
 assign_arguments (self, job)
 
 __repr__ (self)
 

Public Attributes

 arguments_generator = arguments_generator
 The ArgumentsGenerator used when creating subjobs.
 

Detailed Description

Abstract base class. This class handles the logic of creating subjobs for a `Job` object.
The `create_subjobs` function should be implemented and used to construct
the subjobs of the parent job object.

Parameters:
    arguments_generator (ArgumentsGenerator): Used to construct the generator function that will yield the argument
        tuple for each `SubJob`. The splitter will iterate through the generator each time `create_subjobs` is
        called. The `SubJob` will be sent into the generator with ``send(subjob)`` so that the generator can decide what
        arguments to return.

Definition at line 153 of file backends.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
* ,
arguments_generator = None )
Derived classes should call `super` to run this.

Definition at line 166 of file backends.py.

166 def __init__(self, *, arguments_generator=None):
167 """
168 Derived classes should call `super` to run this.
169 """
170
171 self.arguments_generator = arguments_generator
172

Member Function Documentation

◆ __repr__()

__repr__ ( self)
 

Definition at line 205 of file backends.py.

205 def __repr__(self):
206 """
207 """
208 return f"{self.__class__.__name__}"
209
210

◆ assign_arguments()

assign_arguments ( self,
job )
Use the `arguments_generator` (if one exists) to assign the argument tuples to the
subjobs.

Definition at line 179 of file backends.py.

179 def assign_arguments(self, job):
180 """
181 Use the `arguments_generator` (if one exists) to assign the argument tuples to the
182 subjobs.
183 """
184 if self.arguments_generator:
185 arg_gen = self.arguments_generator.generator
186 generating = True
187 for subjob in sorted(job.subjobs.values(), key=lambda sj: sj.id):
188 if generating:
189 try:
190 args = arg_gen.send(subjob)
191 except StopIteration:
192 B2ERROR(f"StopIteration called when getting args for {subjob}, "
193 "setting all subsequent subjobs to have empty argument tuples.")
194 args = tuple() # If our generator finishes before the subjobs we use empty argument tuples
195 generating = False
196 else:
197 args = tuple()
198 B2DEBUG(29, f"Arguments for {subjob}: {args}")
199 subjob.args = args
200 return
201
202 B2INFO(f"No ArgumentsGenerator assigned to the {self} so subjobs of {job} "
203 "won't automatically have arguments assigned.")
204

◆ create_subjobs()

create_subjobs ( self,
job )
Implement this method in derived classes to generate the `SubJob` objects.

Reimplemented in ArgumentsSplitter, MaxFilesSplitter, and MaxSubjobsSplitter.

Definition at line 174 of file backends.py.

174 def create_subjobs(self, job):
175 """
176 Implement this method in derived classes to generate the `SubJob` objects.
177 """
178

Member Data Documentation

◆ arguments_generator

arguments_generator = arguments_generator

The ArgumentsGenerator used when creating subjobs.

Definition at line 171 of file backends.py.


The documentation for this class was generated from the following file: