Elvis0001 commited on
Commit
afd586a
·
1 Parent(s): 9a4ea8c

Establish verified local OpenPELS environment

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -0
  2. .gitignore +5 -0
  3. README.md +51 -0
  4. restore-local-assets.py +50 -0
  5. run-local.sh +19 -0
.gitattributes CHANGED
@@ -81,3 +81,5 @@ static/assets/LiberationSerif-Regular-DREh6cMU.ttf filter=lfs diff=lfs merge=lfs
81
  static/testbenches/images/c3l.png filter=lfs diff=lfs merge=lfs -text
82
  static/testbenches/images/xfly6s.png filter=lfs diff=lfs merge=lfs -text
83
  static/testbenches/images/xfly8s.png filter=lfs diff=lfs merge=lfs -text
 
 
 
81
  static/testbenches/images/c3l.png filter=lfs diff=lfs merge=lfs -text
82
  static/testbenches/images/xfly6s.png filter=lfs diff=lfs merge=lfs -text
83
  static/testbenches/images/xfly8s.png filter=lfs diff=lfs merge=lfs -text
84
+ docs/topology/2to1_switching_capacitors/figures/nominal_waveforms.png filter=lfs diff=lfs merge=lfs -text
85
+ docs/topology/2to1_switching_capacitors/figures/output_resistance.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ /.venv/
2
+ /.openpels-runtime/
3
+ /local-source/
4
+ __pycache__/
5
+ .DS_Store
README.md CHANGED
@@ -34,3 +34,54 @@ upstream commit df9afb17d88a6925cdbf8a6f87e68175029e8280, under AGPL-3.0-only.
34
  Copyright notices are retained. Complete corresponding source, the dependency
35
  lockfile and reproduction instructions are available through the application's
36
  **Download complete source** footer link (`static/openpels-source.zip`).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  Copyright notices are retained. Complete corresponding source, the dependency
35
  lockfile and reproduction instructions are available through the application's
36
  **Download complete source** footer link (`static/openpels-source.zip`).
37
+
38
+ ## Run locally on macOS
39
+
40
+ From the checkout, install the runtime and restore the public release assets:
41
+
42
+ ```sh
43
+ brew install python@3.12 ngspice
44
+ python3.12 -m venv .venv
45
+ .venv/bin/python -m pip install -r requirements-simulator.txt
46
+ .venv/bin/python restore-local-assets.py
47
+ ./run-local.sh
48
+ ```
49
+
50
+ Open [OpenPELS in Chrome](http://127.0.0.1:8765). Stop a foreground server
51
+ with **Control-C**. Set `PORT=8766` before `./run-local.sh` to use a different
52
+ port. The launcher serves the existing frontend and pins the simulator engine
53
+ to the bundled revision. The asset restore command replaces Git LFS pointers
54
+ with checksum-verified bytes from the matching public Hugging Face revision.
55
+ Git may show these files as modified in a checkout without Git LFS filters.
56
+
57
+ Gallery, analysis, editing and NGSpice use bundled circuit resources. The UI
58
+ requests Google Fonts and has fallback fonts. Browser recovery uses local
59
+ browser storage. NGSpice writes runs and logs to `.openpels-runtime/`.
60
+ The optional **Upload a topology** feature sends the submitted image and token
61
+ directly to Hugging Face Inference Providers. To use it, enter your own token
62
+ with Inference Providers permission under **Vision connection**. The default
63
+ model is `Qwen/Qwen2.5-VL-72B-Instruct`. The local simulator uses the included
64
+ generic SPICE models. There is no database, external storage, or foundry PDK
65
+ required for the local workbench.
66
+
67
+ ## Rebuild the frontend
68
+
69
+ The release contains the built UI in `static/`. The source archive includes the
70
+ editable frontend and reference analysis as sibling directories. To rebuild,
71
+ use Node.js 24 or newer and the archived pnpm version:
72
+
73
+ ```sh
74
+ mkdir -p local-source
75
+ unzip -n static/openpels-source.zip -d local-source
76
+ npm install --prefix .openpels-runtime/toolchain pnpm@11.16.0
77
+ export PATH="$PWD/.openpels-runtime/toolchain/node_modules/.bin:$PWD/.venv/bin:$PATH"
78
+ pnpm --dir local-source/openpels install --frozen-lockfile
79
+ pnpm --dir local-source/openpels build
80
+ .venv/bin/python local-source/openpels/scripts/openpels/build.py
81
+ PORT=8766 OPENPELS_STATIC_DIR="$PWD/local-source/openpels/apps/editor/dist-pe" \
82
+ OPENPELS_RUN_DIR="$PWD/.openpels-runtime/rebuilt" ./run-local.sh
83
+ ```
84
+
85
+ Open [the rebuilt workbench](http://127.0.0.1:8766) while the release build runs
86
+ on port 8765. The source archive also contains the frontend build guide at
87
+ `local-source/openpels/scripts/openpels/README.md`.
restore-local-assets.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Restore Git LFS pointers from the public OpenPELS release backing this checkout."""
3
+
4
+ from concurrent.futures import ThreadPoolExecutor
5
+ from hashlib import sha256
6
+ from pathlib import Path
7
+ import re
8
+ import subprocess
9
+ from tempfile import TemporaryDirectory
10
+ from urllib.parse import quote
11
+
12
+
13
+ ROOT = Path(__file__).resolve().parent
14
+ RELEASE = '9a4ea8ca87f8460e4c72990fbf493f1fd60dc7e0'
15
+ PUBLIC_ASSETS = f'https://huggingface.co/spaces/minjiechen/OpenPELS/resolve/{RELEASE}'
16
+ POINTER = re.compile(rb'version https://git-lfs.github.com/spec/v1\noid sha256:([a-f0-9]{64})\nsize (\d+)\n')
17
+
18
+
19
+ def restore(relative_path):
20
+ path = ROOT / relative_path
21
+ if not path.is_file() or path.is_symlink():
22
+ return False
23
+ with path.open('rb') as stream:
24
+ pointer = POINTER.fullmatch(stream.read(256))
25
+ if pointer is None:
26
+ return False
27
+
28
+ digest, size = pointer.groups()
29
+ with TemporaryDirectory(dir=path.parent) as temporary_directory:
30
+ download = Path(temporary_directory) / 'asset'
31
+ subprocess.run([
32
+ '/usr/bin/curl', '-q', '--fail', '--silent', '--show-error', '--location',
33
+ '--proto', '=https', '--proto-redir', '=https', '--retry', '2',
34
+ '--output', str(download), f'{PUBLIC_ASSETS}/{quote(relative_path)}',
35
+ ], check=True)
36
+ with download.open('rb') as stream:
37
+ actual_digest = sha256(stream.read()).hexdigest().encode()
38
+ if download.stat().st_size != int(size) or actual_digest != digest:
39
+ raise ValueError(f'Git LFS checksum or size differs for {relative_path}')
40
+ download.chmod(path.stat().st_mode & 0o777)
41
+ download.replace(path)
42
+ return True
43
+
44
+
45
+ if __name__ == '__main__':
46
+ tracked_paths = subprocess.check_output(['git', 'ls-files', '-z'], cwd=ROOT)
47
+ paths = filter(None, tracked_paths.decode().split('\0'))
48
+ with ThreadPoolExecutor(max_workers=6) as pool:
49
+ count = sum(pool.map(restore, paths))
50
+ print(f'Restored {count} Git LFS assets.')
run-local.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ cd -- "$(dirname -- "$0")"
5
+ root="$PWD"
6
+ # Homebrew's default paths also cover minimal launchctl environments.
7
+ export PATH="$PATH:/opt/homebrew/bin:/usr/local/bin"
8
+ export PYTHONDONTWRITEBYTECODE=1
9
+
10
+ if [[ ! -x "$root/.venv/bin/python" ]] || ! command -v ngspice >/dev/null; then
11
+ printf '%s\n' 'Install the local dependencies using the README before launching OpenPELS.' >&2
12
+ exit 1
13
+ fi
14
+
15
+ exec "$root/.venv/bin/python" "$root/server.py" \
16
+ --host 127.0.0.1 --port "${PORT:-8765}" \
17
+ --site "${OPENPELS_STATIC_DIR:-$root/static}" \
18
+ --work "${OPENPELS_RUN_DIR:-$root/.openpels-runtime}" \
19
+ --engine "$root/simulator/library/ngspice/studies/xfly6s_xfly8s_c3l_scaled_comparison/gui/xfly_compare_gui.py"