contrib/runners/mistral_v2/query/mistral_v2.py
def query(self, execution_id, query_context, last_query_time=None):
        """
        Queries mistral for workflow results using v2 APIs.
        :param execution_id: st2 execution_id (context to be used for logging/audit)
        :type execution_id: ``str``
        :param query_context: context for the query to be made to mistral. This contains mistral
                              execution id.
        :type query_context: ``object``
        :param last_query_time: Timestamp of last query.
        :type last_query_time: ``float``
        :rtype: (``str``, ``object``)
        """
        dt_last_query_time = (
            time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(last_query_time))
            if last_query_time else None
        )

        liveaction_db = action_utils.get_liveaction_by_id(execution_id)

        mistral_exec_id = query_context.get('mistral', {}).get('execution_id', None)
        if not mistral_exec_id:
            raise Exception('[%s] Missing mistral workflow execution ID in query context. %s',
                            execution_id, query_context)

        try:
            wf_result = self._get_workflow_result(mistral_exec_id)

            wf_tasks_result = self._get_workflow_tasks(
                mistral_exec_id,
                last_query_time=dt_last_query_time
            )

            result = self._format_query_result(
                liveaction_db.result,
                wf_result,
                wf_tasks_result
            )
        except exceptions.ReferenceNotFoundError as exc:
            LOG.exception('[%s] Unable to find reference.', execution_id)
            return (action_constants.LIVEACTION_STATUS_FAILED, exc.message)
        except Exception:
            LOG.exception('[%s] Unable to fetch mistral workflow result and tasks. %s',
                          execution_id, query_context)
            raise

        status = self._determine_execution_status(
            liveaction_db,
            result['extra']['state'],
            result['tasks']
        )

        LOG.debug('[%s] mistral workflow execution status: %s' % (execution_id, status))
        LOG.debug('[%s] mistral workflow execution result: %s' % (execution_id, result))

        return (status, result)

        Queries mistral for workflow results using v2 APIs.
        :param execution_id: st2 execution_id (context to be used for logging/audit)
        :type execution_id: ``str``
        :param query_context: context for the query to be made to mistral. This contains mistral
                              execution id.
        :type query_context: ``object``
        :param last_query_time: Timestamp of last query.
        :type last_query_time: ``float``
        :rtype: (``str``, ``object``)
        
Queries mistral for workflow results using v2 APIs.
Queries mistral for workflow results using v2 APIs .
def query(self, execution_id, query_context, last_query_time=None):
        dt_last_query_time = (
            time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(last_query_time))
            if last_query_time else None
        )
        liveaction_db = action_utils.get_liveaction_by_id(execution_id)
        mistral_exec_id = query_context.get('mistral', {}).get('execution_id', None)
        if not mistral_exec_id:
            raise Exception('[%s] Missing mistral workflow execution ID in query context. %s',
                            execution_id, query_context)
        try:
            wf_result = self._get_workflow_result(mistral_exec_id)
            wf_tasks_result = self._get_workflow_tasks(
                mistral_exec_id,
                last_query_time=dt_last_query_time
            )
            result = self._format_query_result(
                liveaction_db.result,
                wf_result,
                wf_tasks_result
            )
        except exceptions.ReferenceNotFoundError as exc:
            LOG.exception('[%s] Unable to find reference.', execution_id)
            return (action_constants.LIVEACTION_STATUS_FAILED, exc.message)
        except Exception:
            LOG.exception('[%s] Unable to fetch mistral workflow result and tasks. %s',
                          execution_id, query_context)
            raise
        status = self._determine_execution_status(
            liveaction_db,
            result['extra']['state'],
            result['tasks']
        )
        LOG.debug('[%s] mistral workflow execution status: %s' % (execution_id, status))
        LOG.debug('[%s] mistral workflow execution result: %s' % (execution_id, result))
        return (status, result)
def query ( self , execution_id , query_context , last_query_time = None ) : dt_last_query_time = ( time . strftime ( '%Y-%m-%d %H:%M:%S' , time . gmtime ( last_query_time ) ) if last_query_time else None ) liveaction_db = action_utils . get_liveaction_by_id ( execution_id ) mistral_exec_id = query_context . get ( 'mistral' , { } ) . get ( 'execution_id' , None ) if not mistral_exec_id : raise Exception ( '[%s] Missing mistral workflow execution ID in query context. %s' , execution_id , query_context ) try : wf_result = self . _get_workflow_result ( mistral_exec_id ) wf_tasks_result = self . _get_workflow_tasks ( mistral_exec_id , last_query_time = dt_last_query_time ) result = self . _format_query_result ( liveaction_db . result , wf_result , wf_tasks_result ) except exceptions . ReferenceNotFoundError as exc : LOG . exception ( '[%s] Unable to find reference.' , execution_id ) return ( action_constants . LIVEACTION_STATUS_FAILED , exc . message ) except Exception : LOG . exception ( '[%s] Unable to fetch mistral workflow result and tasks. %s' , execution_id , query_context ) raise status = self . _determine_execution_status ( liveaction_db , result [ 'extra' ] [ 'state' ] , result [ 'tasks' ] ) LOG . debug ( '[%s] mistral workflow execution status: %s' % ( execution_id , status ) ) LOG . debug ( '[%s] mistral workflow execution result: %s' % ( execution_id , result ) ) return ( status , result )
Queries mistral for workflow results using v2 APIs.
Queries mistral for workflow results using v2 APIs .
"""
        Queries mistral for workflow results using v2 APIs.
        :param execution_id: st2 execution_id (context to be used for logging/audit)
        :type execution_id: ``str``
        :param query_context: context for the query to be made to mistral. This contains mistral
                              execution id.
        :type query_context: ``object``
        :param last_query_time: Timestamp of last query.
        :type last_query_time: ``float``
        :rtype: (``str``, ``object``)
        """
None
(``str``, ``object``)
self
execution_id
st2 execution_id (context to be used for logging/audit)
st2 execution_id ( context to be used for logging / audit )
query_context
context for the query to be made to mistral. This contains mistral
execution id.
context for the query to be made to mistral . This contains mistral execution id .
last_query_time
Timestamp of last query.
Timestamp of last query .