Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tab_height = '500px'
stepsize = 10
#style = {'description_width': '250px'}
style = {'description_width': '25%'}
layout = {'width': '400px'}
name_button_layout={'width':'25%'}
widget_layout = {'width': '15%'}
units_button_layout ={'width':'15%'}
desc_button_layout={'width':'45%'}
param_name1 = Button(description='random_seed', disabled=True, layout=name_button_layout)
param_name1.style.button_color = 'lightgreen'
self.random_seed = IntText(
value=0,
step=1,
style=style, layout=widget_layout)
param_name2 = Button(description='therapy_activation_time', disabled=True, layout=name_button_layout)
param_name2.style.button_color = 'tan'
self.therapy_activation_time = FloatText(
value=10080,
step=1000,
style=style, layout=widget_layout)
param_name3 = Button(description='save_interval_after_therapy_start', disabled=True, layout=name_button_layout)
param_name3.style.button_color = 'lightgreen'
self.save_interval_after_therapy_start = FloatText(
value=1.0,
step=0.1,
style=style, layout=widget_layout)
param_name5 = Button(description='unattached_worker_migration_bias', disabled=True, layout=name_button_layout)
param_name5.style.button_color = 'red'
self.unattached_worker_migration_bias = FloatText(
value=0.5,
step=0.1,
style=style, layout=widget_layout)
param_name6 = Button(description='number_of_directors', disabled=True, layout=name_button_layout)
param_name6.style.button_color = 'green'
self.number_of_directors = IntText(
value=15,
step=1,
style=style, layout=widget_layout)
param_name7 = Button(description='number_of_cargo_clusters', disabled=True, layout=name_button_layout)
param_name7.style.button_color = 'red'
self.number_of_cargo_clusters = IntText(
value=100,
step=10,
style=style, layout=widget_layout)
param_name8 = Button(description='number_of_workers', disabled=True, layout=name_button_layout)
param_name8.style.button_color = 'green'
self.number_of_workers = IntText(
def _get_clustering_widget(self):
self._update_clustering = widgets.Button(description='update')
self._use_clustering = widgets.Checkbox(
value=True, description='apply clustering')
self._max_num_clusters = widgets.IntText(value=20,
description='maximum number of clusters')
self._random_state = widgets.IntText(
value=42, description='Random State')
self._cache_in_repo = widgets.Checkbox(
value=True, description='cache ICE in repo')
self._scale = widgets.Checkbox(
value=True, description='scale x-values to zero mean and unit variance')
self._update_clustering.on_click(self._cluster)
return widgets.VBox(children=[
self._use_clustering,
self._max_num_clusters,
self._random_state,
self._cache_in_repo,
self._scale
])
def __init__(self, data, interval=10, step=1, **kwargs):
super(Animation, self).__init__(data, **kwargs)
self.play = widgets.Play(interval=interval, value=self.x, min=0, max=len(self.data.axes[self.comp]),
step=step, description="Press play", disabled=False)
self.interval_wgt = widgets.IntText(value=interval, description='Interval:', disabled=False)
self.step_wgt = widgets.IntText(value=step, description='Step:', disabled=False)
# link everything together
widgets.jslink((self.play, 'value'), (self.index_slider, 'value'))
self.interval_wgt.observe(self.update_interval, 'value')
self.step_wgt.observe(self.update_step, 'value')
def __init__(self, net, width="95%", height="550px", play_rate=0.5):
self._ignore_layer_updates = False
self.player = _Player(self, play_rate)
self.player.start()
self.net = net
self.dataset = net.dataset
self.net = net
self._width = width
self._height = height
## Global widgets:
style = {"description_width": "initial"}
self.feature_columns = IntText(description="Feature columns:", value=3, style=style)
self.feature_scale = FloatText(description="Feature scale:", value=2.0, style=style)
self.feature_columns.observe(self.regenerate, names='value')
self.feature_scale.observe(self.regenerate, names='value')
## Hack to center SVG as justify-content is broken:
self.net_svg = HTML(value="""<p style="text-align:center">%s</p>""" % ("",), layout=Layout(
width=self._width, overflow_x='auto', overflow_y="auto",
justify_content="center"))
# Make controls first:
self.output = Output()
controls = self.make_controls()
config = self.make_config()
super().__init__([config, controls, self.net_svg, self.output])
def __init__(self, title, function, length, play_rate=0.5):
self.player = _Player(self, play_rate)
self.player.start()
self.title = title
self.function = function
self.length = length
self.output = Output()
self.position_text = IntText(value=0, layout=Layout(width="100%"))
self.total_text = Label(value="of %s" % self.length, layout=Layout(width="100px"))
controls = self.make_controls()
super().__init__([controls, self.output])
if "dashboard" in self.scheduler.services:
link = self.dashboard_link
link = '<p><b>Dashboard: </b><a href="%s">%s</a></p>\n' % (
link,
link,
)
else:
link = ""
title = "<h2>%s</h2>" % type(self).__name__
title = HTML(title)
dashboard = HTML(link)
status = HTML(self._widget_status(), layout=Layout(min_width="150px"))
request = IntText(0, description="Workers", layout=layout)
scale = Button(description="Scale", layout=layout)
request_cores = IntText(0, description="Cores", layout=layout)
scale_cores = Button(description="Scale", layout=layout)
request_memory = Text("O GB", description="Memory", layout=layout)
scale_memory = Button(description="Scale", layout=layout)
minimum = IntText(0, description="Minimum", layout=layout)
maximum = IntText(0, description="Maximum", layout=layout)
adapt = Button(description="Adapt", layout=layout)
minimum_cores = IntText(0, description="Min cores", layout=layout)
maximum_cores = IntText(0, description="Max cores", layout=layout)
adapt_cores = Button(description="Adapt", layout=layout)
minimum_mem = Text("0 GB", description="Min memory", layout=layout)
maximum_mem = Text("0 GB", description="Max memory", layout=layout)
adapt_mem = Button(description="Adapt", layout=layout)
children = (p, l, b, f, a)
elif isinstance(value, int):
from ipywidgets import IntSlider, IntText, BoundedIntText, \
Label
from traitlets import link
p = Label(value=param, layout=Layout(flex='0 1 auto', width='10%'))
b = BoundedIntText(value=0, min=1e-10,
layout=Layout(flex='0 1 auto', width='10%'),
font_weight='bold')
a = IntText(value=2 * value,
layout=Layout(flex='0 1 auto', width='10%'))
f = IntSlider(value=value, min=b.value, max=a.value,
step=1,
layout=Layout(flex='1 1 auto', width='60%'))
l = IntText(value=f.value,
layout=Layout(flex='0 1 auto', width='10%'),
disabled=True)
link((f, 'value'), (l, 'value'))
def on_min_change(change):
if f.max > change['new']:
f.min = change['new']
f.step = 1
def on_max_change(change):
if f.min < change['new']:
f.max = change['new']
f.step = 1
def on_param_change(change):
self.params[self._method][param] = change['new']
def make_controls(self):
button_begin = Button(icon="fast-backward", layout=Layout(width='100%'))
button_prev = Button(icon="backward", layout=Layout(width='100%'))
button_next = Button(icon="forward", layout=Layout(width='100%'))
button_end = Button(icon="fast-forward", layout=Layout(width='100%'))
#button_prop = Button(description="Propagate", layout=Layout(width='100%'))
#button_train = Button(description="Train", layout=Layout(width='100%'))
self.button_play = Button(icon="play", description="Play", layout=Layout(width="100%"))
refresh_button = Button(icon="refresh", layout=Layout(width="25%"))
self.position_text = IntText(value=0, layout=Layout(width="100%"))
self.control_buttons = HBox([
button_begin,
button_prev,
#button_train,
self.position_text,
button_next,
button_end,
self.button_play,
refresh_button
], layout=Layout(width='100%', height="50px"))
length = (len(self.dataset.train_inputs) - 1) if len(self.dataset.train_inputs) > 0 else 0
self.control_slider = IntSlider(description="Dataset index",
continuous_update=False,
min=0,
max=max(length, 0),
if self.asynchronous:
return None
try:
from ipywidgets import Layout, VBox, HBox, IntText, Button, HTML, Accordion
except ImportError:
self._cached_widget = None
return None
layout = Layout(width="150px")
title = HTML("<h2>YarnCluster</h2>")
status = HTML(self._widget_status(), layout=Layout(min_width="150px"))
request = IntText(0, description="Workers", layout=layout)
scale = Button(description="Scale", layout=layout)
minimum = IntText(0, description="Minimum", layout=layout)
maximum = IntText(0, description="Maximum", layout=layout)
adapt = Button(description="Adapt", layout=layout)
accordion = Accordion(
[HBox([request, scale]), HBox([minimum, maximum, adapt])],
layout=Layout(min_width="500px"),
)
accordion.selected_index = None
accordion.set_title(0, "Manual Scaling")
accordion.set_title(1, "Adaptive Scaling")
@adapt.on_click
def adapt_cb(b):