Belle II Software development
Result Class Reference
Inheritance diagram for Result:
HTCondor.HTCondorResult LSF.LSFResult Local.LocalResult PBS.PBSResult

Public Member Functions

 __init__ (self, job)
 
 ready (self)
 
 update_status (self)
 
 get_exit_code_from_file (self)
 

Public Attributes

 job = job
 Job object for result.
 
 time_to_wait_for_exit_code_file = timedelta(minutes=5)
 After our first attempt to view the exit code file once the job is 'finished', how long should we wait for it to exist before timing out?
 
 exit_code_file_initial_time = None
 Time we started waiting for the exit code file to appear.
 

Protected Attributes

bool _is_ready = False
 Quicker way to know if it's ready once it has already been found.
 

Detailed Description

Base class for Result objects. A Result is created for each `Job` (or `Job.SubJob`) object
submitted to a backend. It provides a way to query a job's status to find out if it's ready.

Definition at line 868 of file backends.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
job )
Pass in the job object to allow the result to access the job's properties and do post-processing.

Definition at line 874 of file backends.py.

874 def __init__(self, job):
875 """
876 Pass in the job object to allow the result to access the job's properties and do post-processing.
877 """
878
879 self.job = job
880
881 self._is_ready = False
882
884 self.time_to_wait_for_exit_code_file = timedelta(minutes=5)
885
886 self.exit_code_file_initial_time = None
887

Member Function Documentation

◆ get_exit_code_from_file()

get_exit_code_from_file ( self)
Read the exit code file to discover the exit status of the job command. Useful fallback if the job is no longer
known to the job database (batch system purged it for example). Since some backends may take time to download
the output files of the job back to the working directory we use a time limit on how long to wait.

Definition at line 909 of file backends.py.

909 def get_exit_code_from_file(self):
910 """
911 Read the exit code file to discover the exit status of the job command. Useful fallback if the job is no longer
912 known to the job database (batch system purged it for example). Since some backends may take time to download
913 the output files of the job back to the working directory we use a time limit on how long to wait.
914 """
915 if not self.exit_code_file_initial_time:
916 self.exit_code_file_initial_time = datetime.now()
917 exit_code_path = Path(self.job.working_dir, Backend.exit_code_file)
918 with open(exit_code_path) as f:
919 exit_code = int(f.read().strip())
920 B2DEBUG(29, f"Exit code from file for {self.job} was {exit_code}")
921 return exit_code
922
923

◆ ready()

ready ( self)
Returns whether or not this job result is known to be ready. Doesn't actually change the job status. Just changes
the 'readiness' based on the known job status.

Definition at line 888 of file backends.py.

888 def ready(self):
889 """
890 Returns whether or not this job result is known to be ready. Doesn't actually change the job status. Just changes
891 the 'readiness' based on the known job status.
892 """
893 B2DEBUG(29, f"Calling {self.job}.result.ready()")
894 if self._is_ready:
895 return True
896 elif self.job.status in self.job.exit_statuses:
897 self._is_ready = True
898 return True
899 else:
900 return False
901

◆ update_status()

update_status ( self)
Update the job's (and subjobs') status so that `Result.ready` will return the up to date status. This call will have to
actually look up the job's status from some database/exit code file.

Reimplemented in HTCondor.HTCondorResult, Local.LocalResult, LSF.LSFResult, and PBS.PBSResult.

Definition at line 902 of file backends.py.

902 def update_status(self):
903 """
904 Update the job's (and subjobs') status so that `Result.ready` will return the up to date status. This call will have to
905 actually look up the job's status from some database/exit code file.
906 """
907 raise NotImplementedError
908

Member Data Documentation

◆ _is_ready

bool _is_ready = False
protected

Quicker way to know if it's ready once it has already been found.

Saves a lot of calls to batch system commands.

Definition at line 881 of file backends.py.

◆ exit_code_file_initial_time

exit_code_file_initial_time = None

Time we started waiting for the exit code file to appear.

Definition at line 886 of file backends.py.

◆ job

job = job

Job object for result.

Definition at line 879 of file backends.py.

◆ time_to_wait_for_exit_code_file

time_to_wait_for_exit_code_file = timedelta(minutes=5)

After our first attempt to view the exit code file once the job is 'finished', how long should we wait for it to exist before timing out?

Definition at line 884 of file backends.py.


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