Exemple #1
0
    def get_workers(self):
        """
        Returns information about all the workers in the database. The return
        value is a list of dicts with the structure shown in the code below.
        """
        with self._engine.begin() as conn:
            worker_rows = conn.execute(
                select([cl_worker, cl_worker_dependency.c.dependencies])
                .select_from(cl_worker.outerjoin(cl_worker_dependency))
            ).fetchall()
            worker_run_rows = conn.execute(cl_worker_run.select()).fetchall()

        worker_dict = {(row.user_id, row.worker_id): {
            'user_id': row.user_id,
            'worker_id': row.worker_id,
            'tag': row.tag,
            'cpus': row.cpus,
            'gpus': row.gpus,
            'memory_bytes': row.memory_bytes,
            'checkin_time': row.checkin_time,
            'socket_id': row.socket_id,
            'run_uuids': [],
            'dependencies': row.dependencies and self._deserialize_dependencies(row.dependencies),
        } for row in worker_rows}
        for row in worker_run_rows:
            worker_dict[(row.user_id, row.worker_id)]['run_uuids'].append(row.run_uuid)
        return worker_dict.values()
Exemple #2
0
    def get_workers(self):
        """
        Returns information about all the workers in the database. The return
        value is a list of dicts with the structure shown in the code below.
        """
        with self._engine.begin() as conn:
            worker_rows = conn.execute(cl_worker.select()).fetchall()
            worker_run_rows = (
                conn.execute(cl_worker_run.select()).fetchall())
            worker_dependency_rows = (
                conn.execute(cl_worker_dependency.select()).fetchall())
 
        worker_dict = {(row.user_id, row.worker_id): {
            'user_id': row.user_id,
            'worker_id': row.worker_id,
            'slots': row.slots,
            'checkin_time': row.checkin_time,
            'socket_id': row.socket_id,
            'run_uuids': [],
            'dependency_uuids': [],
        } for row in worker_rows}
        for row in worker_run_rows:
            worker_dict[(row.user_id, row.worker_id)]['run_uuids'].append(row.run_uuid)
        for row in worker_dependency_rows:
            worker_dict[(row.user_id, row.worker_id)]['dependency_uuids'].append(row.dependency_uuid)
        return worker_dict.values()
Exemple #3
0
    def get_workers(self):
        """
        Returns information about all the workers in the database. The return
        value is a list of dicts with the structure shown in the code below.
        """
        with self._engine.begin() as conn:
            worker_rows = conn.execute(
                select([cl_worker,
                        cl_worker_dependency.c.dependencies]).select_from(
                            cl_worker.outerjoin(
                                cl_worker_dependency,
                                cl_worker.c.worker_id ==
                                cl_worker_dependency.c.worker_id,
                            ))).fetchall()
            worker_run_rows = conn.execute(cl_worker_run.select()).fetchall()

        worker_dict = {
            (row.user_id, row.worker_id): {
                'user_id':
                row.user_id,
                'worker_id':
                row.worker_id,
                'group_uuid':
                row.group_uuid,
                'tag':
                row.tag,
                'cpus':
                row.cpus,
                'gpus':
                row.gpus,
                'memory_bytes':
                row.memory_bytes,
                'free_disk_bytes':
                row.free_disk_bytes,
                'checkin_time':
                row.checkin_time,
                'socket_id':
                row.socket_id,
                # run_uuids will be set later
                'run_uuids': [],
                'dependencies':
                row.dependencies
                and self._deserialize_dependencies(row.dependencies),
                'shared_file_system':
                row.shared_file_system,
                'tag_exclusive':
                row.tag_exclusive,
                'exit_after_num_runs':
                row.exit_after_num_runs,
                'is_terminating':
                row.is_terminating,
                'preemptible':
                row.preemptible,
            }
            for row in worker_rows
        }
        for row in worker_run_rows:
            worker_dict[(row.user_id,
                         row.worker_id)]['run_uuids'].append(row.run_uuid)
        return list(worker_dict.values())
Exemple #4
0
    def get_workers(self):
        """
        Returns information about all the workers in the database. The return
        value is a list of dicts with the structure shown in the code below.
        """
        with self._engine.begin() as conn:
            worker_rows = conn.execute(
                select([cl_worker, cl_worker_dependency.c.dependencies]).select_from(
                    cl_worker.outerjoin(cl_worker_dependency)
                )
            ).fetchall()
            worker_run_rows = conn.execute(cl_worker_run.select()).fetchall()

        worker_dict = {
            (row.user_id, row.worker_id): {
                'user_id': row.user_id,
                'worker_id': row.worker_id,
                'tag': row.tag,
                'cpus': row.cpus,
                'gpus': row.gpus,
                'memory_bytes': row.memory_bytes,
                'checkin_time': row.checkin_time,
                'socket_id': row.socket_id,
                'run_uuids': [],
                'dependencies': row.dependencies
                and self._deserialize_dependencies(row.dependencies),
            }
            for row in worker_rows
        }
        for row in worker_run_rows:
            worker_dict[(row.user_id, row.worker_id)]['run_uuids'].append(row.run_uuid)
        return worker_dict.values()
Exemple #5
0
 def get_bundle_worker(self, uuid):
     """
     Returns information about the worker that the given bundle is running
     on. This method should be called only for bundles that are running.
     """
     with self._engine.begin() as connection:
         row = connection.execute(cl_worker_run.select()
                                  .where(cl_worker_run.c.run_uuid == uuid)).fetchone()
         precondition(row, 'Trying to find worker for bundle that is not running.')
         worker_row = connection.execute(cl_worker.select()
                                         .where(and_(cl_worker.c.user_id == row.user_id,
                                                     cl_worker.c.worker_id == row.worker_id))).fetchone()
         return {
             'user_id': worker_row.user_id,
             'worker_id': worker_row.worker_id,
             'socket_id': worker_row.socket_id,
         }
 def get_bundle_worker(self, uuid):
     """
     Returns information about the worker that the given bundle is running
     on. This method should be called only for bundles that are running.
     """
     with self._engine.begin() as connection:
         row = connection.execute(cl_worker_run.select()
                                  .where(cl_worker_run.c.run_uuid == uuid)).fetchone()
         precondition(row, 'Trying to find worker for bundle that is not running.')
         worker_row = connection.execute(cl_worker.select()
                                         .where(and_(cl_worker.c.user_id == row.user_id,
                                                     cl_worker.c.worker_id == row.worker_id))).fetchone()
         return {
             'user_id': worker_row.user_id,
             'worker_id': worker_row.worker_id,
             'socket_id': worker_row.socket_id,
         }