def multiple_views(build_path, monkeypatch): """Create multiple views app.""" monkeypatch.setattr(App, '_sourcefile', lambda self: 'bowtie.tests.test_multiple') app = App() view1 = View() # pylint: disable=unused-variable assert view1._uuid == 2 # pylint: disable=protected-access view2 = View() view2.add(table) app.add_route(view2, 'view2') app.add(table) app.add_sidebar(ctrl) app.add_sidebar(ctrl2) app.subscribe(callback, ctrl.on_change) app.subscribe(callback, ctrl2.on_click) app._build() # pylint: disable=protected-access env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) yield server.kill()
def components(build_path, monkeypatch): """App with all components.""" monkeypatch.setattr(App, '_sourcefile', lambda self: 'bowtie.tests.test_components') controllers, visuals = create_components() app = App(rows=len(visuals)) for controller in controllers: # pylint: disable=protected-access assert COMPONENT_REGISTRY[controller._uuid] == controller app.add_sidebar(controller) for vis in visuals: # pylint: disable=protected-access assert COMPONENT_REGISTRY[vis._uuid] == vis app.add(vis) # pylint: disable=protected-access app._build() env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) yield server.kill()
def test_components(chrome_driver, build_path): """Tests plotly.""" app = App(rows=len(visuals), directory=build_path) for controller in controllers: app.add_sidebar(controller) for vis in visuals: app.add(vis) app.build() env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) chrome_driver.get('http://localhost:9991') chrome_driver.implicitly_wait(5) logs = chrome_driver.get_log('browser') for log in logs: if log['level'] == 'SEVERE': raise Exception(log['message']) server.kill()
def components(build_reset, monkeypatch): """App with all components.""" controllers, visuals, htmls = create_components() app = App(__name__, rows=len(visuals), sidebar=True) for controller in controllers: # pylint: disable=protected-access assert COMPONENT_REGISTRY[controller._uuid] == controller app.add_sidebar(controller) for vis in visuals: # pylint: disable=protected-access assert COMPONENT_REGISTRY[vis._uuid] == vis app.add(vis) for htm in htmls: # pylint: disable=protected-access assert COMPONENT_REGISTRY[htm._uuid] == htm app.add_sidebar(htm) assert len( COMPONENT_REGISTRY) == len(controllers) + 2 * len(visuals) + len(htmls) # pylint: disable=protected-access app._build() # run second time to make sure nothing weird happens with subsequent builds app._build() with server_check(app) as server: yield server
def main(): from bowtie import App app = App(debug=True) app.add_sidebar(sigma) app.add(mainplot) app.schedule(0.1, walk) return app
def components(build_reset, monkeypatch): """App with all components.""" controllers, visuals, htmls = create_components() app = App(__name__, rows=len(visuals), sidebar=True) for controller in controllers: # pylint: disable=protected-access assert COMPONENT_REGISTRY[controller._uuid] == controller app.add_sidebar(controller) for vis in visuals: # pylint: disable=protected-access assert COMPONENT_REGISTRY[vis._uuid] == vis app.add(vis) for htm in htmls: # pylint: disable=protected-access assert COMPONENT_REGISTRY[htm._uuid] == htm app.add_sidebar(htm) assert len(COMPONENT_REGISTRY) == len(controllers) + 2 * len(visuals) + len(htmls) # pylint: disable=protected-access app._build() # run second time to make sure nothing weird happens with subsequent builds app._build() with server_check(app) as server: yield server
def construct(): from bowtie import App app = App(debug=True) app.add_sidebar(sigma) app.add(mainplot) app.schedule(0.1, walk) app.build()
def test_build(build_path): """Tests the build process.""" reset_uuid() ctrl = Nouislider() viz = Plotly() app = App(directory=build_path) app.add_sidebar(ctrl) app.add(viz) app.subscribe(callback, ctrl.on_change) app.build()
def markdown(build_reset, monkeypatch): """Create markdown and text widgets.""" app = App(__name__, sidebar=True) app.add(mark) app.add_sidebar(side) app.add_sidebar(text) app.subscribe(text.on_change)(write) # pylint: disable=protected-access app._build() with server_check(app) as server: yield server
def test_build(build_reset, monkeypatch): """Tests the build process.""" reset_uuid() ctrl = Nouislider() viz = Plotly() app = App(__name__, sidebar=True) app.add_sidebar(ctrl) app.add(viz) app.subscribe(ctrl.on_change)(callback) # pylint: disable=protected-access app._build()
def markdown(build_reset, monkeypatch): """Create markdown and text widgets.""" app = App(__name__, sidebar=True) app.add(mark) app.add_sidebar(side) app.add_sidebar(text) app.subscribe(text.on_change)(write) # pylint: disable=protected-access app._build() with server_check(app) as server: yield server
def test_build(build_path, monkeypatch): """Tests the build process.""" monkeypatch.setattr(App, '_sourcefile', lambda self: 'bowtie.tests.test_compile') reset_uuid() ctrl = Nouislider() viz = Plotly() app = App() app.add_sidebar(ctrl) app.add(viz) app.subscribe(callback, ctrl.on_change) # pylint: disable=protected-access app._build()
def multiple_views(build_reset, monkeypatch): """Create multiple views app.""" app = App(__name__, sidebar=True) view1 = View() # pylint: disable=unused-variable assert view1._uuid == 2 # pylint: disable=protected-access view2 = View() view2.add(table) app.add_route(view2, 'view2') app.add(table) app.add_sidebar(ctrl) app.add_sidebar(ctrl2) app.subscribe(ctrl.on_change)(app.subscribe(ctrl2.on_click)(callback)) app._build() # pylint: disable=protected-access with server_check(app) as server: yield server
def multiple_views(build_reset, monkeypatch): """Create multiple views app.""" app = App(__name__, sidebar=True) view1 = View() # pylint: disable=unused-variable assert view1._uuid == 2 # pylint: disable=protected-access view2 = View() view2.add(table) app.add_route(view2, 'view2') app.add(table) app.add_sidebar(ctrl) app.add_sidebar(ctrl2) app.subscribe(ctrl.on_change)(app.subscribe(ctrl2.on_click)(callback)) app._build() # pylint: disable=protected-access with server_check(app) as server: yield server
def test_markdown(chrome_driver, build_path): """Test markdown and text widgets.""" app = App(directory=build_path) app.add(mark) app.add_sidebar(side) app.add_sidebar(text) app.subscribe(write, text.on_change) app.build() env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) chrome_driver.get('http://*****:*****@style='grid-area: 1 / 2 / 2 / 3; position: relative;']") assert 'top' in output.text assert 'middle' in output.text assert 'link' in output.text txtctrl.send_keys('apple') time.sleep(1) assert 'apple' in output.text txtctrl.send_keys('banana') time.sleep(1) assert 'apple' in output.text assert 'banana' in output.text server.kill()
def markdown(build_path, monkeypatch): """Create markdown and text widgets.""" monkeypatch.setattr(App, '_sourcefile', lambda self: 'bowtie.tests.test_editor') app = App() app.add(mark) app.add_sidebar(side) app.add_sidebar(text) app.subscribe(write, text.on_change) # pylint: disable=protected-access app._build() env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) yield server.kill()
def plotly(build_path, monkeypatch): """Create plotly app.""" monkeypatch.setattr(App, '_sourcefile', lambda self: 'bowtie.tests.test_plotly') app = App() app.add(viz) app.add_sidebar(ctrl) app.add_sidebar(ctrl2) app.subscribe(callback, ctrl.on_change) app.subscribe(callback, ctrl2.on_click) # pylint: disable=protected-access app._build() env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) yield server.kill()
def test_plotly(chrome_driver, build_path): """Tests plotly.""" app = App(directory=build_path) app.add(viz) app.add_sidebar(ctrl) app.add_sidebar(ctrl2) app.subscribe(callback, ctrl.on_change) app.subscribe(callback, ctrl2.on_click) app.build() env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', '')) server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env) time.sleep(5) chrome_driver.get('http://localhost:9991') chrome_driver.implicitly_wait(5) assert chrome_driver.title == 'Bowtie App' button = chrome_driver.find_element_by_class_name('ant-btn') button.click() points = chrome_driver.find_elements_by_class_name('point') logs = chrome_driver.get_log('browser') for log in logs: if log['level'] == 'SEVERE': raise Exception(log['message']) assert len(points) == 4 server.kill()
def plotly(build_reset, monkeypatch): """Create plotly app.""" app = App(__name__, sidebar=True) app.add(viz) app.add_sidebar(ctrl) app.add_sidebar(ctrl_range) app.add_sidebar(ctrl2) app.subscribe(ctrl.on_change)(app.subscribe(ctrl2.on_click)(callback)) # pylint: disable=protected-access app._build() with server_check(app) as server: yield server
def main(): from bowtie import App app = App(title='Network DownScaler') app.add(sine_plot) app.add_sidebar(upload) app.subscribe(upload_listener, upload.on_upload) app.add_sidebar(scale_factor_input) app.subscribe(update_scale_factor, scale_factor_input.on_change) app.add_sidebar(freq_slider) app.subscribe(slider_listener, freq_slider.on_change) app.add_sidebar(dropdown_src) app.add_sidebar(dropdown_dst) app.subscribe(dropdown_src_listener, dropdown_src.on_change) app.subscribe(dropdown_dst_listener, dropdown_dst.on_change) return app
from bowtie import App from bowtie.control import Nouislider from bowtie.visual import Plotly from bowtie import Pager, cache, command import numpy as np from numpy import random as rng import plotlywrapper as pw app = App(debug=True, sidebar=True) pager = Pager() sigma = Nouislider(start=0., minimum=0.1, maximum=50.) mainplot = Plotly() app.add_sidebar(sigma) app.add(mainplot) def initialize(): cache.save('data', [0.] * 100) @app.subscribe(pager) def upgraph(): data = cache.load('data') value = float(sigma.get()) data.pop(0) data.append(value * rng.randn() + data[-1]) mainplot.do_all(pw.line(data).to_json()) cache.save('data', data)
from bowtie import App from bowtie.control import Nouislider from bowtie.visual import Plotly from bowtie import Pager, cache, command import numpy as np from numpy import random as rng import plotlywrapper as pw app = App(debug=True, sidebar=True) pager = Pager() sigma = Nouislider(start=0., minimum=0.1, maximum=50.) mainplot = Plotly() app.add_sidebar(sigma) app.add(mainplot) def initialize(): cache.save('data', [0.] * 100) @app.subscribe(pager) def upgraph(): data = cache.load('data') value = float(sigma.get()) data.pop(0) data.append(value * rng.randn() + data[-1]) mainplot.do_all(pw.line(data).to_json()) cache.save('data', data)
xdown = Dropdown(labels=attrs, values=attrs) ydown = Dropdown(labels=attrs, values=attrs) zdown = Dropdown(labels=attrs, values=attrs) alphaslider = Slider(start=10, minimum=1, maximum=50) mainplot = Plotly() mplot3 = Plotly() linear = Plotly() table1 = Table() app.columns[0].fraction(2) app.columns[1].fraction(1) app.columns[2].fraction(1) app.add_sidebar(description) app.add_sidebar(Header('X Variable', size=3)) app.add_sidebar(xdown) app.add_sidebar(Header('Y Variable', size=3)) app.add_sidebar(ydown) app.add_sidebar(Header('Z Variable', size=3)) app.add_sidebar(zdown) app.add_sidebar(Header('Alpha Parameter', size=3)) app.add_sidebar(alphaslider) app[0, 0] = mainplot app[0, 1:] = mplot3 app[1, :2] = linear app[1, 2] = table1