Skip to content

Commit 1e3b85d

Browse files
docs: Add codespaces doc (#5044)
* Add codespaces doc Signed-off-by: Sherlock113 <sherlockxu07@gmail.com> * ci: auto fixes from pre-commit.ci For more information, see https://pre-commit.ci --------- Signed-off-by: Sherlock113 <sherlockxu07@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 787af5f commit 1e3b85d

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed
Loading
Loading
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
=======================
2+
Develop with Codespaces
3+
=======================
4+
5+
Codespaces provide a cloud-based development environment that allows you to run AI applications directly on BentoCloud as you develop. With access to various instance types, including GPUs, Codespaces make it easy to develop multi-Service, GPU-powered applications.
6+
7+
By connecting your local IDE to a remote Codespace, you can see real-time changes on BentoCloud, as the Codespace automatically hot-reloads when it detects local updates. This ensures your development environment mirrors production, so you can build with confidence.
8+
9+
Create a Codespace
10+
------------------
11+
12+
1. Navigate to the directory where your ``bentofile.yaml`` file is located. You can use the :doc:`Quickstart project </get-started/quickstart>` as an example.
13+
2. Run the following command to create a Codespace:
14+
15+
.. code-block:: bash
16+
17+
bentoml code
18+
19+
3. (Optional) If your project requires secure environment variables like API keys, we recommend you create :doc:`secrets </bentocloud/how-tos/manage-secrets>` for them. For example:
20+
21+
.. code-block:: bash
22+
23+
bentoml secret create huggingface HF_TOKEN=<your_hf_token>
24+
bentoml code --secret huggingface
25+
26+
4. Follow the on-screen instructions to create a new Codespace (or attach to an existing one) as prompted. Once created, you can view it in the **Codespaces** section of BentoCloud.
27+
28+
.. image:: ../../_static/img/bentocloud/how-to/codespaces/codespace-on-bentocloud.png
29+
30+
Test your application
31+
---------------------
32+
33+
Once the Codespace is up and running, you can test your application by calling its exposed endpoint.
34+
35+
While developing with your Codespace, the following changes will be automatically synchronized between your local environment and the Codespace. This means any local code updates will be reflected in the remote Codespace, automatically triggering a reload.
36+
37+
- BentoML Service code, including adding or deleting Services
38+
- Models
39+
- System packages
40+
- Python requirements
41+
42+
Codespace logs will stream directly to your terminal, giving you real-time feedback on your application's performance. You can also debug the application using the provided endpoint URL on the Codespace details page.
43+
44+
Note that the following changes cannot be synchronized:
45+
46+
- Python version (Codespaces currently use Python 3.11)
47+
- Base image and Docker options
48+
49+
Build your Bento
50+
----------------
51+
52+
Once development is complete, you can build your Bento directly from a Codespace. To do this, click the **Build Bento** button.
53+
54+
.. image:: ../../_static/img/bentocloud/how-to/codespaces/codespace-detail-page.png
55+
56+
After the build is successful, you can view the Bento and create a Deployment with it.
57+
58+
After development
59+
-----------------
60+
61+
To exit the Codespace from your terminal, press ``Ctrl+C``. Note that this **DOES NOT** terminate the remote Codespace automatically. To terminate a remote Codespace, run the following command:
62+
63+
.. code-block:: bash
64+
65+
bentoml deployment terminate <codespace_name>
66+
67+
Reattach to an existing Codespace
68+
---------------------------------
69+
70+
To reattach to a previously created Codespace, use the following command:
71+
72+
.. code-block:: bash
73+
74+
bentoml code --attach <codespace_name>
75+
76+
This will synchronize the remote Codespace with your current local code.

docs/source/bentocloud/how-tos/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Read how-to guides to explore the key features of BentoCloud.
3333

3434
Run inference with Deployments.
3535

36+
.. grid-item-card:: Develop with Codespaces
37+
:link: codespaces
38+
:link-type: doc
39+
40+
Connect your local IDE with a cloud-based development environment, which reflects code changes in real time.
41+
3642
.. grid-item-card:: Autoscaling
3743
:link: autoscaling
3844
:link-type: doc
@@ -78,6 +84,7 @@ Read how-to guides to explore the key features of BentoCloud.
7884
configure-deployments
7985
manage-deployments
8086
call-deployment-endpoints
87+
codespaces
8188
autoscaling
8289
manage-access-token
8390
manage-secrets

0 commit comments

Comments
 (0)