Skip to content

Commit 23b35d8

Browse files
authored
v0.3.0 (#106)
- Fragmentation reporting improvements (largest tensor allocatable) - Tensor details in tensor list - Circular Buffers zoom view - Filtering system for tensor deallocation report - Fix for missing tables for partial support of legacy data
2 parents c1475e5 + 84e157e commit 23b35d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+911
-393
lines changed

.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
ignore = E203, E266, E501, W503, F403, F401
3+
exclude =
4+
.git,
5+
__pycache__,
6+
docs/source/conf.py,
7+
build,
8+
dist
9+
max-complexity = 10
10+
max-line-length = 79

.github/workflows/build-wheels.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build wheel
2+
3+
on:
4+
release:
5+
types: [ 'created', 'edited', 'unpublished' ]
6+
7+
env:
8+
CIBW_BUILD_VERBOSITY: 1
9+
VITE_API_ROOT: api
10+
11+
jobs:
12+
build_wheel:
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Use Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: v22.1.0
20+
- run: npm install
21+
- run: npm run build
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.9
27+
28+
- name: Build wheel and install
29+
run: |
30+
python -m pip install --user --upgrade build
31+
python -m build --wheel
32+
33+
- uses: actions/upload-artifact@v4
34+
with:
35+
name: ttnn_visualizer_${{ github.sha }}
36+
path: ./dist/*.whl
37+
38+
upload-wheel-release:
39+
runs-on: ubuntu-20.04
40+
needs:
41+
build_wheel
42+
steps:
43+
- name: '📦 Upload Release'
44+
run: |
45+
cd ${{github.workspace}}
46+
gh release upload ${{github.event.release.tag_name}} ttnn_visualizer_${{github.sha}}
47+
env:
48+
GITHUB_TOKEN: ${{ github.TOKEN }}
49+
shell: bash

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ id_ed*
3636
/docker/SSH/config
3737

3838
# Backend
39-
/backend/data
39+
backend/ttnn_visualizer/data
40+
backend/ttnn_visualizer/static
41+
/backend/data/*
42+
backend/*egg-info
43+
build
4044
.env

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/ambv/black
5+
rev: stable
6+
hooks:
7+
- id: black
8+
language_version: python3.12
9+
- repo: https://github.com/PyCQA/flake8
10+
rev: 7.1.1
11+
hooks:
12+
- id: flake8

Dockerfile

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ RUN apt-get update \
1515

1616

1717
USER node
18-
19-
20-
2118
COPY --chown=node:node ./package.json package-lock.json index.html ./
2219

2320
RUN npm install
@@ -37,14 +34,15 @@ RUN npm run build
3734

3835
CMD ["bash"]
3936

40-
# # Backend Docker Build
37+
# Backend Docker Build
4138
FROM python:3.12.3-slim-bookworm AS app
4239

4340
WORKDIR /app
4441

4542
ARG UID=1000
4643
ARG GID=1000
4744

45+
# Setup base environment
4846
RUN apt-get update \
4947
&& apt-get install -y --no-install-recommends build-essential curl libpq-dev openssh-client\
5048
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
@@ -53,46 +51,34 @@ RUN apt-get update \
5351
&& useradd --create-home --no-log-init -u "${UID}" -g "${GID}" python \
5452
&& chown python:python -R /app
5553

56-
RUN mkdir -p /public
57-
58-
# Backend Build steps
59-
60-
# ROOTLESS BUILD - WIP
61-
# Currently we can not use the MacOS magic socket as non-root.
62-
# Once this issue is resolved we can replace root with the python user
63-
# To avoid running the container as root we can su -c in the entrypoint
64-
65-
# USER python
66-
67-
COPY --chown=python:python ./backend/requirements.txt ./
54+
# Copy Python setup files / environment if exists
55+
COPY --chown=python:python backend/ttnn_visualizer/requirements.txt ./
6856
COPY --chown=python:python ./.env* /app/
69-
COPY --chown=python:python ./backend/bin ./bin
7057

58+
# Copy and run installation scripts
59+
COPY --chown=python:python ./backend/ttnn_visualizer/bin ./bin
7160
RUN chmod 0755 bin/* && bin/pip3-install
7261

73-
# ARG FLASK_ENV="production"
74-
# ENV PYTHONUNBUFFERED="true" \
75-
# FLASK_ENV="${FLASK_ENV}" \
76-
# PYTHONPATH="." \
77-
# PATH="${PATH}:/home/python/.local/bin" \
78-
# USER="python"
79-
62+
# Copy backend files to image
8063
COPY --chown=python:python ./backend /app/backend
81-
COPY --chown=python:python --from=assets /app/assets/dist /public
8264

83-
RUN mkdir -p /app/backend/data && chmod a+rw /app/backend/data
65+
# Copy the assets rom the frontend build to the public folder in app container
66+
COPY --chown=python:python --from=assets /app/assets/backend/ttnn_visualizer/static /public
67+
68+
# Create directory for user data (reports/etc)
69+
RUN mkdir -p /app/backend/ttnn_visualizer/data && chmod a+rw /app/backend/ttnn_visualizer/data
8470

8571
USER root
8672

8773
ARG FLASK_ENV="production"
8874
ENV PYTHONUNBUFFERED="true" \
8975
FLASK_ENV="${FLASK_ENV}" \
90-
PYTHONPATH="." \
76+
PYTHONPATH="/app/backend/" \
9177
PATH="${PATH}:/root/.local/bin" \
9278
USER="root"
9379

9480
ENTRYPOINT ["/app/bin/docker-entrypoint-web"]
9581

9682
EXPOSE 8000
9783

98-
CMD ["gunicorn", "-c", "backend/config/gunicorn.py", "backend.app:create_app()"]
84+
CMD ["gunicorn", "-c", "backend/ttnn_visualizer/config/gunicorn.py", "ttnn_visualizer.app:create_app()"]

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
graft backend/ttnn_visualizer/static
2+
prune backend/ttnn_visualizer/data

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,9 @@ To run the application you can simply run `docker-compose up web`. To rebuild ad
189189
To use the [provided SSH container](./docker/SSH/README.md) with the compose configuration you can substitute `web` in the above commands for `ssh`. To run the container in the background use `docker-compose up ssh -d`
190190

191191
To connect to this container through the remote connection manager you use the name of the service (`ssh`) as the 'host' and the default SSH port 22.
192+
193+
### Installing as Wheel
194+
195+
Download the wheel file from the [releases page]() and install using `pip install release_name.whl`. After installation
196+
simply run `ttnn-visualizer` to start the application.
197+
File renamed without changes.

backend/app.py renamed to backend/ttnn_visualizer/app.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
from os import environ
44
from pathlib import Path
55

6-
import flask
7-
from dotenv import load_dotenv
86
from flask import Flask
9-
from flask_cors import CORS
7+
import flask
108
from werkzeug.debug import DebuggedApplication
119
from werkzeug.middleware.proxy_fix import ProxyFix
12-
13-
from backend import settings
10+
from flask_cors import CORS
11+
from ttnn_visualizer import settings
12+
from dotenv import load_dotenv
13+
from ttnn_visualizer.database import create_update_database
1414

1515

1616
def create_app(settings_override=None):
17-
from backend.views import api
17+
from ttnn_visualizer.views import api
1818

1919
"""
2020
Create a Flask application using the app factory pattern.
@@ -23,18 +23,18 @@ def create_app(settings_override=None):
2323
:return: Flask app
2424
"""
2525

26-
dotenv_path = Path(__file__).parent.parent.joinpath('.env')
26+
dotenv_path = Path(__file__).parent.parent.joinpath(".env")
2727
if dotenv_path.exists():
2828
load_dotenv(str(dotenv_path))
2929

3030
static_assets_dir = environ.get("STATIC_ASSETS", "/public")
3131
flask_env = environ.get("FLASK_ENV", "development")
3232

3333
app = Flask(__name__, static_folder=static_assets_dir, static_url_path="/")
34-
34+
3535
app.config.from_object(getattr(settings, flask_env))
3636

37-
logging.basicConfig(level=app.config.get('LOG_LEVEL', 'INFO'))
37+
logging.basicConfig(level=app.config.get("LOG_LEVEL", "INFO"))
3838

3939
app.logger.info(f"Starting TTNN visualizer in {flask_env} mode")
4040

@@ -51,14 +51,16 @@ def create_app(settings_override=None):
5151
ACTIVE_DATA_DIRECTORY = app.config["ACTIVE_DATA_DIRECTORY"]
5252

5353
active_db_path = Path(ACTIVE_DATA_DIRECTORY, "db.sqlite")
54+
active_db_path.parent.mkdir(exist_ok=True, parents=True)
5455
empty_db_path = Path(__file__).parent.resolve().joinpath("empty.sqlite")
56+
5557
if not active_db_path.exists():
56-
active_db_path.parent.mkdir(exist_ok=True, parents=True)
5758
shutil.copy(empty_db_path, active_db_path)
5859

5960
extensions(app)
6061

6162
if flask_env == "production":
63+
6264
@app.route("/", defaults={"path": ""})
6365
@app.route("/<path:path>")
6466
def catch_all(path):
@@ -68,7 +70,7 @@ def catch_all(path):
6870

6971

7072
def extensions(app: flask.Flask):
71-
from backend.extensions import flask_static_digest, db, ma
73+
from ttnn_visualizer.extensions import flask_static_digest, db, ma
7274

7375
"""
7476
Register 0 or more extensions (mutates the app passed in).

backend/ttnn_visualizer/appserver.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import pathlib
3+
import sys
4+
5+
from gunicorn.app.wsgiapp import run
6+
7+
app_dir = pathlib.Path(__file__).parent.resolve()
8+
config_dir = app_dir.joinpath("config")
9+
static_assets_dir = app_dir.joinpath("static")
10+
11+
12+
def serve():
13+
os.environ.setdefault("FLASK_ENV", "production")
14+
os.environ.setdefault("STATIC_ASSETS", str(static_assets_dir))
15+
sys.argv = [
16+
"gunicorn",
17+
"-c",
18+
str(config_dir.joinpath("gunicorn.py").absolute()),
19+
"ttnn_visualizer.app:create_app()",
20+
]
21+
run()

0 commit comments

Comments
 (0)