libeblearntools
ebl::job Class Reference

Jobs to be executed. More...

#include <job.h>

Inheritance diagram for ebl::job:
ebl::mpijob

List of all members.

Public Member Functions

 job (configuration &conf, const char *oconffname=NULL, bool resume=false)
virtual ~job ()
 Destructor.
virtual void run ()
 Execute job (fork and call run_child()).
virtual bool started ()
 Returns true if the job has been started, false otherwise.
virtual bool write (bool reset_progress=false)
virtual bool alive ()
virtual bool running ()
virtual int getpid ()
 Return pid of this job.
virtual string & name ()
 Return the name of this job (its configuration filename).
virtual string shortname ()
 Return the short name of this job.
virtual string get_root ()
 Return root directory of this job.
virtual double minutes ()
 Return job's running time in minutes.
virtual void force_started ()
 Force the start flag to be on. This is be useful to mpi job manager.
virtual void reset_started ()
 Force the start flag to be off. This is be useful to mpi job manager.
virtual string elapsed ()
 Return elapsed running time string.
virtual bool resumed ()
 Returns true if this job is being resumed from before.
virtual bool finished ()
 Returns true if this job is finished, false otherwise.
virtual int progress () const
virtual bool declare_started ()
virtual bool declare_finished ()
virtual bool check_started ()
 Returns true if a file named 'progress' exists in the job's directory.
virtual bool check_running ()
virtual int check_progress ()
virtual bool check_finished ()
 Returns true if a file named 'finished' exists in the job's directory.
virtual void figure_resume_from_weights (const char *dir=NULL)

Static Public Member Functions

static void write_progress (uint i, uint total, const char *additional=NULL, const char *root=NULL)
static string get_progress_filename (const char *root=NULL)
 Returns the filename where progress info is written by write_progress().
static void write_finished (const char *root=NULL)

Protected Member Functions

virtual void run_child ()
 Execute child's code.
virtual void figure_resume_out ()

Protected Attributes

configuration conf
 Job's configuration.
configuration rconf
 Resolved job's configuration.
string exe
 executable full path
string outdir
 job's output directory
string confname
 job's configuration filename
string oconffname_
 job's original conf filename
timer t
bool _locally_started
 This job is/was started.
bool _started
 This job is/was started.
bool _running
 This job is running right now.
bool _alive
 This job is run by us right now.
int pid
 pid of this job
bool resumed_
 This job is being resumed or not.
bool _finished
 This is is finished or not.
int _progress
 Progress percentage.
string progress_fname
 Filename of progress file.
string finished_fname
 Filename of finished file.

Detailed Description

Jobs to be executed.


Constructor & Destructor Documentation

ebl::job::job ( configuration conf,
const char *  oconffname = NULL,
bool  resume = false 
)

Create a job given a configuration conf.

Parameters:
confThe job's configuration.
oconffnameThe original configuration's filename.
resumeIf true, find latest saved parameters and start from them.

Member Function Documentation

bool ebl::job::alive ( ) [virtual]

Return true if the job is alive and running. This differs from running() in that it indicates if the job is being run by us.

int ebl::job::check_progress ( ) [virtual]

Returns the percentage progress of the job by looking at the 'progress' file in the job's directory. If progress does not exist, returns -1. If progress exists and empty, returns 0. If 'retrain_iteration' and 'iterations' are defined, return retrain_iteration / iterations * 100 as percentage.

bool ebl::job::check_running ( ) [virtual]

Returns true if job's progress file was modified less than an hour ago. This also updates the value returned by running() method. This information is different than alive(), in the sense that this job could be run by somebody else or ourselves.

bool ebl::job::declare_finished ( ) [virtual]

Create an empty file named 'finished' in the job's directory, to show that this job was finished. Returns false if writing the file failed.

bool ebl::job::declare_started ( ) [virtual]

Create an empty file named 'progress' in the job's directory, to show that this job is being processed. Returns false if writing the file failed.

void ebl::job::figure_resume_from_weights ( const char *  dir = NULL) [virtual]

Figure out resume parameters from existing weights files.

Parameters:
dirIf null, use job's output directory.
void ebl::job::figure_resume_out ( ) [protected, virtual]

Figure out resume parameters from 'progress' file. If no info found in progress file, this tries figure_resume_from_weights().

int ebl::job::progress ( ) const [virtual]

Returns the progress percentage or -1 if not started. This value is updated after a check_progress() call only.

bool ebl::job::running ( ) [virtual]

Return true if the job is running. This differs from alive() in that it indicates if the job is being run by anybody else or us.

bool ebl::job::write ( bool  reset_progress = false) [virtual]

Write job's files in configuration's output directory.

Parameters:
reset_progressIf true, ignore existing progress in target dir.
void ebl::job::write_finished ( const char *  root = NULL) [static]

Write the file 'finished' in current directory or in root directory if specified. If 'progress' file already exists, move it to 'finished' (to avoid having too many files, otherwise, just touch file 'finished'.

void ebl::job::write_progress ( uint  i,
uint  total,
const char *  additional = NULL,
const char *  root = NULL 
) [static]

Write the file 'progress' in current directory or in root directory if specified, and write 'i' and 'total' variables to describre progress.

Parameters:
additionalAdditional string the user may want to put in progress such as resuming information.

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