This module defines the ADMIT task (AT) base class.
Base class for Admit Task (AT) objects.
The ADMIT task base class implements generic interface features common to concrete ATs. Tasks are the basic execution unit in ADMIT and are responsible for operating on BDPs to perform calculations or otherwise transform them into new data products. Each task includes a unique set of keywords controlling its behavior.
Parameters: | keys : dictionary of str keywords with default values, optional.
keyvals : dictionary of new values for the keywords, optional.
|
---|
Notes
As a general rule the attributes of an AT should not be directly manipulated by the code in an AT, all are taken care of internally or accessed via methods (e.g. setkey)
Attributes
_taskid | (int) Static task ID counter (increments as new tasks are instantiated). Instances also have a unique _taskid containing their particular ID number. |
_bdp_in | (list of BDPs) BDP input cache. |
_bdp_in_map | (list of ints) Listing of BDP uid’s correspinding to those listed in _bdp_in |
_bdp_out | (list of BDPs) BDP output cache. |
_bdp_out_map | (list of ints) Listing of BDP uid’s correspinding to those listed in _bdp_out |
_keys | (dict) Task keyword dictionary. |
_type | (str) Concrete task type. |
_stale | (boolean) Whether the AT needs to be run (i.e. keyword changed) ??? what if the output BDP doesn’t exist ??? |
_enabled | (boolean) Whether the AT is enabled, if set to False the flow manager will not execute the local run method. |
_do_plot | (boolean) Should plotting be done |
_plot_mode | (int) TBD |
_valid_bdp_in | (List) List of Tuples indicating what types and how many BDPs are expected as input |
_valid_bdp_out | (List) List of Tuples indicating what types and how many BDPs are expected as output |
_needToSave | (boolean) Whether this AT and underlying BDP’s need to be saved to disk |
Methods
addinput(item[, slot]) | Add a BDP input to an AT. |
addinputbdp(item[, slot, insert]) | Add a BDP to the _bdp_in list |
addoutput(item[, slot]) | Add a BDP output product to an AT. |
addoutputbdp(item[, slot, insert]) | Add a BDP to the _bdp_out list |
check() | |
checkfiles() | check if the files from all the BDP_out’s in an AT exist, |
checktype(item) | Check the type of an object to see if ti is a BDP |
clearinput() | Clear the input BDP list |
clearoutput() | Clear the output BDP list |
copy() | Creates an independent duplicate of the task. |
delete([delfiles]) | Method to delete the AT and underlying BDPs. |
delinput(slot) | Delete a specific BDP in the _bdp_in list |
deloutput(slot) | Delete a specific BDP in the _bdp_out list |
dir([filename]) | Return the absolution directory of this ADMIT project or a derefenced filename address. |
execute([args]) | Executes the task. |
getVersion() | Return the version string |
getdtd(fl) | Method to write out the dtd data |
getkey(key) | Retrieval value for a key. |
haskey(key) | Query if a key exists for an AT. |
isequal(at) | Method to determine if two ATs are the same. |
isstale() | Return True/False if an AT is up to date |
len2() | Return the length of _bdp_in and _bdp_out in a tuple |
markChanged() | Mark an AT that it’s state was changed, so it would need to be rerun. |
markUpToDate() | Sets the _stale state to indicate that the AT does not need to be run |
mkdir(dirname) | Make a directory in the ADMIT hierarchy if it doesn’t exist yet It also allows an absolute path, in the classical unix sense. |
run() | Runs the task. |
save() | |
set_bdp_in([bin]) | Validate the _valid_bdp_in list and digest it into the appropriate attributes |
set_bdp_out([bout]) | Validate the _valid_bdp_out list and digest it into the appropriate attributes |
setkey([name, value, isinit]) | set keys, two styles are possible: |
show() | Return the type of the AT |
summary() | place holder empty summary in case the derived class doesn’t implement it |
uptodate() | Returns the current state of the _stale flag |
validateinput([describe]) | Method to validate the _bdp_in’s against a dictionary of expected types. |
write(node) | Method to write the AT to disk |
Add a BDP input to an AT. The BDP type will be validated before it is added to the input list.
Parameters: | item : BDP
|
---|---|
Returns: | None |
Add a BDP to the _bdp_in list This method should not be called directly, use addinput instead
Parameters: | item : BDP
|
---|---|
Returns: | None |
Add a BDP output product to an AT. The BDP type will be validated before it is added to the output list.
Parameters: | item : BDP
|
---|---|
Returns: | None |
Add a BDP to the _bdp_out list This method should not be called directly, use addoutput instead
Parameters: | item : BDP
|
---|---|
Returns: | None |
check if the files from all the BDP_out’s in an AT exist, and return the list of files not found @todo this needs a catch-22 fix on re-running admit
Check the type of an object to see if ti is a BDP
Parameters: | item : Any
|
---|---|
Returns: | Boolean
|
Clear the input BDP list
Clear the output BDP list
Creates an independent duplicate of the task.
WARNING: The current implementation performs a deepcopy() and updates a few members; proper behavior with respect to input/output BDPs, filenames, keywords, etc., are still TBD.
Returns: Reference to the new (cloned) task.
Method to delete the AT and underlying BDPs.
Parameters: | delfiles : Boolean
It is recommended that any AT that stores images inside of lists, dictionaries, tuples, etc. override this method with a customized version. |
---|
Delete a specific BDP in the _bdp_in list
Parameters: | slot : int
|
---|
Delete a specific BDP in the _bdp_out list
Parameters: | slot : int
|
---|
Return the absolution directory of this ADMIT project or a derefenced filename address. This includes the potentially operating system dependant directory separator. This way filenames can be constructed as follows: Admit.dir() + ‘foobar.dat’ or Admit.dir(‘foobar.dat’)
Parameters: | filename : filename (optional) Optional filename |
---|---|
Returns: | string
|
Executes the task.
Parameters: | args: list of BDPs, optional
|
---|---|
Returns: | None |
See also
Notes
If args is not given, the previously cached BDP inputs are reused; hence execution (input validation) will fail if required arguments are absent.
Return the version string
Returns: | String
|
---|
Method to write out the dtd data
Parameters: | fl : file handle
|
---|---|
Returns: | None |
Retrieval value for a key. If the key had not been set yet, a default value can be returned, else None is returned. Notice no type checking has been done here, the caller is responsible for this.
See also haskey()
Parameters: | key : string
|
---|---|
Returns: | The value of the key |
Query if a key exists for an AT. Returns True/False
Parameters: | key : string
|
---|---|
Returns: | Boolean
|
Method to determine if two ATs are the same. Useful for testing.
Parameters: | at : AT
|
---|---|
Returns: | Boolean
|
Return True/False if an AT is up to date
Returns: | boolean
|
---|
Return the length of _bdp_in and _bdp_out in a tuple If you just want the _bdp_out, the intrinsic len(my_at) Thus my_at.len2()[1] is the same as len(my_at)
Returns: | Tuple
|
---|
Mark an AT that it’s state was changed, so it would need to be rerun. The FlowManager will take care of any dependants that will need to be marked as well. Use “markUpToDate” if you want the opposite function.
Sets the _stale state to indicate that the AT does not need to be run
Make a directory in the ADMIT hierarchy if it doesn’t exist yet It also allows an absolute path, in the classical unix sense. @todo this routine is identical to the one in Admit()
Runs the task.
Running a task transforms its input BDPs into output BDPs according to its function. Following this call the output BDPs accurately reflect the current state of the task (keywords and BDP inputs). Each concrete AT must implement its own run() method.
Returns: | None |
---|
See also
Validate the _valid_bdp_in list and digest it into the appropriate attributes
Parameters: | bin : List
|
---|
Validate the _valid_bdp_out list and digest it into the appropriate attributes
Parameters: | bout : List
|
---|
set keys, two styles are possible:
This method checks the type of the keyword value, as it must remain the same. Also new keywords cannot be added.
Parameters: | name : dictionary or string
value : any
|
---|---|
Returns: | None |
Return the type of the AT
Returns: | string
|
---|
place holder empty summary in case the derived class doesn’t implement it
Returns the current state of the _stale flag
Returns: | boolean
|
---|
Method to validate the _bdp_in’s against a dictionary of expected types. Returns False if anything is amiss. If describe == True then the return is a tuple containing True/False and a list of what was found/not found.
Method to write the AT to disk
Parameters: | node : elemettree node
|
---|---|
Returns: | node : elemettree node
dtd : Text string of the dtd |