File size: 2,254 Bytes
7feac49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright (c) Alibaba, Inc. and its affiliates.
from typing import Type

import gradio as gr

from swift.ui.base import BaseUI


class ReportTo(BaseUI):

    group = 'llm_train'

    locale_dict = {
        'reporter': {
            'label': {
                'zh': '训练记录',
                'en': 'Training report'
            },
        },
        'report_to': {
            'label': {
                'zh': '训练记录方式',
                'en': 'Report to'
            },
        },
        'swanlab_token': {
            'label': {
                'zh': 'swanlab登录token',
                'en': 'The login token of swanlab'
            },
        },
        'swanlab_project': {
            'label': {
                'zh': 'swanlab项目名称',
                'en': 'Project of swanlab'
            },
        },
        'swanlab_workspace': {
            'label': {
                'zh': 'swanlab工作空间',
                'en': 'Workspace of swanlab'
            },
        },
        'swanlab_exp_name': {
            'label': {
                'zh': 'swanlab实验名称',
                'en': 'Experiment of swanlab'
            },
        },
        'swanlab_mode': {
            'label': {
                'zh': 'swanlab工作模式',
                'en': 'Work mode of swanlab'
            },
        },
    }

    @classmethod
    def do_build_ui(cls, base_tab: Type['BaseUI']):
        with gr.Accordion(elem_id='reporter', open=False):
            with gr.Blocks():
                with gr.Row():
                    gr.Dropdown(
                        elem_id='report_to',
                        multiselect=True,
                        is_list=True,
                        choices=['tensorboard', 'wandb', 'swanlab'],
                        allow_custom_value=True,
                        scale=20)
                    gr.Textbox(elem_id='swanlab_token', lines=1, scale=20)
                    gr.Textbox(elem_id='swanlab_project', lines=1, scale=20)
                with gr.Row():
                    gr.Textbox(elem_id='swanlab_workspace', lines=1, scale=20)
                    gr.Textbox(elem_id='swanlab_exp_name', lines=1, scale=20)
                    gr.Dropdown(elem_id='swanlab_mode', scale=20)