Ejemplo n.º 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,
                                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())
Ejemplo n.º 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(
                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()
Ejemplo n.º 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)
                )
            ).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()