Exemplo n.º 1
0
    def test_jobboard_backend_connection_fetches_persistence_backend(self):
        self.assertFalse(self.persistence_fetch.called)

        with jobboard_backend_connection():
            self.persistence_fetch.assert_called_once_with(
                PERSISTENCE_CONF
            )
Exemplo n.º 2
0
def get_all_logbooks():
    """
    Retrieve all logbooks from the persistence backend and
    translate all the relevant data into a dict structure
    :return iter[dict, ..] all_logbooks_as_dict: An iterable of dicts
    representing all logbooks and their contents currently in the
    persistence backend
    """
    with persistence_backend_connection() as p:
        with jobboard_backend_connection() as j:
            return [{
                'name':
                lb.name,
                'meta':
                lb.meta,
                'flow_details': [{
                    'uuid':
                    f.uuid,
                    'atom_details': [{
                        'uuid': a.uuid,
                        'name': a.name,
                        'state': a.state,
                    } for a in get_atoms_for_flow(f, p)],
                    'meta':
                    f.meta,
                    'state':
                    f.state,
                    'owner':
                    get_owner(f.uuid, j)
                } for f in get_flows_from_logbook(lb, p)]
            } for lb in get_logbooks(p)]
Exemplo n.º 3
0
    def test_jobboard_backend_connection_fetches_job_board_backend(self):
        self.assertFalse(self.job_board_fetch.called)

        with jobboard_backend_connection():
            self.job_board_fetch.assert_called_once_with(
                CONDUCTOR_NAME, JOBBOARD_CONF,
                persistence=self.persistence_fetch.return_value
            )
Exemplo n.º 4
0
    def test_jobboard_backend_connection_adds_custom_jobboard_iterator(self):
        self.assertFalse(self.jobboard_iterator.called)

        with jobboard_backend_connection() as conn:
            self.jobboard_iterator.assert_called_once_with(
                conn.unfiltered_iterjobs
            )
            self.assertEqual(
                conn.iterjobs, self.jobboard_iterator.return_value
            )
Exemplo n.º 5
0
def perform_post(logbook,
                 flow_factory,
                 store=None,
                 factory_args=None,
                 factory_kwargs=None,
                 capabilities=set()):
    """
    Connect to the job board backend and queue the job
    :param obj logbook: The logbook to post the job to
    :param obj flow_factory: A function that returns a flow
    :param dict store: The store to post with the flow
    :param list factory_args: The args to pass to the flow factory
    during flow pickup time in the conductor
    :param dict factory_kwargs: The kwargs to pass to the flow factory
    during flow pickup time in the conductor
    :param set [str, ..] capabilities: A list of capabilities the the
    conductor should satisfy to view the job as allowed to claim.
    See the register_capability decorator for registering new capabilities
    :return None:
    """
    log.debug("Posting job to the job board")
    with jobboard_backend_connection() as job_backend:
        flow_detail = compose_flow_detail(store or dict())
        save_flow_detail_to_logbook(flow_detail, logbook)
        save_flow_factory_into_flow_detail(flow_detail,
                                           flow_factory,
                                           factory_args=factory_args,
                                           factory_kwargs=factory_kwargs)
        job_backend.post(
            "job-from-{}".format(CONDUCTOR_NAME),
            book=logbook,
            details={
                # Need this to find the job back in the logbook
                # See _flow_detail_from_job
                # http://pydoc.net/Python/taskflow/0.6.1/
                # taskflow.conductors.base/
                'flow_uuid': flow_detail.uuid,
                'capabilities': capabilities
            })
Exemplo n.º 6
0
    def test_jobboard_backend_connection_closes_connection_after_ctx(self):
        with jobboard_backend_connection() as conn:
            self.assertFalse(conn.close.called)

        conn.close.assert_called_once_with()
Exemplo n.º 7
0
 def test_jobboard_backend_connection_yields_connection_to_context(self):
     with jobboard_backend_connection() as conn:
         expected_connection = self.job_board_fetch.return_value
         self.assertEqual(conn, expected_connection)
Exemplo n.º 8
0
 def test_jobboard_backend_connection_connects_to_jobboard(self):
     self.assertFalse(self.job_board_fetch.return_value.connect.called)
     with jobboard_backend_connection():
         self.job_board_fetch.return_value.connect.assert_called_once_with()