コード例 #1
0
ファイル: webapp.py プロジェクト: MSLNZ/pr-omega-logger
def current_readings_viewer(tab, n_intervals):
    if tab != 'current-readings':
        return

    n = n_intervals or 0  # n_intervals is initially None
    n += 1

    children = []
    margin_right = cfg.value('current_readings/margin_right', '16px')
    for serial, data in now().json.items():
        b = f'{serial} [{data["report_number"]}] - {data["alias"]} @ {data["datetime"][11:]}'
        children.append(html.B(b))
        if data['error']:
            children.append(html.P(data['error']))
        elif 'temperature2' in data:
            for sensor in ['1', '2']:
                p = []
                for key in 'temperature' + sensor, 'humidity' + sensor, 'dewpoint' + sensor:
                    p.append(html.I(key + ':', style={'color': 'grey'}))
                    p.append(
                        html.Span(f'{data[key]:.2f}',
                                  style={'margin-right': margin_right}))
                children.append(html.P(p))
        else:
            p = []
            for key in ['temperature', 'humidity', 'dewpoint']:
                p.append(html.I(key + ':', style={'color': 'grey'}))
                p.append(
                    html.Span(f'{data[key]:.2f}',
                              style={'margin-right': margin_right}))
            children.append(html.P(p))
    return html.Div(
        children=children,
        style={'fontSize': cfg.value('current_readings/font_size', '24px')})
コード例 #2
0
    def serve(self):
        assert (self._built)

        self._app.layout = html.Div(children=[
            html.H1(["WARA-SW TEP Dashboard: ",
                     html.B(self.title)]),
            self.render()
        ])
        self._app.run_server(debug=True)
コード例 #3
0
def test_slsh002_sliders_marks_si_unit_format(dash_dcc):

    LAYOUT = []

    # Showing SI Units
    LAYOUT.extend(
        [
            html.Div(
                "Testing SI units",
                style={"marginBottom": 10, "marginTop": 30},
            ),
        ]
    )

    for n in range(-20, 20):
        min = 0
        max = pow(10, n)

        LAYOUT.extend(
            [
                html.Div(
                    [
                        html.B(
                            f"min={min}, max={max}(=10^{n})",
                            style={"marginBottom": 15, "marginTop": 25},
                        ),
                        (
                            html.Div(
                                "(Known issue: Slider does not seem to work for precision below 10^(-6))"
                            )
                            if n <= -6
                            else None
                        ),
                        html.Div("value is undefined"),
                        dcc.Slider(min, max),
                        dcc.RangeSlider(min, max),
                        html.Div(f"value=0.4 * 10^{n}"),
                        dcc.Slider(min, max, value=0.4 * max),
                        dcc.RangeSlider(min, max, value=[0.2 * max, 0.4 * max]),
                        html.Div(f"value=0.5 * 10^{n}"),
                        dcc.Slider(min, max, value=0.5 * max),
                        dcc.RangeSlider(min, max, value=[0.2 * max, 0.5 * max]),
                    ]
                )
            ]
        )

    app = Dash(__name__)
    app.layout = html.Div(LAYOUT)

    dash_dcc.start_server(app)
    dash_dcc.wait_for_element(".rc-slider")
    dash_dcc.percy_snapshot("slsh002 - test_slsh002_sliders_marks_si_unit_format", True)
コード例 #4
0
        def apply_transformation(transformation_data, struct):

            transformation = self.from_data(transformation_data)
            error = None

            try:
                struct = transformation.apply_transformation(struct)
            except Exception as exc:
                error_title = (
                    f'Failed to apply "{transformation.__class__.__name__}" '
                    f"transformation: {exc}")
                traceback_info = Reveal(
                    title=html.B("Traceback"),
                    children=[dcc.Markdown(traceback.format_exc())],
                )
                error = [error_title, traceback_info]

            return struct, error
コード例 #5
0
        def apply_transformation(transformation_data, struct):

            transformation = self.from_data(transformation_data)
            error = None

            try:
                if not isinstance(transformation, AbstractTransformation):
                    raise ValueError(
                        f"Can't run transformation: {transformation} is {type(transformation)}"
                    )

                struct = transformation.apply_transformation(struct)
            except Exception as exc:
                error_title = html.Span(
                    f'Failed to apply "{transformation.__class__.__name__}" '
                    f"transformation: {exc}")
                traceback_info = Reveal(
                    id=self.id("Error"),
                    title=html.B("Traceback"),
                    children=[dcc.Markdown(traceback.format_exc())],
                )
                error = [error_title, traceback_info]

            return struct, error
コード例 #6
0
ファイル: app_home.py プロジェクト: ltalirz/sycofinder
    ["v0.1.1", "reduce max number of variables to 5"],
    ["v0.1.0", "release on Materials Cloud"],
]

about_html = [html.P(i) for i in about.split("\n\n")]

layout = [
    html.Div(
        [
            html.Div(html.H1(app.title), id="maintitle"),
            html.H2("About"),
            html.Img(src="assets/images/logo.png", className="sycologo"),
            html.Img(src="assets/images/schema.png", className="sycoschema"),
            html.Div(about_html + [
                html.P(
                    html.A(html.B("Watch the tutorial on Youtube"),
                           href='https://youtu.be/i8i4HmEEw4Y',
                           target='_blank')),
            ],
                     className="info-container"),
            html.H2("Steps"),
            html.Div(html.Ol([
                html.Li(html.A('Compute diverse set', href='maxdiv/')),
                html.Li(
                    html.A('Genetic Algorithm: compute next generation',
                           href='ga/')),
                html.Li(html.A('Determine importance of variables',
                               href='ml/')),
            ]),
                     className="sycolinks"),
            html.H2("Changelog"),
コード例 #7
0
from models.exchange import Granularity

tg_wrapper = Wrapper("config.json", "webgui")
tg_wrapper.helper.read_config()
# selected_pair = None
CONTENT_STYLE = {
    "margin-left": "0rem",
    "margin-right": "0rem",
    "padding": "0rem 1rem",
}
layout = (
    html.Div(
        style=CONTENT_STYLE,
        children=[
            html.H4("Bot Config Generator", style={"textAlign": "left"}),
            html.B(),
            html.Div(id="save-change-message"),
            html.Div(
                dbc.Button(
                    "Save Changes",
                    id="save-changes",
                    value="saved",
                    n_clicks=0,
                    disabled=False,
                ),
                className="d-grid gap-2",
            ),
            html.H5("Exchanges"),
            html.Div(
                dbc.Card(
                    dbc.CardBody(
コード例 #8
0
 # row for arg and marginal trees
 dbc.Row(
     [
         # column for arg
         dbc.Col(
             [
                 # arg
                 dbc.Container(
                     [
                         dbc.Container(
                             [
                                 dbc.Row(
                                     [
                                         dbc.Col(
                                             [
                                                 html.B("Simulation:"),
                                                 # "Simulation:",
                                                 dcc.Dropdown(
                                                     id='sim-dropdown',
                                                     options=[
                                                         {
                                                             'label':
                                                             "ARG",
                                                             'value':
                                                             'arg'
                                                         },
                                                         # {'label': "SMC", 'value': 'smc'},
                                                         {
                                                             'label':
                                                             "SMC'",
                                                             'value':
コード例 #9
0
    } for i in np.unique(df_top5.index)],
    multi=True,
    style=dict(
        backgroundColor='#E6E6FA',
        #    marginLeft='10px',
        #    width='60%',
        #    paddingLeft="30px",
    ))

layout = html.Div([
    header_contents,
    html.P('メンティー集合を入力してください'), groupA_drop_down_list,
    html.Br(),
    html.P('メンター集合を入力してください'), groupB_drop_down_list,
    html.Br(),
    html.B(id='matching_check', style=dict(color='red')),
    dcc.Graph(
        id='matching_result',
        responsive=True,
    )
])


@app.callback(Output('matching_check', 'children'),
              [Input('group_usersA', 'value'),
               Input('group_usersB', 'value')])
def check_matching_input(list_userA, list_userB):
    if len(set(list_userA) & set(list_userB)) != 0:
        return 'メンティー集合とメンター集合に重複があります'
    elif len(set(list_userA)) > len(set(list_userB)):
        return 'メンティー集合の要素をメンター集合の要素と同等以下になるように減らしてください'
コード例 #10
0
from dash import html
import dash_bootstrap_components as dbc
from models.telegram import Wrapper
# from models.exchange import Granularity

tg_wrapper = Wrapper("config.json", "webgui")
tg_wrapper.helper.read_config()

tg_token = tg_wrapper.helper.config["telegram"]["token"]
tg_userid = tg_wrapper.helper.config["telegram"]["user_id"]
tg_clientid = tg_wrapper.helper.config["telegram"]["client_id"]

layout = html.Div([
    html.H4("Telegram Config", style={"textAlign": "left"}),
    html.B(),
    html.H5("Options"),
    html.Div(
        dbc.Card(
            dbc.CardBody([
                html.Div([
                    dbc.Label("Telegram Token"),
                    dbc.Input(
                        value=tg_token,
                        id="input",
                        placeholder="Enter Token ... ",
                        type="password",
                    ),
                    dbc.FormText(
                        "Token Format: nnnnnnnnnn:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    ),
                ]),
コード例 #11
0
    def __init__(
        self,
        running_args: argparse.Namespace,
        immutable_args: Iterable[str],
        dashboard_host: str,
        dashboard_port: int,
        **kwargs,
    ):
        threading.Thread.__init__(self)
        self.app = dash.Dash(__name__,
                             url_base_pathname='/radiotracking-config/',
                             meta_tags=[{
                                 "name":
                                 "viewport",
                                 "content":
                                 "width=device-width, initial-scale=1"
                             }])

        config_columns = html.Div(children=[],
                                  style={
                                      "columns": "2 359px",
                                      "padding": "20pt"
                                  })
        config_tab = dcc.Tab(label="tRackIT Configuration",
                             children=[config_columns])
        config_columns.children.append(
            html.Div(
                "Reconfiguration requires restarting of pyradiotracking. Please keep in mind, that a broken configuration might lead to failing starts."
            ))

        self.running_args = running_args
        self.immutable_args = immutable_args
        self.config_states: List[State] = []

        for group in Runner.parser._action_groups:
            # skip untitled groups
            if not isinstance(group.title, str):
                continue

            # skip groups not used in the config file
            if len(group._group_actions) == 0:
                continue

            group_div = html.Div(children=[],
                                 style={"break-inside": "avoid-column"})
            config_columns.children.append(group_div)

            group_div.children.append(html.H3(f"[{group.title}]"))

            # iterate actions and extract values
            for action in group._group_actions:
                if action.dest not in vars(running_args):
                    continue

                value = vars(running_args)[action.dest]

                group_div.children.append(
                    html.P(children=[
                        html.B(action.dest),
                        f" - {action.help}",
                        html.Br(),
                        dcc.Input(id=action.dest, value=repr(value)),
                    ]))

                if action.type == int or isinstance(action,
                                                    argparse._CountAction):
                    if not isinstance(value, list):
                        group_div.children[-1].children[-1].type = "number"
                        group_div.children[-1].children[-1].step = 1
                elif action.type == float:
                    if not isinstance(value, list):
                        group_div.children[-1].children[-1].type = "number"
                elif action.type == str:
                    group_div.children[-1].children[-1].type = "text"
                    if isinstance(value, list):
                        group_div.children[-1].children[-1].value = repr(value)
                    else:
                        group_div.children[-1].children[-1].value = value
                elif isinstance(action, argparse._StoreTrueAction):
                    group_div.children[-1].children[-1] = dcc.Checklist(
                        id=action.dest,
                        options=[
                            {
                                "value": action.dest,
                                "disabled": action.dest in self.immutable_args
                            },
                        ],
                        value=[action.dest] if value else [],
                    )

                if action.dest in self.immutable_args:
                    group_div.children[-1].children[-1].disabled = True

                self.config_states.append(State(action.dest, "value"))

        config_columns.children.append(html.Button('Save', id="submit-config"))
        self.app.callback(Output('config-msg', 'children'), [
            Input("submit-config", "n_clicks"),
        ], self.config_states)(self.submit_config)

        config_columns.children.append(
            html.Button('Restart', id="submit-restart"))
        self.app.callback(Output('submit-restart', 'children'), [
            Input("submit-restart", "n_clicks"),
        ])(self.submit_restart)
        config_columns.children.append(
            html.H4("",
                    id="config-msg",
                    style={
                        "text-align": "center",
                        "padding": "10px"
                    }))

        tabs = dcc.Tabs(children=[])
        tabs.children.append(config_tab)

        self.app.layout = html.Div([tabs])
        self.app.layout.style = {"font-family": "sans-serif"}

        self.server = ThreadedWSGIServer(dashboard_host, dashboard_port + 1,
                                         self.app.server)

        self.calibrations: Dict[float, Dict[str, float]] = {}