|
| 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. |
0 commit comments