You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributing/dev-environment.md
+31-51Lines changed: 31 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
1
# Dev Environment
2
2
3
-
To make changes to Invoke's backend, frontend, or documentation, you'll need to set up a dev environment.
3
+
To make changes to Invoke's backend, frontend or documentation, you'll need to set up a dev environment.
4
4
5
-
If you just want to use Invoke, you should use the [installer][installer link].
5
+
If you only want to make changes to the docs site, you can skip the frontend dev environment setup as described in the below guide.
6
6
7
-
!!! info "Why do I need the frontend toolchain?"
8
-
9
-
The repo doesn't contain a build of the frontend. You'll be responsible for rebuilding it every time you pull in new changes, or run it in dev mode (which incurs a substantial performance penalty).
7
+
If you just want to use Invoke, you should use the [launcher][launcher link].
10
8
11
9
!!! warning
12
10
@@ -17,84 +15,66 @@ If you just want to use Invoke, you should use the [installer][installer link].
17
15
## Setup
18
16
19
17
1. Run through the [requirements][requirements link].
18
+
20
19
2.[Fork and clone][forking link] the [InvokeAI repo][repo link].
20
+
21
21
3. Create an directory for user data (images, models, db, etc). This is typically at `~/invokeai`, but if you already have a non-dev install, you may want to create a separate directory for the dev install.
22
-
4. Create a python virtual environment inside the directory you just created:
23
22
24
-
```sh
25
-
python3 -m venv .venv --prompt InvokeAI-Dev
26
-
```
23
+
4. Follow the [manual install][manual install link] guide, with some modifications to the install command:
27
24
28
-
5. Activate the venv (you'll need to do this every time you want to run the app):
25
+
- Use `.` instead of `invokeai`to install from the current directory.
29
26
30
-
```sh
31
-
source .venv/bin/activate
32
-
```
27
+
- Add `-e` after the `install` operation to make this an [editable install][editable install link]. That means your changes to the python code will be reflected when you restart the Invoke server.
33
28
34
-
6. Install the repo as an [editable install][editable install link]:
29
+
- When installing the `invokeai` package, add the `dev`, `test` and `docs` package options to the package specifier. You may or may not need the `xformers` option - follow the manual install guide to figure that out. So, your package specifier will be either `".[dev,test,docs]"` or `".[dev,test,docs,xformers]"`. Note the quotes!
30
+
31
+
With the modifications made, the install command should look something like this:
Refer to the [manual installation][manual install link] instructions for more determining the correct install options. `xformers` is optional, but `dev` and `test` are not.
37
+
5. At this point, you should have Invoke installed, a venv set up and activated, and the server running. But you will see a warning inthe terminal that no UI was found. If you go to the URL for the server, you won't get a UI.
41
38
42
-
7. Install the frontend dev toolchain:
39
+
This is because the UI build is not distributed with the source code. You need to build it manually. End the running server instance.
- [`pnpm`](https://pnpm.io/8.x/installation) (must be v8 - not v9!)
41
+
If you only want to edit the docs, you can stop here and skip to the **Documentation** section below.
46
42
47
-
8. Do a production build of the frontend:
43
+
6. Install the frontend dev toolchain:
48
44
49
-
```sh
50
-
cd PATH_TO_INVOKEAI_REPO/invokeai/frontend/web
51
-
pnpm i
52
-
pnpm build
53
-
```
45
+
- [`nodejs`](https://nodejs.org/) (v20+)
46
+
47
+
- [`pnpm`](https://pnpm.io/8.x/installation) (must be v8 - not v9!)
54
48
55
-
9. Start the application:
49
+
7. Do a production build of the frontend:
56
50
57
51
```sh
58
-
cd PATH_TO_INVOKEAI_REPO
59
-
python scripts/invokeai-web.py
52
+
cd <PATH_TO_INVOKEAI_REPO>/invokeai/frontend/web
53
+
pnpm i
54
+
pnpm build
60
55
```
61
56
62
-
10. Access the UI at `localhost:9090`.
57
+
8. Restart the server and navigate to the URL. You should get a UI. After making changes to the python code, restart the server to see those changes.
63
58
64
59
## Updating the UI
65
60
66
-
You'll need to run `pnpm build` every time you pull in new changes. Another option is to skip the build and instead run the app in dev mode:
61
+
You'll need to run `pnpm build` every time you pull in new changes.
62
+
63
+
Another option is to skip the build and instead run the UI in dev mode:
67
64
68
65
```sh
69
66
pnpm dev
70
67
```
71
68
72
-
This starts a dev server at `localhost:5173`, which you will use instead of `localhost:9090`.
69
+
This starts a vite dev server for the UI at `127.0.0.1:5173`, which you will use instead of `127.0.0.1:9090`.
73
70
74
-
The dev mode is substantially slower than the production build but may be more convenient if you just need to test things out.
71
+
The dev mode is substantially slower than the production build but may be more convenient if you just need to test things out. It will hot-reload the UI as you make changes to the frontend code. Sometimes the hot-reload doesn't work, and you need to manually refresh the browser tab.
75
72
76
73
## Documentation
77
74
78
-
The documentation is built with `mkdocs`. To preview it locally, you need a additional set of packages installed.
79
-
80
-
```sh
81
-
# after activating the venv
82
-
pip install -e ".[docs]"
83
-
```
84
-
85
-
Then, you can start a live docs dev server, which will auto-refresh when you edit the docs:
86
-
87
-
```sh
88
-
mkdocs serve
89
-
```
90
-
91
-
On macOS and Linux, there is a `make` target for this:
92
-
93
-
```sh
94
-
make docs
95
-
```
75
+
The documentation is built with `mkdocs`. It provides a hot-reload dev server for the docs. Start it with `mkdocs serve`.
0 commit comments