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

Added support for Swarm Mode #344

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8e17313
added support for swarm mode
filopedraz Sep 1, 2023
29b1cdd
stable petals release fixed version
filopedraz Sep 6, 2023
f9e02fd
solved conflicts
filopedraz Sep 19, 2023
f1f029b
Fix style + add PETALS tag
Janaka-Steph Sep 19, 2023
66ec10a
Merge pull request #1 from Janaka-Steph/petals-swarm
filopedraz Sep 19, 2023
e4f2516
Merge branch 'main' into feat/swarm-mode
filopedraz Oct 9, 2023
ed72704
Merge branch 'feat/swarm-mode' of github.com:filopedraz/prem-app into…
filopedraz Oct 9, 2023
daa95ee
updated small fix readme
filopedraz Oct 9, 2023
2dc2f49
show swarm mode only on macos
nsosio Oct 10, 2023
35576fb
added num_blocks parameter; start petals does not work
nsosio Oct 10, 2023
5a05001
clean up
nsosio Oct 10, 2023
eb72a0f
bugfix
nsosio Oct 10, 2023
7315bfe
added hardcoded model selection
nsosio Oct 10, 2023
6d375d3
added model selection
nsosio Oct 11, 2023
e353f94
added username from whomai (with prem-app as fallback)
nsosio Oct 11, 2023
e3117bd
removed max val for num blocks
nsosio Oct 12, 2023
81611a6
build fixed
nsosio Oct 12, 2023
71e3f9b
added public name parameter (default prem-app)
nsosio Oct 13, 2023
0b3f945
moved petals swarm to sidecar
nsosio Oct 13, 2023
d733d93
fix: supports Apple Silicon and little UI tweaks
tiero Oct 16, 2023
cf2b920
moved petals sidecar script to scripts; bugfix in SwarmMode
nsosio Oct 16, 2023
1f46717
added get_username tauri command
nsosio Oct 17, 2023
8dbca3e
added swarm-mode only for aarch64
nsosio Oct 17, 2023
e6aea1d
renamed petals binary from petals-aarch64-apple-darwin to petals-univ…
nsosio Oct 18, 2023
c6670fe
CI: workflow tidy
casperdcl Oct 18, 2023
e2a23d4
build_petals: parameterise for arches
casperdcl Oct 18, 2023
1075901
CI: build petals
casperdcl Oct 18, 2023
dfccace
CI: temp PR build
casperdcl Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Let us know which Model / Feature you wanna see in Prem [here](https://feedback.
- [Docker](https://docs.docker.com/engine/install/)
- [Tauri](https://tauri.app/v1/guides/getting-started/prerequisites#installing)

### Run the app with Tauri
### Run the app with Tauri (Desktop App)

> Make sure to remove any value in the `.env` file.

Expand All @@ -104,7 +104,7 @@ npm i
npm run tauri dev
```

### Run the app with React
### Run the app with React (Browser App)

```bash
# run the daemon
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@
"infra:down": "bash ./scripts/down.sh",
"infra:up": "bash ./scripts/up.sh",
"lint": "yarn eslint && yarn prettier --check",
"prebuild": "yarn build_petals",
"prettier": "prettier --write src/",
"prettier:check": "prettier --check src/",
"preview": "vite preview",
"tauri": "tauri"
"tauri": "tauri",
"build_petals": "./src-tauri/petals/build_petals_sidecar.sh"
nsosio marked this conversation as resolved.
Show resolved Hide resolved
},
"type": "module",
"version": "0.0.30"
Expand Down
96 changes: 11 additions & 85 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
version = "1.0"

[dependencies.tauri]
features = ["updater", "system-tray", "process-exit", "dialog-all", "path-all", "shell-all"]
features = [ "shell-sidecar", "updater", "system-tray", "process-exit", "dialog-all", "path-all", "process-command-api"]
version = "1.3"

[features]
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/petals/build_petals_sidecar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Set the paths to the Python script, requirements file, and bash script
TAURI_PATH="$(pwd)/src-tauri"
PYTHON_SCRIPT_PATH="${TAURI_PATH}/petals/run_petals.py"
REQUIREMENTS_FILE_PATH="${TAURI_PATH}/petals/requirements.txt"
BUILD_SIDE_SCRIPT_PATH="${TAURI_PATH}/petals/build_petals_sidecar.sh"
DIST_PATH="${TAURI_PATH}/bin/python"

# Create a Python virtual environment
python3 -m venv prem

# Activate the virtual environment
source prem/bin/activate

# Install the necessary packages
pip install -r $REQUIREMENTS_FILE_PATH

# Package the Python script
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
Copy link
Contributor

@tiero tiero Oct 16, 2023

Choose a reason for hiding this comment

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

This will not work on all architectures, please build one for each architecture

Suggested change
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-aarch64-apple-darwin

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will not be enough. If is not possible to make an universal binary with single name, we must package both in the App

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

If we manage to make an universal binary, we should them call it petals-universal-apple-darwin otherwsie when you will be up to compile

       Error failed to bundle project: Failed to copy external binaries: Failed to copy external binaries: path matching bin/python/petals-universal-apple-darwin not found.: path matching bin/python/petals-universal-apple-darwin not found.

Copy link
Contributor

Choose a reason for hiding this comment

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

if not possible to have universal binary, we must also change how we build the desktop app and file naming (splitting Apple SIlicon and Apple Intel) on website, documentations etc..

Copy link
Contributor

@casperdcl casperdcl Oct 16, 2023

Choose a reason for hiding this comment

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

universal bin may or may not be possible1:

Suggested change
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean --target-arch universal2 -n petals-universal-apple-darwin

plus tauri build --target universal-apple-darwin23

Note, however, that this increases your bundle size significantly4

Footnotes

  1. https://pyinstaller.org/en/stable/feature-notes.html#macos-multi-arch-support

  2. https://tauri.app/v1/api/cli/#build

  3. https://github.com/premAI-io/prem-app/blob/a7df7ed5c915dd0fcd79525cb78314a3e7b19faf/.github/workflows/on-tag.yaml#L97

  4. https://tauri.app/v1/guides/building/macos/#binary-targets


# Deactivate the virtual environment
deactivate

rm -r "$(pwd)/prem"
2 changes: 2 additions & 0 deletions src-tauri/petals/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
petals==2.2.0
pyinstaller==6.0.0
16 changes: 16 additions & 0 deletions src-tauri/petals/run_petals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import argparse
import os
import subprocess

def run_command(num_blocks, public_name, model):
command = f"/usr/bin/python3 -m petals.cli.run_server --num_blocks {num_blocks} --public_name {public_name} {model}"
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
output, error = process.communicate()

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--num_blocks', type=int, required=True)
parser.add_argument('--public_name', type=str, required=True)
parser.add_argument('--model', type=str, required=True)
args = parser.parse_args()
run_command(args.num_blocks, args.public_name, args.model)
Loading