scheduler.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:treadmill 作者: Morgan-Stanley 项目源码 文件源码
def explain_group(parent):
    """Scheduler explain CLI group."""

    def _print_frame(df):
        """Prints dataframe."""
        if not df.empty:
            pd.set_option('display.max_rows', None)
            pd.set_option('float_format', lambda f: '%f' % f)
            pd.set_option('expand_frame_repr', False)
            print(df.to_string(index=False))

    @parent.group()
    def explain():
        """Explain scheduler internals"""
        pass

    @explain.command()
    @click.option('--instance', help='Application instance')
    @click.option('--partition', help='Cell partition', default='_default')
    @cli.admin.ON_EXCEPTIONS
    def queue(instance, partition):
        """Explain the application queue"""
        cell_master = make_readonly_master()
        frame = reports.explain_queue(cell_master.cell,
                                      partition,
                                      pattern=instance)
        _print_frame(frame)

    @explain.command()
    @click.argument('instance')
    @click.option('--mode', help='Tree traversal method',
                  type=click.Choice(reports.WALKS.keys()), default='default')
    @cli.admin.ON_EXCEPTIONS
    def placement(instance, mode):
        """Explain application placement"""
        cell_master = make_readonly_master()

        if instance not in cell_master.cell.apps:
            cli.bad_exit('Instance not found.')

        app = cell_master.cell.apps[instance]
        if app.server:
            cli.bad_exit('Instace already placed on %s' % app.server)

        frame = reports.explain_placement(cell_master.cell, app, mode)
        _print_frame(frame)

    del queue
    del placement
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号