Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: no frontend build in repo #5253

Merged
merged 9 commits into from
Dec 11, 2023
Merged

Conversation

psychedelicious
Copy link
Collaborator

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Description

I think it's time to remove the frontend build from the repo.

The intention was to allow contributors to work on the python side of things without needing to worry about the client.

While this is a nice sentiment, it is problematic:

  • The build is rarely current on main, which means if you run on main, you have no guarantee that the frontend is compatible with the backend
  • When creating a release, you have to carefully build the frontend and then commit it
  • Contributors (both new and familiar) get tripped up trying to run the app in "dev" mode
  • End-users are encouraged to just clone main, which is deeply unsafe for them - main is inherently unstable, and it's possible their database could get borked with an over-eager git pull
  • There's additional maintenance burden for frontend contributors

It is for reasons like these that including builds in a repo is not a common practice.

This PR does two things:

  • Updates create_installer.sh to build the frontend & makes some minor QoL improvements to the script
  • Remove the frontend from the repo

Impact to contributors

If you want to run the app on main, you need to install the frontend toolchain. This currently consists of nodejs and pnpm (a modern package manager with a terrible name that has replaced yarn due to technical issues with yarn):

With that installed, you have two options to run the app:

  • Build the frontend locally with pnpm build, run the server per usual, and access the app at localhost:9090
  • Run the frontend in dev mode with pnpm dev, run the server per usual, and access the app at localhost:5173

create_installer.sh changes

See the commit for details, but in briefly, this script now builds the frontend before creating the installer.

If there is already a frontend build but you still want to recreate the installer, say no when asked if you want to rebuild the frontend.

You must have nodejs and pnpm installed to create an installer.

Related Tickets & Documents

This has been a recurring discussion since the beginning of the project, so there may be tickets, but I don't know where.

QA Instructions, Screenshots, Recordings

  • Run the installer script, taking care to not push tags when prompted!, and building the frontend
  • Create a fresh venv, activate it
  • Unzip the installer, and install the .whl with pip install path/to/wheel.whl
  • Run the app with invokeai-web

I've done this a bunch of times and it works fine.

@psychedelicious psychedelicious force-pushed the feat/ui/add-eslint-unused-imports branch from 7f3c9d0 to bbd63a0 Compare December 9, 2023 05:10
Base automatically changed from feat/ui/add-eslint-unused-imports to main December 9, 2023 05:12
In other words, build frontend when creating installer.

Changes to `create_installer.sh`

- If `python` is not in `PATH` but `python3` is, alias them (well, via function). This is needed on some machines to run the installer without symlinking to `python3`.
- Make the messages about pushing tags clearer. The script force-pushes, so it's possible to accidentally take destructive action. I'm not sure how to otherwise prevent damage, so I just added a warning.
- Print out `pwd` when prompting about being in the `installer` dir.
- Rebuild the frontend - if there is already a frontend build, first checks if the user wants to rebuild it.
- Checks for existence of `../build` dir before deleting - if the dir doesn't exist, the script errors and exits at this point.
- Format and spell check.

Other changes:

- Ignore `dist/` folder.
- Delete `dist/`.

**Note: you may need to use `git rm --cached invokeai/app/frontend/web/dist/` if git still wants to track `dist/`.**
More accurate/clearer messages
Using `-f` is functionally equivalent to first checking if the dir exists before removing it. We just want to ensure the build dir doesn't exists.
- Color outputs
- Clarify messages
- Do not offer to use existing frontend build (insurance - prevents accidentally using old build)
Potentially confusing and not useful
Copy link
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@psychedelicious psychedelicious merged commit c5c975c into main Dec 11, 2023
7 checks passed
@psychedelicious psychedelicious deleted the feat/no-frontend-build-in-repo branch December 11, 2023 01:30
@rvdd1962
Copy link

Bless you for your work on this one, thx so much @psychedelicious

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants