def __init__(self, __task_type, **kwargs): ''' Construct an instance of GBDX Task Args: __task_type: name of the task **kwargs: key=value pairs for inputs to set on the task Returns: An instance of Task. ''' self.name = __task_type + '_' + str(uuid.uuid4())[:8] self.name = self.name.replace(':','_') # keep colon out of task name self.type = __task_type task_registry = TaskRegistry() self.definition = task_registry.get_definition(__task_type) self.domain = self.definition.get('containerDescriptors', [{'properties': {}}])[0]['properties'].get('domain', 'default') self._timeout = self.definition['properties'].get('timeout') self.inputs = Inputs(self.input_ports, task=self) self.outputs = Outputs(self.output_ports, self.name) self.batch_values = None self._impersonation_allowed = None # all the other kwargs are input port values or sources self.set(**kwargs)
def test_describe_tasks(): tr = TaskRegistry(gbdx) task_list = tr.list() assert len(task_list) > 0 desc = tr.get_definition(task_list[0]) assert isinstance(desc, dict) assert len(desc['description']) > 0