How to use the flowmachine.flowmachine.core.query_state.QueryState function in flowmachine

To help you get started, we’ve selected a few flowmachine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
transition is possible given the current state of the query.

        Parameters
        ----------
        event: QueryEvent
            Event to trigger

        Returns
        -------
        tuple of QueryState, bool
            Returns a tuple of the new query state, and a bool indicating whether this method
            call caused a transition to that state

        """
        state, trigger_success = self.state_machine.trigger(event)
        return QueryState(state.decode()), trigger_success
github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
def __init__(self, redis_client: StrictRedis, query_id: str, db_id: str):
        self.query_id = query_id
        must_populate = redis_client.get(f"finist:{db_id}:{query_id}-state") is None
        self.state_machine = Finist(
            redis_client, f"{db_id}:{query_id}-state", QueryState.KNOWN
        )
        if must_populate:  # Need to create the state machine for this query
            self.state_machine.on(QueryEvent.QUEUE, QueryState.KNOWN, QueryState.QUEUED)
            self.state_machine.on(
                QueryEvent.EXECUTE, QueryState.QUEUED, QueryState.EXECUTING
            )
            self.state_machine.on(
                QueryEvent.ERROR, QueryState.EXECUTING, QueryState.ERRORED
            )
            self.state_machine.on(
                QueryEvent.FINISH, QueryState.EXECUTING, QueryState.COMPLETED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.QUEUED, QueryState.CANCELLED
            )
            self.state_machine.on(
github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
QueryEvent.ERROR, QueryState.EXECUTING, QueryState.ERRORED
            )
            self.state_machine.on(
                QueryEvent.FINISH, QueryState.EXECUTING, QueryState.COMPLETED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.QUEUED, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.EXECUTING, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.CANCELLED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.ERRORED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.FINISH_RESET, QueryState.RESETTING, QueryState.KNOWN
            )
github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
self.state_machine = Finist(
            redis_client, f"{db_id}:{query_id}-state", QueryState.KNOWN
        )
        if must_populate:  # Need to create the state machine for this query
            self.state_machine.on(QueryEvent.QUEUE, QueryState.KNOWN, QueryState.QUEUED)
            self.state_machine.on(
                QueryEvent.EXECUTE, QueryState.QUEUED, QueryState.EXECUTING
            )
            self.state_machine.on(
                QueryEvent.ERROR, QueryState.EXECUTING, QueryState.ERRORED
            )
            self.state_machine.on(
                QueryEvent.FINISH, QueryState.EXECUTING, QueryState.COMPLETED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.QUEUED, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.EXECUTING, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.CANCELLED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.ERRORED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
QueryEvent.CANCEL, QueryState.QUEUED, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.EXECUTING, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.CANCELLED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.ERRORED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.FINISH_RESET, QueryState.RESETTING, QueryState.KNOWN
            )
github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
def __init__(self, redis_client: StrictRedis, query_id: str, db_id: str):
        self.query_id = query_id
        must_populate = redis_client.get(f"finist:{db_id}:{query_id}-state") is None
        self.state_machine = Finist(
            redis_client, f"{db_id}:{query_id}-state", QueryState.KNOWN
        )
        if must_populate:  # Need to create the state machine for this query
            self.state_machine.on(QueryEvent.QUEUE, QueryState.KNOWN, QueryState.QUEUED)
            self.state_machine.on(
                QueryEvent.EXECUTE, QueryState.QUEUED, QueryState.EXECUTING
            )
            self.state_machine.on(
                QueryEvent.ERROR, QueryState.EXECUTING, QueryState.ERRORED
            )
            self.state_machine.on(
                QueryEvent.FINISH, QueryState.EXECUTING, QueryState.COMPLETED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.QUEUED, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.CANCEL, QueryState.EXECUTING, QueryState.CANCELLED
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.CANCELLED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.ERRORED, QueryState.RESETTING
            )
            self.state_machine.on(
                QueryEvent.RESET, QueryState.COMPLETED, QueryState.RESETTING
            )
github Flowminder / FlowKit / flowmachine / flowmachine / core / query_state.py View on Github external
def current_query_state(self) -> QueryState:
        """

        Returns
        -------
        QueryState
            Current state of the query this state machine refers to
        """
        return QueryState(self.state_machine.state().decode())