mirror of
https://github.com/trycua/computer.git
synced 2026-01-04 04:19:57 -06:00
118 lines
2.7 KiB
Plaintext
118 lines
2.7 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Computer Server\n",
|
|
"\n",
|
|
"This notebook demonstrates how to host the server used by Computer."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Installation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"!pip install cua-computer-server"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# If locally installed, use this instead:\n",
|
|
"import os\n",
|
|
"\n",
|
|
"os.chdir('../libs/computer-server')\n",
|
|
"!pdm install\n",
|
|
"!pdm build\n",
|
|
"\n",
|
|
"!pip uninstall cua-computer-server -y\n",
|
|
"!pip install ./dist/cua_computer_server-0.1.0-py3-none-any.whl --force-reinstall"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Start the Computer server"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"==> Starting computer-server on 0.0.0.0:8000...\n",
|
|
"Starting computer-server on 0.0.0.0:8000...\n",
|
|
"\u001b[32mINFO\u001b[0m: Started server process [\u001b[36m65480\u001b[0m]\n",
|
|
"\u001b[32mINFO\u001b[0m: Waiting for application startup.\n",
|
|
"\u001b[32mINFO\u001b[0m: Application startup complete.\n",
|
|
"\u001b[32mINFO\u001b[0m: Uvicorn running on \u001b[1mhttp://0.0.0.0:8000\u001b[0m (Press CTRL+C to quit)\n",
|
|
"^C\n",
|
|
"\u001b[32mINFO\u001b[0m: Shutting down\n",
|
|
"\u001b[32mINFO\u001b[0m: Waiting for application shutdown.\n",
|
|
"\u001b[32mINFO\u001b[0m: Application shutdown complete.\n",
|
|
"\u001b[32mINFO\u001b[0m: Finished server process [\u001b[36m65480\u001b[0m]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import os\n",
|
|
"# os.chdir('../../scripts')\n",
|
|
"\n",
|
|
"! ./run_computer_server.sh\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Synchronous usage\n",
|
|
"from computer_server import Server\n",
|
|
"\n",
|
|
"server = Server(port=8000)\n",
|
|
"server.start() # Blocks until stopped"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.7"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|