avid.actions.rttb.voxelizer.VoxelizerAction

class avid.actions.rttb.voxelizer.VoxelizerAction(structSet, referenceImage, structName, actionTag='Voxelizer', allowIntersections=True, booleanMask=False, outputExt='nrrd', alwaysDo=False, session=None, additionalActionProps=None, actionConfig=None, propInheritanceDict=None, cli_connector=None)

Bases: GenericCLIAction

Class that wraps the single action for the tool rttb VoxelizerTool.

__init__(structSet, referenceImage, structName, actionTag='Voxelizer', allowIntersections=True, booleanMask=False, outputExt='nrrd', alwaysDo=False, session=None, additionalActionProps=None, actionConfig=None, propInheritanceDict=None, cli_connector=None)
Parameters:
  • tool_id – actionID that will be used to deduce the tool/executable for this action instance.

  • outputFlags – The argument/flag name (without “-” or “–”; the will be added automatically) of the output. If set to none, the action assumes that the output parameter are indexed by and directly added in the beginning as the last parameters without a flag. If you don’t want to use a flag, but control the position of the output parameter. Define a output flag (or keep the default ‘o’) and use the argPositions to control the position of all arguments.

  • argPositions – list that contains the keys of all arguments (from artefact_args and additional_args) that are not flag based but positional arguments. Those arguments will be added in the order of the list before the positional arguments.

  • indicateCallable – A callable that, if defined, will be called to query the outputs. The action assumes that the callable returns a list of output artefacts or None (if no indication can be made; like self.indicateOutputs). If this callable is not set, the default is one output that will be defined by the action and uses the first input artefact as reference. The signature of indicateCallable is: indicateCallable(actionInstance = Instance of the calling action, indicated_default_output = the artefact produced by the default indication strategy, **allArgs = all arguments passed to the action).

  • generateNameCallable – A callable that, if defined, will be called to specify the name(s) of output. If this callable is not set, the default name will be constructed as <actionID>_<actionTag>_ followed by all inputs. The signature of generateNameCallable is: generateNameCallable(actionInstance = Instance of the calling action, **allArgs = all arguments passed to the action). It is expected to return a string for the output name.

  • postProcessCLIExecutionCallable – A callable that, if defined, will be called to execute post-processing code after the CLI Execution. If this callable is not set, no post-processing will be done. The signature of postProcessCLIExecutionCallable is: postProcessCLIExecutionCallable(actionInstance = Instance of the calling action, **allArgs = all arguments passed to the action).

  • collectOutputsCallable – A callable that, if defined, will be called to collect/generate artefact instances for all generated outputs after the CLI execution is post processed. For more details, See the documentation of SingleActionBase._collectOutputs. If this callable is not set, nothing will be collected and the indicated outputs are assumed to be still correct. The signature of the callable is: collectOutputsCallable(actionInstance = instance of the calling action, indicatedOutputs = outputs indicated so far, **allArgs = all arguments passed to the action )

  • noOutputArgs – If set to true the output artefacts of the action will not be added as output args. In this case outputFlags will be ignored.

  • outputReferenceArtefactName – Name of the inputArgs that will be used as template when generating the output artefacts. If not set (None), the first input selection (in alphabetic order) will be used. If indicateCallable is set, this argument has only impact if the callable makes use of it.

  • defaultoutputextension – Output extension that should be used if no indicateCallable is defined.

  • additionalArgs – Dictionary with all additional arguments (except the artefact inputs and outputs) that should be passed to the cli. The key is the argument/flag name (without “-” or “–”; the will be added automatically). If the value is not None it will be also added after the argument.

  • additionalArgsAsURL – List of names of additionalArgs whose values should be treated like URLs extracted from the input arguments. Depending on the OS or runtime environement that might lead to alterations of the values. E.g. due to mapping of the URLs. If a name in the list does not exist in additionalArgs, it is just ignored.

  • illegalArgs – List that can be used to add additional forbidden argument names, that may not be contained in additionalArgs or inputArgs.

  • inputArgsURLExtractionDelegate – Delegate that can be used to change the way how urls are extracted from artefacts that are provided for the argument or to offer a way to manipulate them before generating the cli call string. The default implementation (extract_artefact_arg_urls_default) does just return the URL of the artefact. The signature of the delegate is delegate(arg_name, arg_value). Arg_value is expected to be a list of artefacts. The return is expected to be a list of URL strings (or None for artefacts that should not return a URL).

  • use_no_url_id – Bool. If set to true, the unique id at the end of generated filenames will be removed, giving the user full control of the resulting filenames. WARNING: When using this option, the user has to take care themselves to avoid collisions between generated files.

  • inputArgs – It is assumed that all unknown named arguments are inputs with artefact lists.

Methods

__init__(structSet, referenceImage, structName)

param tool_id:

actionID that will be used to deduce the tool/executable for this action instance.

do()

Triggers the processing of an action instance.

do_finalize()

Function that has to be called after the data processing of an action processing to finalize the action state and do the bookkeeping (e.g. notifying the session, checking the validity and existence of the outputs).

do_processing()

Function that has to be called to do the data processing of an action processing.

do_setup()

Function that has to be called to prepare an action for the processing.

generateArtefact([reference, ...])

Helper method that can be used in derived action classes in their indicateOutputs() implementation.

indicateOutputs()

Return a list of artefact entries the action will produce if do_setup() is called.

setAdditionalArguments(additionalArgs)

Method can be used to (re)set the additional arguments of the action instance.

Attributes

ACTION_FAILURE

Indicating the skipping of the (last) execution of an action.

ACTION_PENDING

Indicating that the action instance is currently generating the outputs.

ACTION_RUNNING

Indicating that the action instance is in an uninitialized state.

ACTION_SKIPPED

Indicating that the action instance was not executed so far.

ACTION_SUCCESS

Indicating the failure of the (last) execution of an action instance.

ACTION_UNINIT

actionInstanceUID

actionTag

action_tag_selector

cwd

returns the current working directory that is used by the action when executing the tool.

has_warnings

instanceName

isFailure

isPending

isRunning

isSkipped

isSuccess

is_uninitialized

last_cli_call_file_path

last_exec_state

last_warnings

logErrorFilePath

Returns the path of the error log file that contains the std::error stream of the execution, the action instance is associated with.

logFilePath

Returns the path of the log file that contains the std::out stream of the execution, the action instance is associated with.

outputArtefacts

ACTION_FAILURE = 'FAILURE'

Indicating the skipping of the (last) execution of an action. As any outputs the action instance would produce are available and still up to date.

ACTION_PENDING = 'PENDING'

Indicating that the action instance is currently generating the outputs.

ACTION_RUNNING = 'RUNNING'

Indicating that the action instance is in an uninitialized state.

ACTION_SKIPPED = 'SKIPPED'

Indicating that the action instance was not executed so far.

ACTION_SUCCESS = 'SUCCESS'

Indicating the failure of the (last) execution of an action instance.

property cwd

returns the current working directory that is used by the action when executing the tool.

do()

Triggers the processing of an action instance. This should be used as public trigger of an action. It is a convenient version that will trigger do_setup, do_process and do_finalize in the right way. Returns the action instance itself.

do_finalize()

Function that has to be called after the data processing of an action processing to finalize the action state and do the bookkeeping (e.g. notifying the session, checking the validity and existence of the outputs). After the call of the method the outputs of action instance are collected and verified. It is advised to use do(), which will use do_finalize() appropriately.

do_processing()

Function that has to be called to do the data processing of an action processing. After the call of the method the outputs of action instance are computed. It is advised to use do(), which will use do_processing() appropriately.

do_setup()

Function that has to be called to prepare an action for the processing. After the call of the method the action instance is able to process the data (if needed). The return value indicates of the instance can/needs to process (true) or not (false). It is advised to use do(), which will use do_setup() appropriately. After the call of this method, the instance will have one of the following states: (1) pending: expected state. Indicating that action should/needs to process and no waiting for triggering do_process() (2) skipped: indicated ouput data is already there and valid. No need for do_process, directly trigger do_finalize() (3) failed: indicated that the setup failed (e.g. because inputs are invalid). No need for do_process, directly trigger do_finalize()

generateArtefact(reference=None, copyAdditionalPropsFromReference=True, userDefinedProps=None, url_user_defined_part=None, url_extension=None, use_no_url_id=False)

Helper method that can be used in derived action classes in their indicateOutputs() implementation. The generation will be done in following steps: 1) It generates an artefact that has the actionTag of the current action. 2) Other properties will be taken from the reference (if given). 3) If a self._propInheritanceDict is specified it will be used to inherit property values. 4) self._additionalActionProps will be transferd. 5) the property values defined in userDefinedProps will be transfered. Remark: ActionTag will always be of this action. Remark: As default the URL will be None. If parameter url_user_defined_part or url_extension are not None, an artefact URL will be created. In this case the following pattern will be used: <artefact_path>[<url_user_defined_part>.]<artefact_id>[<><url_extension>] artefact_path: Return of artefactHelper.generateArtefactPath using the configured new artefact. url_user_defined_part: Parameter of the call artefact_id: ID of the new artefact extension_seperator: OS specific file extension seperator url_extension: Parameter of the call REMARK: Currently if self has a _propInheritanceDict specified, only the first artefact of the indicated input selection will be used to inherit the property. @param reference An other artefact as reference. If given, the following properties will be copied to the new artefact: Case, timepoint, type, format, objective. @param copyAdditionalPropsFromReference Indicates if also the additional properties should be transfered from the reference to the new artefact (only relevant of reference is not None). @param userDefinedProps Properties specified by the user that should be set for the new artefact. Parameter is a dictionary. The keys are the property ids and the dict values their value. Passing None indicates that there are no props @url_user_defined_part: specifies the humand readable prefix of the artefact url. If set a URL will be generated. @url_extension: specifies the file extension of the artefact url. If set a URL will be generated. @use_no_url_id Bool. If set to true, the unique id at the end of generated filenames will be removed, giving the user full control of the resulting filenames. WARNING: When using this option, the user has to take care themselves to avoid collisions between generated files.

indicateOutputs()

Return a list of artefact entries the action will produce if do_setup() is called. The method should return complete entries. Therefore, the entries should already contain the url where they will be stored if the action is executed. Remark: The output indication might not represent the final result of an action (e.g. because an action is not able to determine the outputs before they are actually generated.). This the list might only indicate the assumed outputs. Also An action can return None to signal that it cannot indicate the outputs before generation. :return: Either a list of indicated outputs or None.

property logErrorFilePath

Returns the path of the error log file that contains the std::error stream of the execution, the action instance is associated with. If it is None the action was not executed so far.

property logFilePath

Returns the path of the log file that contains the std::out stream of the execution, the action instance is associated with. If it is None the action was not executed so far.

setAdditionalArguments(additionalArgs)

Method can be used to (re)set the additional arguments of the action instance. All passed arguments are assumed to be additional arguments with lists of argument values; like when you setting them directly in __init__(). If additional arguments where already set, the old ones will be overwritten.