# check out https://dash.plotly.com/ for documentation
# And check out https://py.cafe/maartenbreddels for more examples
from dash import Dash, Input, Output, callback, dcc, html
import sys
import sysconfig
import site
site.getusersitepackages = lambda: "/"
print( sys.prefix,
sys.base_prefix,
sys.exec_prefix,
sys.base_exec_prefix,sysconfig.get_paths().values(),
*site.getsitepackages(),
site.getusersitepackages())
# check out https://solara.dev/ for documentation
# or https://github.com/widgetti/solara/
# And check out https://py.cafe/maartenbreddels for more examples
import sys
import grpclib
sys.modules['grpclib'] = grpclib
sys.modules['grpclib.client'] = grpclib
sys.modules['grpclib.const'] = grpclib
sys.modules['grpclib.config'] = grpclib
sys.modules['grpclib.events'] = grpclib
sys.modules['grpclib.exceptions'] = grpclib
sys.modules['grpclib.protocol'] = grpclib
import synchronicity.synchronizer
synchronicity.synchronizer.Synchronizer._start_loop = lambda self: None
import asyncio
# loop = asyncio.get_event_loop()
# synchronicity.synchronizer.Synchronizer._get_loop = lambda self, start=False: loop
# def _run_function_sync(self, coro, interface, original_func):
# print(coro, interface, original_func)
# synchronicity.synchronizer.Synchronizer._run_function_sync = _run_function_sync
# from synchronicity import Synchronizer
# synchronizer = Synchronizer()
# @synchronizer.create_blocking
# async def f(x):
# await asyncio.sleep(1.0)
# return x**2
# # Running f in a synchronous context blocks until the result is available
# print("call it")
# ret = f(42) # Blocks
# print('f(42) =', ret)
import modal
import modal
app = modal.App("example-get-started")
@app.function()
def square(x):
print("This code is running on a remote worker!")
return x**2
@app.local_entrypoint()
def main():
print("the square is", square.remote(42))
app = Dash(__name__)
md = """
# Dash demo
See [The dash examples index](https://dash-example-index.herokuapp.com/) for more examples.
"""
app.layout = html.Div(
children=[
dcc.Markdown(children=md, link_target="_blank"),
dcc.Dropdown(id="dropdown", options=["red", "green", "blue", "orange"]),
dcc.Markdown(id="markdown", children=["## Hello World"]),
]
)
@callback(
Output("markdown", "style"),
Input("dropdown", "value"),
)
def update_markdown_style(color):
print(square.remote(2))
return {"color": color}