def description(self) -> Description: """Get a description of the resource type.""" manager: WorkflowManager = self._workflow_manager() if manager is None: raise ScopeError( 'Out of scope. Managing context no longer exists!') return manager.tasks[self.uid()].description()
def description(self) -> Description: """Get a description of the resource type.""" context = self._context() if context is None: raise ScopeError( 'Out of scope. Managing context no longer exists!') return context.item(self.uid()).description()
def manager(self) -> 'WorkflowManager': manager = self._workflow_manager() if manager is None: raise ScopeError('Out of scope. Managing context no longer exists!') else: if not isinstance(manager, WorkflowManager): raise APIError('Bug: ItemView._workflow_manager must weakly reference ' 'a WorkflowManager.') return manager
def result(self): """Get a local object of the tasks's result type. .. todo:: Forces dependency resolution. """ context = self._context() if context is None: raise ScopeError( 'Out of scope. Managing context no longer exists!') return context.item(self.uid()).result()
def done(self) -> bool: """Check the status of the task. Returns: true if the task has finished. """ context = self._context() if context is None: raise ScopeError( 'Out of scope. Managing context no longer exists!') return context.item(self.uid()).done()
def done(self) -> bool: """Check the status of the task. Returns: true if the task has finished. """ manager: WorkflowManager = self._workflow_manager() if manager is None: raise ScopeError( 'Out of scope. Managing context no longer exists!') return manager.tasks[self.uid()].done()
def result(self): """Get a local object of the tasks's result type. .. todo:: Forces dependency resolution. """ manager: WorkflowManager = self._workflow_manager() if manager is None: raise ScopeError( 'Out of scope. Managing context no longer exists!') # TODO: What is the public interface to the tasks or completion status? # Note: We want to keep the View object as lightweight as possible, such # as storing just the weak ref to the manager, and the item identifier. return manager.tasks[self.uid()].result()
def __getattr__(self, item): """Proxy attribute accessor for special task members. If the workflow element provides the requested interface, the managing Context will provide appropriate access. For "result" attributes, the returned reference supports the Future interface. """ # We don't actually want to do this check here, but this is essentially what # needs to happen: # assert hasattr(self.description().type().result_description().type(), item) context = self._context() if context is None: raise ScopeError( 'Out of scope. Managing context no longer available!') task = context.item(self.uid()) # type: Task try: return getattr(task, item) except KeyError as e: raise