Previous topic

pycrtools.tasks.calibratefm

Next topic

pycrtools.tasks.crimager

This Page

pycrtools.tasks.commands

go_class Simple command to let the user start the current task by simply typing ‘go’.
t_class Dummy base class which redefined the __repr__ object such that the user can call a function by simply typing the name of an instance without brackets.
task(*args, **kwargs) Usage:
tdel(*args) Deletes the parameters in the workspace of a task.
tget_class Usage:
thelp_class Usage:
tinit_class Class to let the user run the initialization part of a task.
tlist_class Class to let the user list the available tasks that can be loaded with tload.
tload(name[, get, quiet]) Loads a specific task as the current task, you you can start it with ‘go’ and set parameters with ‘par x=value’.
tlog_class Class to let the user list the log of recently run tasks, including execution times.
tnorerun(name, version, *args, **kwargs) Usage:
tpar_class Sets the parameters in the workspace of a task.
tpars_class Usage:
tput_class Usage:
trerun(name, version, *args, **kwargs) Usage:
treset_class Usage:
trun(name, *args, **kwargs) Usage:

Comands to work with tasks

An example to use tasks is give in tasks/averagespectrum.py

to try it start ipython and type

Task # the currently loaded task instance Task.par (=value) # access or set a parameter (without updating) Task(par1,par2,...) # run the task with parameters par1,par2,.... trun “taskname”, pars # run the task with name “taskname” and assign it to the global variable Task` trerun “taskname”, pars # like trun, but store task and do not reload it during a 2nd call, but rerun. tlist # to view the available tasks tlog # list the log of recently run tasks, including execution times. tload 2 # to load the task #2 (can also provide a name) tload “taskname” # i.e., this is safer in code since the task number can change with time tpars # to list all parameters tpar nchunks=2 # to set a parameter go # to run the task tpar parfile=”averagespectrum_2011-02-15_23:52:15.par” # to read back a parameter file treset # to reset parameters to default values tget (name) # to read back the parameters from the latest run - will also be done at tload - or get the one stored under ‘name’ tput (name) # store input parameters in database (under ‘name’) tinit # run the initialization routine again (without resetting the parameters to default values) thelp # print documentation of task module

class pycrtools.tasks.commands.go_class

Simple command to let the user start the current task by simply typing ‘go’.

task - You can also provide a task as argument which will then be run, by stating saying ‘go task=tasks.task_instance’.

Positional and keyword parameters can be provided as parameters, e.g,

go data,par1=123

Before starting the task, go will store the current parameters with “tput”.

class pycrtools.tasks.commands.t_class

Dummy base class which redefined the __repr__ object such that the user can call a function by simply typing the name of an instance without brackets.

pycrtools.tasks.commands.task(*args, **kwargs)

Usage:

task() -> return current loaded task

or

task("taskname",par,par1=X,par2=Y,...) - > return task named taskname

Description:

With no parameters return the currently loaded task. Otherwise return the task with the name given as first argument and the other parameters as arguments.

See also:

tload

pycrtools.tasks.commands.tdel(*args)

Deletes the parameters in the workspace of a task.

Example:

In ipython you can say something like

par x=2

to set parameter x of the current task. If that was initially an ouput parameter, it now becomes and input parameter. This can be reverted by typing

tdel “x”

class pycrtools.tasks.commands.tget_class

Usage:

tget -> Class to let the user retrieve the input parameters from the system data base on disk. See also ‘tput’

tget name -> Retrieve the parameters stored under the respective name

tget 0 (or any unknown name) -> show a list of all available parameter sets

class pycrtools.tasks.commands.thelp_class

Usage:

thelp what

Description:

Print documentation of tasks

Parameters:

what - 0 = help on current task, 1 = help on tasks
‘taskname’ - help on named task
class pycrtools.tasks.commands.tinit_class

Class to let the user run the initialization part of a task. This will result in a forced initialization, irrespective of whether this has been run before, unless force=False.

class pycrtools.tasks.commands.tlist_class

Class to let the user list the available tasks that can be loaded with tload.

pycrtools.tasks.commands.tload(name, get=True, quiet=False, **args)

Loads a specific task as the current task, you you can start it with ‘go’ and set parameters with ‘par x=value’.

One can also provide a number, which refers to the number associated with the task when typing ‘tlist’.

The loaded task will be saved and reloaded the next time the program is started.

class pycrtools.tasks.commands.tlog_class

Class to let the user list the log of recently run tasks, including execution times.

Parameter:

n = 20 - Display the last 20 entries. n=-1 means display all doprint = True - print the result otherwise return the string to be printed loglist = None - If provided use this list of log entries

x=[{‘execution_time’: 0.22922900000000002,

‘name’: ‘AverageSpectrum’, ‘start_time’: ‘2011-08-04 14:24:19’, ‘start_time_cpu’: 0.71958299999999997, ‘version’: ‘cr_event’},

{‘execution_time’: 4.6105419999999997,
‘name’: ‘FitBaseline’, ‘start_time’: ‘2011-08-04 14:24:19’, ‘start_time_cpu’: 0.97520499999999999, ‘version’: ‘’}]
pycrtools.tasks.commands.tnorerun(name, version, *args, **kwargs)

Usage:

tnorerun(taskname,version,parameters,keyword1=....)

Like trerun, just don’t reload the task - for testing purposes only ...

Run the taks with the given task name and with the parameters provided as argument list.

name - task name to load (see tlist()) version - assign the task a unique version ID, so that you can store

and rerun different instances of the same task

The task itself will be available via the global variable Task afterwards.

All stored tasks can be found in the dict tasks.task_instances.

class pycrtools.tasks.commands.tpar_class

Sets the parameters in the workspace of a task.

Example:

In ipython you can say something like

par x=2

to set parameter x of the current task.

If no parameters are provided, just print the input parameters.

class pycrtools.tasks.commands.tpars_class

Usage:

tpars -> list parameter workspace

Class to let the user view the current parameter set by simply typing ‘tpars’. Use ‘tpars 0’ or ‘tpars False’ to just see input parameters (this only works in ipython, python requires brackets).

*noninputparameters*=True - If False, don’t list the derived paramters.

*workarrays*=False - If True also list the work arrays.

class pycrtools.tasks.commands.tput_class

Usage:

tput -> Class to let the user store the input parameters to the system data base on disk. See also ‘tget’

tput name -> Store parameters stored under ‘name’ (retrieve with tget name)

delete - If True, delete the parameter set from data base.

pycrtools.tasks.commands.trerun(name, version, *args, **kwargs)

Usage:

trerun(taskname,version,parameters,keyword1=....)

Run the taks with the given task name and with the parameters provided as argument list.

name - task name to load (see tlist()) version - assign the task a unique version ID, so that you can store

and rerun different instances of the same task

The task itself will be available via the global variable Task afterwards.

All stored tasks can be found in the dict tasks.task_instances.

class pycrtools.tasks.commands.treset_class

Usage:

treset -> Reset all parameters to orginal values.

treset(par1=val1,par2=val2,...) -> reset all parameters to default and initialze with parameters provided.

treset(restorecallparameters=True,par1=val1,par2=val2,...) -> reset all parameters to their state at initialization, but keep the parameters provided during the last initialisation.

pycrtools.tasks.commands.trun(name, *args, **kwargs)

Usage:

trun(taskname,parameter,keyword1=....)

Run the taks with the given tasknname and with the parameters provided as argument list.

The task itself will be available via the global variable Task afterwards.