Spaces:
Running
Running
Update the org card (#5)
Browse files- Update the org card (bab9d5282181c9088a842057fb65612a9a62ab78)
- Fix casing (1cce611bf12daa4a9983dea374073a7554a79b90)
- Warn about changes not persisted (40f5e041c6e7a793be298ae5a3ca1f90286044e1)
README.md
CHANGED
|
@@ -18,45 +18,105 @@ pinned: false
|
|
| 18 |
|
| 19 |
# Spaces Dev Mode (feature preview)
|
| 20 |
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/wSfCELm8WoY_EFhj8l1MM.png" style="max-width: 500px;">
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
Go to your Space's settings and click on "Enable dev mode".
|
| 34 |
|
| 35 |
-

|
| 48 |
- `curl`, `wget` and `procps` (required by the VS Code server process)
|
| 49 |
-
- `git` and `git-lfs` to be able to commit and push changes from your
|
| 50 |
|
| 51 |
-
2. Your application code must be located in the `/app` folder for the
|
| 52 |
|
| 53 |
3. The `/app` folder must be owned by the user with uid `1000` to allow you to make changes to the code.
|
| 54 |
|
| 55 |
4. The Dockerfile must contain a `CMD` instruction for startup. Checkout [Docker's documentation](https://docs.docker.com/reference/dockerfile/#cmd) about the `CMD` instruction for more details.
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
### Example of a compatible Dockerfile
|
| 58 |
|
| 59 |
-
This is an example of a Dockerfile compatible with Spaces
|
| 60 |
|
| 61 |
It installs the required packages with `apt-get`, along with a couple more for developer convenience (namely: `top`, `vim` and `nano`).
|
| 62 |
It then starts a NodeJS application from `/app`.
|
|
|
|
| 18 |
|
| 19 |
# Spaces Dev Mode (feature preview)
|
| 20 |
|
| 21 |
+
## About Spaces
|
| 22 |
|
| 23 |
+
Spaces offer a simple way to host ML demos and apps on your profile or your organization's profile.
|
| 24 |
+
In essence, a Space is a Docker container that runs your application.
|
| 25 |
+
|
| 26 |
+
Learn more about Spaces here: <a href="https://huggingface.co/docs/hub/spaces" target="_blank">https://huggingface.co/docs/hub/spaces</a>.
|
| 27 |
+
|
| 28 |
+
## Spaces Dev Mode
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
Whenever your commit some changes to your Space repo, the underlying Docker image gets rebuilt, and then a new virtual machine is provisioned to host the new container.
|
| 32 |
+
|
| 33 |
+
The Dev Mode allows you to update your Space much quicker by overriding the Docker image.
|
| 34 |
+
|
| 35 |
+
The Dev Mode Docker image starts your application as a sub-process, allowing you to restart it without stopping the Space container itself.
|
| 36 |
+
It also starts a VS Code server and a SSH server in the background for you to connect to the Space.
|
| 37 |
+
|
| 38 |
+
The ability to connect to the running Space unlocks several use cases:
|
| 39 |
+
- You can make changes to the app code without the Space rebuilding everytime
|
| 40 |
+
- You can debug a running application and monitor resources live
|
| 41 |
+
|
| 42 |
+
Overall it makes developing and experimenting with Spaces much faster by skipping the Docker image rebuild phase.
|
| 43 |
+
|
| 44 |
+
## Interface
|
| 45 |
+
|
| 46 |
+
Once the Dev Mode is enabled on your Space, you should see a modal like the following.
|
| 47 |
|
| 48 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/5f17f0a0925b9863e28ad517/wSfCELm8WoY_EFhj8l1MM.png" style="max-width: 500px;">
|
| 49 |
|
| 50 |
+
The application does not restart automatically when you change the code. For your changes to appear in the Space, you need to use the `Refresh` button that will restart the app.
|
| 51 |
+
|
| 52 |
+
<div class="alert alert-warning">
|
| 53 |
+
If you're using the Streamlit or Gradio SDK, or if your application is Pyhton-based, note that requirements are not installed automatically.
|
| 54 |
+
You will need to manually run `pip install` from VS Code or SSH.
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
### Persisting changes
|
| 58 |
+
|
| 59 |
+
<div class="alert alert-warning">
|
| 60 |
+
The changes you make when the Dev Mode is enabled are not persisted to the Space repo automatically.
|
| 61 |
+
By default, they will be discarded when the Dev Mode is disabled or when the Space goes to sleep.
|
| 62 |
+
</div>
|
| 63 |
+
If you wish to persist changes made while the Dev Mode is enabled, you need to use `git` from inside the Space container (using VS Code or SSH). For example:
|
| 64 |
+
|
| 65 |
+
```shell
|
| 66 |
+
# Add changes and commit them
|
| 67 |
+
git add .
|
| 68 |
+
git commit -m "Persist changes from Dev Mode"
|
| 69 |
+
|
| 70 |
+
# Push the commit to persist them in the repo
|
| 71 |
+
git push
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
The modal will display a warning if you have uncommitted or unpushed changes in the Space:
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+

|
| 78 |
|
| 79 |
+
### How to enable the Dev Mode
|
| 80 |
|
| 81 |
+
Go to your Space's settings and click on "Enable Dev Mode".
|
| 82 |
|
|
|
|
| 83 |
|
| 84 |
+

|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
You can also enable the Dev Mode from the quick actions dropdown.
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+

|
| 91 |
+
|
| 92 |
|
| 93 |
## Limitations
|
| 94 |
|
| 95 |
+
The Dev Mode is currently not available for static Spaces. Docker Spaces also have some additional requirements.
|
| 96 |
|
| 97 |
### Docker Spaces
|
| 98 |
|
| 99 |
+
Dev Mode is supported for Docker Spaces. However, your Space needs to comply with the following rules for the Dev Mode to work properly.
|
| 100 |
|
| 101 |
1. The following packages must be installed:
|
| 102 |
|
| 103 |
- `bash` (required to establish SSH connections)
|
| 104 |
- `curl`, `wget` and `procps` (required by the VS Code server process)
|
| 105 |
+
- `git` and `git-lfs` to be able to commit and push changes from your Dev Mode environment
|
| 106 |
|
| 107 |
+
2. Your application code must be located in the `/app` folder for the Dev Mode daemon to be able to detect changes.
|
| 108 |
|
| 109 |
3. The `/app` folder must be owned by the user with uid `1000` to allow you to make changes to the code.
|
| 110 |
|
| 111 |
4. The Dockerfile must contain a `CMD` instruction for startup. Checkout [Docker's documentation](https://docs.docker.com/reference/dockerfile/#cmd) about the `CMD` instruction for more details.
|
| 112 |
|
| 113 |
+
The Dev Mode works well when the base image is debian-based (eg, ubuntu).
|
| 114 |
+
|
| 115 |
+
More exotic linux distros (eg, alpine) are not tested and the Dev Mode is not guaranteed to work on them.
|
| 116 |
+
|
| 117 |
### Example of a compatible Dockerfile
|
| 118 |
|
| 119 |
+
This is an example of a Dockerfile compatible with Spaces Dev Mode.
|
| 120 |
|
| 121 |
It installs the required packages with `apt-get`, along with a couple more for developer convenience (namely: `top`, `vim` and `nano`).
|
| 122 |
It then starts a NodeJS application from `/app`.
|