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

Setup progress refactor #1468

Merged

Conversation

RunDevelopment
Copy link
Member

Firstly, nomenclature:

  • The setup process will refer to the process of starting chainner. This includes starting the backed and installing any deps that it might need.
  • An owned backend is a backend process that was spawned by the main process of the app.
  • A borrowed backend is a backend process the frontend connects to in --no-backend mode.

Changes:

  • Removed unused get-ffmpeg ICP channel.
  • Replaced all IPC channels going to the splash screen with a single splash-setup-progress channel.
  • Added a new user-interface-independent way of dealing with user interaction. During the setup process, we might need to tell the user something via a dialog. This just isn't possible in CLI mode, so I had to find a user interaction model that work for both GUI and CLI. My solution to this are interrupts. The basic idea is that an interrupt... interrupts the program and only yields back control after the user has interacted with it.
    Right now, there are 2 types of interrupts: critical error and warning. Critical error will always close the program after being interacted with, while warning will do nothing. More types may be added in the future. Other options for interaction can also be specified.
    Note that interrupts are a declarative format. The one requesting an interrupt is not the one actually performing the interrupt. This allows interrupts to work with both GUI and CLI. To switch from GUI dialogs to CLI prompts, we simply have to change the interrupt listener.
  • Added a new progress API for the setup progress. This makes it easy to change how progress is displayed. The setup progress no longer requires the splash screen for displaying progress. The splash screen is now simply a listener to the progress emitted by the setup process. This makes it easy to swap out the splash screen for something else.
  • The backend new has a /python-info JSON API call. This returns the python info of the current backend server. This python info is now used for borrowed backends.
  • Most of the setup process in now in main/backend/setup.ts.
  • There are 2 types of backend processes now: owned and borrowed. Owned processes are sub processes spawned by the app, while borrowed processes are independent processes simply connected (--no-backend). Both types have make up the BackendProcess interface, which makes it easy to abstract over how the backend was created.
  • The backend new has a /python-info JSON API call. This returns the python info of the current backend server. This python info is now used for borrowed backends. This means that the correct python executable will be used for borrowed backend, which allows you to install/update deps from them with chainner's deps manager.
  • Chainner will no longer check deps integrated python when started with --no-backend. It will simply connect to the borrowed backend and that's it.

Overall, I'm really happy with how this turned out. The new unified BackendProcess API made it easy to extract out the whole setup process into its own file, which made main/main.ts a lot simpler. The new progress API is also really simple and easy to use. The whole architecture around main/main.ts and the setup process feels a lot cleaner now.

@RunDevelopment
Copy link
Member Author

Ah you were right @joeyballentine. I removed stages altogether and replaced it with a simple optional status string. This neatly separates the concerns of the splash screen and the concerns of the ones submitting progress.

@joeyballentine joeyballentine merged commit 01c75c3 into chaiNNer-org:main Jan 11, 2023
@RunDevelopment RunDevelopment deleted the setup-progress-refactor branch January 11, 2023 20:58
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

2 participants