ttnn-visualizer 0.38.3__py3-none-any.whl → 0.39.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ttnn_visualizer/app.py CHANGED
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: © 2025 Tenstorrent AI ULC
4
4
 
5
5
  import argparse
6
+ import json
6
7
  import logging
7
8
  import os
8
9
  import subprocess
@@ -55,16 +56,29 @@ def create_app(settings_override=None):
55
56
 
56
57
  middleware(app)
57
58
 
58
- app.register_blueprint(api)
59
+ app.register_blueprint(api, url_prefix=f"{app.config['BASE_PATH']}/api")
59
60
 
60
61
  extensions(app)
61
62
 
62
63
  if flask_env == "production":
63
-
64
- @app.route("/", defaults={"path": ""})
64
+ @app.route(f"{app.config['BASE_PATH']}/", defaults={"path": ""})
65
65
  @app.route("/<path:path>")
66
66
  def catch_all(path):
67
- return app.send_static_file("index.html")
67
+ js_config = {
68
+ "SERVER_MODE": app.config["SERVER_MODE"],
69
+ "BASE_PATH": app.config["BASE_PATH"],
70
+ }
71
+ js = f"window.TTNN_VISUALIZER_CONFIG = {json.dumps(js_config)};"
72
+
73
+ with open(os.path.join(app.static_folder, "index.html")) as f:
74
+ html = f.read()
75
+
76
+ html_with_config = html.replace(
77
+ "/* SERVER_CONFIG */",
78
+ js,
79
+ )
80
+
81
+ return flask.Response(html_with_config, mimetype="text/html")
68
82
 
69
83
  return app
70
84
 
@@ -42,7 +42,8 @@ def with_instance(func):
42
42
  session['instances'] = []
43
43
 
44
44
  if instance.instance_id not in session['instances']:
45
- session['instances'].append(instance.instance_id)
45
+ session['instances'] = session.get('instances', []) + [instance.instance_id]
46
+
46
47
 
47
48
  return func(*args, **kwargs)
48
49
 
@@ -115,3 +116,16 @@ def remote_exception_handler(func):
115
116
  )
116
117
 
117
118
  return remote_handler
119
+
120
+
121
+ def local_only(f):
122
+ from flask import current_app
123
+
124
+ @wraps(f)
125
+ def decorated_function(*args, **kwargs):
126
+ if current_app.config["SERVER_MODE"]:
127
+ abort(403, description="Endpoint not accessible")
128
+
129
+ return f(*args, **kwargs)
130
+
131
+ return decorated_function
@@ -22,7 +22,7 @@ class DefaultConfig(object):
22
22
  o for o in os.getenv("ALLOWED_ORIGINS", "http://localhost:5173,http://localhost:8000").split(",")
23
23
  if o
24
24
  ]
25
- API_PATH = os.getenv("API_PATH", "/")
25
+ BASE_PATH = os.getenv("BASE_PATH", "/")
26
26
 
27
27
  # Path Settings
28
28
  DB_VERSION = "0.29.0" # App version when DB schema last changed
@@ -1 +1 @@
1
- import{I as n}from"./index-BKzgFDAn.js";import{I as e}from"./index-BvSuWPlB.js";import{p as r,I as s}from"./index-DuZqnhYU.js";function I(o,t){var a=r(o);return t===s.STANDARD?n[a]:e[a]}function p(o){return r(o)}export{n as IconSvgPaths16,e as IconSvgPaths20,I as getIconPaths,p as iconNameToPathsRecordKey};
1
+ import{I as n}from"./index-BKzgFDAn.js";import{I as e}from"./index-BvSuWPlB.js";import{p as r,I as s}from"./index-Ba6DlrXF.js";function I(o,t){var a=r(o);return t===s.STANDARD?n[a]:e[a]}function p(o){return r(o)}export{n as IconSvgPaths16,e as IconSvgPaths20,I as getIconPaths,p as iconNameToPathsRecordKey};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/allPaths-Ysrp65Ak.js","assets/index-BKzgFDAn.js","assets/index-BvSuWPlB.js","assets/index-DuZqnhYU.js","assets/index-BJweZJCB.css"])))=>i.map(i=>d[i]);
2
- import{_ as o,a as n,b as i}from"./index-DuZqnhYU.js";var _=function(e,a){return o(void 0,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,i(()=>import("./allPaths-Ysrp65Ak.js"),__vite__mapDeps([0,1,2,3,4]))];case 1:return t=r.sent().getIconPaths,[2,t(e,a)]}})})};export{_ as allPathsLoader};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/allPaths-BYcRoLEw.js","assets/index-BKzgFDAn.js","assets/index-BvSuWPlB.js","assets/index-Ba6DlrXF.js","assets/index-B9wn2kZo.css"])))=>i.map(i=>d[i]);
2
+ import{_ as o,a as n,b as i}from"./index-Ba6DlrXF.js";var _=function(e,a){return o(void 0,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,i(()=>import("./allPaths-BYcRoLEw.js"),__vite__mapDeps([0,1,2,3,4]))];case 1:return t=r.sent().getIconPaths,[2,t(e,a)]}})})};export{_ as allPathsLoader};