ttnn-visualizer 0.29.0__py3-none-any.whl → 0.30.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 +4 -4
- ttnn_visualizer/csv_queries.py +20 -5
- ttnn_visualizer/decorators.py +0 -7
- ttnn_visualizer/file_uploads.py +5 -7
- ttnn_visualizer/models.py +32 -32
- ttnn_visualizer/queries.py +6 -6
- ttnn_visualizer/sessions.py +78 -69
- ttnn_visualizer/settings.py +4 -1
- ttnn_visualizer/sftp_operations.py +24 -25
- ttnn_visualizer/static/assets/{allPaths-CJHbl9k5.js → allPaths-BFtaymsj.js} +1 -1
- ttnn_visualizer/static/assets/{allPathsLoader-BMROdgRm.js → allPathsLoader-krdfUMe8.js} +2 -2
- ttnn_visualizer/static/assets/{index-CINMcROY.css → index-Bq0nVwFb.css} +2 -2
- ttnn_visualizer/static/assets/{index-DRqEueCH.js → index-BsP_KNDi.js} +246 -246
- ttnn_visualizer/static/assets/{splitPathsBySizeLoader-Bff1kHt3.js → splitPathsBySizeLoader-Exj9Tfv3.js} +1 -1
- ttnn_visualizer/static/index.html +2 -2
- ttnn_visualizer/tests/test_queries.py +4 -4
- ttnn_visualizer/utils.py +17 -29
- ttnn_visualizer/views.py +251 -90
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/METADATA +4 -4
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/RECORD +25 -25
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/LICENSE +0 -0
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/LICENSE_understanding.txt +0 -0
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/WHEEL +0 -0
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/entry_points.txt +0 -0
- {ttnn_visualizer-0.29.0.dist-info → ttnn_visualizer-0.30.0.dist-info}/top_level.txt +0 -0
ttnn_visualizer/app.py
CHANGED
@@ -154,8 +154,8 @@ def open_browser(host, port, instance_id=None):
|
|
154
154
|
|
155
155
|
def parse_args():
|
156
156
|
parser = argparse.ArgumentParser(description="A tool for visualizing the Tenstorrent Neural Network model (TT-NN)")
|
157
|
-
parser.add_argument("--
|
158
|
-
parser.add_argument("--
|
157
|
+
parser.add_argument("--profiler-path", type=str, help="Specify a profiler path", default=None)
|
158
|
+
parser.add_argument("--performance-path", help="Specify a performance path", default=None)
|
159
159
|
return parser.parse_args()
|
160
160
|
|
161
161
|
|
@@ -169,13 +169,13 @@ def main():
|
|
169
169
|
args = parse_args()
|
170
170
|
instance_id = None
|
171
171
|
|
172
|
-
if args.
|
172
|
+
if args.profiler_path or args.performance_path:
|
173
173
|
app = create_app()
|
174
174
|
app.app_context().push()
|
175
175
|
try:
|
176
176
|
session = create_instance_from_local_paths(
|
177
|
-
report_path=args.report_path,
|
178
177
|
profiler_path=args.profiler_path,
|
178
|
+
performance_path=args.performance_path,
|
179
179
|
)
|
180
180
|
except InvalidReportPath:
|
181
181
|
sys.exit("Invalid report path")
|
ttnn_visualizer/csv_queries.py
CHANGED
@@ -261,7 +261,6 @@ class RemoteCSVQueryRunner:
|
|
261
261
|
|
262
262
|
class DeviceLogProfilerQueries:
|
263
263
|
DEVICE_LOG_FILE = "profile_log_device.csv"
|
264
|
-
LOCAL_PROFILER_DIRECTORY = "profiler"
|
265
264
|
DEVICE_LOG_COLUMNS = [
|
266
265
|
"PCIe slot",
|
267
266
|
"core_x",
|
@@ -309,7 +308,7 @@ class DeviceLogProfilerQueries:
|
|
309
308
|
)
|
310
309
|
else:
|
311
310
|
self.runner = LocalCSVQueryRunner(
|
312
|
-
file_path=Path(self.session.
|
311
|
+
file_path=Path(self.session.performance_path).joinpath(
|
313
312
|
self.DEVICE_LOG_FILE
|
314
313
|
),
|
315
314
|
offset=1, # Skip the first line for device log files
|
@@ -375,7 +374,7 @@ class DeviceLogProfilerQueries:
|
|
375
374
|
and not session.remote_connection.useRemoteQuerying
|
376
375
|
):
|
377
376
|
file_path = Path(
|
378
|
-
session.
|
377
|
+
session.performance_path, DeviceLogProfilerQueries.DEVICE_LOG_FILE
|
379
378
|
)
|
380
379
|
with open(file_path, "r") as f:
|
381
380
|
return f.read()
|
@@ -479,11 +478,11 @@ class OpsPerformanceQueries:
|
|
479
478
|
|
480
479
|
@staticmethod
|
481
480
|
def get_local_ops_perf_file_path(session):
|
482
|
-
|
481
|
+
performance_path = Path(session.performance_path)
|
483
482
|
|
484
483
|
# Find the latest file with the correct prefix
|
485
484
|
perf_files = list(
|
486
|
-
|
485
|
+
performance_path.glob(f"{OpsPerformanceQueries.PERF_RESULTS_PREFIX}_*.csv")
|
487
486
|
)
|
488
487
|
if not perf_files:
|
489
488
|
raise FileNotFoundError("No performance results file found.")
|
@@ -544,6 +543,22 @@ class OpsPerformanceQueries:
|
|
544
543
|
columns=self.PERF_RESULTS_COLUMNS, as_dict=as_dict, limit=limit
|
545
544
|
)
|
546
545
|
|
546
|
+
def get_all_folders(directory: str) -> List[str]:
|
547
|
+
"""
|
548
|
+
Get a list of all folder names in the specified directory.
|
549
|
+
|
550
|
+
:param directory: Path to the /profiles directory.
|
551
|
+
:return: List of folder names.
|
552
|
+
"""
|
553
|
+
try:
|
554
|
+
return [
|
555
|
+
folder.name
|
556
|
+
for folder in Path(directory).iterdir()
|
557
|
+
if folder.is_dir()
|
558
|
+
]
|
559
|
+
except Exception as e:
|
560
|
+
raise RuntimeError(f"Error accessing directory: {e}")
|
561
|
+
|
547
562
|
|
548
563
|
class OpsPerformanceReportQueries:
|
549
564
|
REPORT_COLUMNS = [
|
ttnn_visualizer/decorators.py
CHANGED
@@ -36,13 +36,6 @@ def with_session(func):
|
|
36
36
|
session_query_data = get_or_create_instance(instance_id=instance_id)
|
37
37
|
session = session_query_data.to_pydantic()
|
38
38
|
|
39
|
-
if not session.active_report:
|
40
|
-
current_app.logger.error(
|
41
|
-
f"No active report exists for instanceId {instance_id}, returning 404"
|
42
|
-
)
|
43
|
-
# Raise 404 if report_path is missing or does not exist
|
44
|
-
abort(404)
|
45
|
-
|
46
39
|
kwargs["session"] = session
|
47
40
|
return func(*args, **kwargs)
|
48
41
|
|
ttnn_visualizer/file_uploads.py
CHANGED
@@ -36,12 +36,12 @@ def validate_files(files, required_files, pattern=None):
|
|
36
36
|
return True
|
37
37
|
|
38
38
|
|
39
|
-
def
|
39
|
+
def extract_profiler_name(files):
|
40
40
|
"""Extract the report name from the first file."""
|
41
41
|
if not files:
|
42
42
|
return None
|
43
|
-
|
44
|
-
return
|
43
|
+
unsplit_profiler_name = str(files[0].filename)
|
44
|
+
return unsplit_profiler_name.split("/")[0]
|
45
45
|
|
46
46
|
def extract_npe_name(files):
|
47
47
|
if not files:
|
@@ -54,16 +54,14 @@ def extract_npe_name(files):
|
|
54
54
|
def save_uploaded_files(
|
55
55
|
files,
|
56
56
|
target_directory,
|
57
|
-
|
57
|
+
profiler_name=None,
|
58
58
|
):
|
59
59
|
"""
|
60
60
|
Save uploaded files to the target directory.
|
61
61
|
|
62
62
|
:param files: List of files to be saved.
|
63
63
|
:param target_directory: The base directory for saving the files.
|
64
|
-
:param
|
65
|
-
:param modify_path: Optional function to modify the file path before saving.
|
66
|
-
:param flat_structure: If True, saves files directly under the report_name directory without subdirectories.
|
64
|
+
:param profiler_name: The report name to use for the directory.
|
67
65
|
"""
|
68
66
|
for file in files:
|
69
67
|
current_file_name = str(file.filename)
|
ttnn_visualizer/models.py
CHANGED
@@ -168,7 +168,7 @@ class RemoteConnection(SerializeableModel):
|
|
168
168
|
username: str
|
169
169
|
host: str
|
170
170
|
port: int = Field(ge=1, le=65535)
|
171
|
-
|
171
|
+
profilerPath: str
|
172
172
|
performancePath: Optional[str] = None
|
173
173
|
sqliteBinaryPath: Optional[str] = None
|
174
174
|
useRemoteQuerying: bool = False
|
@@ -179,9 +179,9 @@ class StatusMessage(SerializeableModel):
|
|
179
179
|
message: str
|
180
180
|
|
181
181
|
|
182
|
-
class
|
183
|
-
|
184
|
-
|
182
|
+
class ActiveReports(SerializeableModel):
|
183
|
+
profiler_name: Optional[str] = None
|
184
|
+
performance_name: Optional[str] = None
|
185
185
|
npe_name: Optional[str] = None
|
186
186
|
|
187
187
|
|
@@ -194,13 +194,13 @@ class RemoteReportFolder(SerializeableModel):
|
|
194
194
|
|
195
195
|
class Instance(BaseModel):
|
196
196
|
instance_id: str
|
197
|
-
report_path: Optional[str] = None
|
198
197
|
profiler_path: Optional[str] = None
|
198
|
+
performance_path: Optional[str] = None
|
199
199
|
npe_path: Optional[str] = None
|
200
|
-
active_report: Optional[
|
200
|
+
active_report: Optional[ActiveReports] = None
|
201
201
|
remote_connection: Optional[RemoteConnection] = None
|
202
|
-
|
203
|
-
|
202
|
+
remote_profiler_folder: Optional[RemoteReportFolder] = None
|
203
|
+
remote_performance_folder: Optional[RemoteReportFolder] = None
|
204
204
|
|
205
205
|
|
206
206
|
class InstanceTable(db.Model):
|
@@ -208,33 +208,33 @@ class InstanceTable(db.Model):
|
|
208
208
|
|
209
209
|
id = Column(Integer, primary_key=True)
|
210
210
|
instance_id = Column(String, unique=True, nullable=False)
|
211
|
-
|
212
|
-
|
211
|
+
profiler_path = Column(String)
|
212
|
+
performance_path = Column(String, nullable=True)
|
213
213
|
npe_path = Column(String, nullable=True)
|
214
214
|
active_report = db.Column(MutableDict.as_mutable(JSON), nullable=False, default={})
|
215
215
|
remote_connection = Column(JSON, nullable=True)
|
216
|
-
|
217
|
-
|
216
|
+
remote_profiler_folder = Column(JSON, nullable=True)
|
217
|
+
remote_performance_folder = Column(JSON, nullable=True)
|
218
218
|
|
219
219
|
def __init__(
|
220
220
|
self,
|
221
221
|
instance_id,
|
222
222
|
active_report,
|
223
223
|
remote_connection=None,
|
224
|
-
|
225
|
-
|
226
|
-
report_path=None,
|
224
|
+
remote_profiler_folder=None,
|
225
|
+
remote_performance_folder=None,
|
227
226
|
profiler_path=None,
|
227
|
+
performance_path=None,
|
228
228
|
npe_path=None,
|
229
229
|
):
|
230
230
|
self.instance_id = instance_id
|
231
231
|
self.active_report = active_report
|
232
|
-
self.
|
232
|
+
self.profiler_path = profiler_path
|
233
233
|
self.npe_path = npe_path
|
234
234
|
self.remote_connection = remote_connection
|
235
|
-
self.
|
236
|
-
self.
|
237
|
-
self.
|
235
|
+
self.remote_profiler_folder = remote_profiler_folder
|
236
|
+
self.performance_path = performance_path
|
237
|
+
self.remote_performance_folder = remote_performance_folder
|
238
238
|
|
239
239
|
def to_dict(self):
|
240
240
|
return {
|
@@ -242,25 +242,25 @@ class InstanceTable(db.Model):
|
|
242
242
|
"instance_id": self.instance_id,
|
243
243
|
"active_report": self.active_report,
|
244
244
|
"remote_connection": self.remote_connection,
|
245
|
-
"
|
246
|
-
"
|
247
|
-
"report_path": self.report_path,
|
245
|
+
"remote_profiler_folder": self.remote_profiler_folder,
|
246
|
+
"remote_performance_folder": self.remote_performance_folder,
|
248
247
|
"profiler_path": self.profiler_path,
|
248
|
+
"performance_path": self.performance_path,
|
249
249
|
"npe_path": self.npe_path
|
250
250
|
}
|
251
251
|
|
252
252
|
def to_pydantic(self) -> Instance:
|
253
253
|
return Instance(
|
254
254
|
instance_id=str(self.instance_id),
|
255
|
-
|
256
|
-
|
257
|
-
str(self.
|
255
|
+
profiler_path=str(self.profiler_path) if self.profiler_path is not None else None,
|
256
|
+
performance_path=(
|
257
|
+
str(self.performance_path) if self.performance_path is not None else None
|
258
258
|
),
|
259
259
|
npe_path=(
|
260
260
|
str(self.npe_path) if self.npe_path is not None else None
|
261
261
|
),
|
262
262
|
active_report=(
|
263
|
-
(
|
263
|
+
(ActiveReports(**self.active_report) if self.active_report else None)
|
264
264
|
if isinstance(self.active_report, dict)
|
265
265
|
else None
|
266
266
|
),
|
@@ -269,16 +269,16 @@ class InstanceTable(db.Model):
|
|
269
269
|
if self.remote_connection is not None
|
270
270
|
else None
|
271
271
|
),
|
272
|
-
|
273
|
-
RemoteReportFolder.model_validate(self.
|
274
|
-
if self.
|
272
|
+
remote_profiler_folder=(
|
273
|
+
RemoteReportFolder.model_validate(self.remote_profiler_folder, strict=False)
|
274
|
+
if self.remote_profiler_folder is not None
|
275
275
|
else None
|
276
276
|
),
|
277
|
-
|
277
|
+
remote_performance_folder=(
|
278
278
|
RemoteReportFolder.model_validate(
|
279
|
-
self.
|
279
|
+
self.remote_performance_folder, strict=False
|
280
280
|
)
|
281
|
-
if self.
|
281
|
+
if self.remote_performance_folder is not None
|
282
282
|
else None
|
283
283
|
),
|
284
284
|
)
|
ttnn_visualizer/queries.py
CHANGED
@@ -36,15 +36,15 @@ class LocalQueryRunner:
|
|
36
36
|
if connection:
|
37
37
|
self.connection = connection
|
38
38
|
else:
|
39
|
-
if not session or not session.
|
39
|
+
if not session or not session.profiler_path:
|
40
40
|
raise ValueError("Report path must be provided for local queries")
|
41
|
-
db_path = str(session.
|
41
|
+
db_path = str(session.profiler_path)
|
42
42
|
if not Path(db_path).exists():
|
43
43
|
raise DatabaseFileNotFoundException(
|
44
44
|
f"Database not found at path: {db_path}"
|
45
45
|
)
|
46
46
|
self.connection = sqlite3.connect(
|
47
|
-
session.
|
47
|
+
session.profiler_path, isolation_level=None, timeout=30
|
48
48
|
)
|
49
49
|
|
50
50
|
def execute_query(self, query: str, params: Optional[List] = None) -> List:
|
@@ -72,7 +72,7 @@ class RemoteQueryRunner:
|
|
72
72
|
self.ssh_client = self._get_ssh_client(self.session.remote_connection)
|
73
73
|
self.sqlite_binary = self.session.remote_connection.sqliteBinaryPath
|
74
74
|
self.remote_db_path = str(
|
75
|
-
Path(self.session.
|
75
|
+
Path(self.session.remote_profiler_folder.remotePath, "db.sqlite")
|
76
76
|
)
|
77
77
|
|
78
78
|
def _validate_session(self):
|
@@ -82,8 +82,8 @@ class RemoteQueryRunner:
|
|
82
82
|
if (
|
83
83
|
not self.session.remote_connection
|
84
84
|
or not self.session.remote_connection.sqliteBinaryPath
|
85
|
-
or not self.session.
|
86
|
-
or not self.session.
|
85
|
+
or not self.session.remote_profiler_folder
|
86
|
+
or not self.session.remote_profiler_folder.remotePath
|
87
87
|
):
|
88
88
|
raise ValueError(
|
89
89
|
"Remote connections require remote path and sqliteBinaryPath"
|
ttnn_visualizer/sessions.py
CHANGED
@@ -11,7 +11,7 @@ from pathlib import Path
|
|
11
11
|
from flask import request
|
12
12
|
|
13
13
|
from ttnn_visualizer.exceptions import InvalidReportPath, InvalidProfilerPath
|
14
|
-
from ttnn_visualizer.utils import
|
14
|
+
from ttnn_visualizer.utils import get_profiler_path, get_performance_path, get_npe_path
|
15
15
|
from ttnn_visualizer.models import (
|
16
16
|
InstanceTable,
|
17
17
|
)
|
@@ -25,31 +25,40 @@ from sqlalchemy.exc import SQLAlchemyError
|
|
25
25
|
|
26
26
|
def update_existing_instance(
|
27
27
|
session_data,
|
28
|
-
|
29
|
-
|
28
|
+
profiler_name,
|
29
|
+
performance_name,
|
30
30
|
npe_name,
|
31
31
|
remote_connection,
|
32
|
-
|
33
|
-
|
32
|
+
remote_profiler_folder,
|
33
|
+
remote_performance_folder,
|
34
34
|
clear_remote,
|
35
35
|
):
|
36
36
|
active_report = session_data.active_report or {}
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
# First ifs are explicit deletes and elifs are updates
|
39
|
+
if profiler_name == "":
|
40
|
+
active_report.pop("profiler_name", None)
|
41
|
+
elif profiler_name is not None:
|
42
|
+
active_report["profiler_name"] = profiler_name
|
43
|
+
|
44
|
+
if performance_name == "":
|
45
|
+
active_report.pop("performance_name", None)
|
46
|
+
elif performance_name is not None:
|
47
|
+
|
48
|
+
active_report["performance_name"] = performance_name
|
49
|
+
if npe_name == "":
|
50
|
+
active_report.pop("npe_name", None)
|
51
|
+
elif npe_name is not None:
|
43
52
|
active_report["npe_name"] = npe_name
|
44
53
|
|
45
54
|
session_data.active_report = active_report
|
46
55
|
|
47
56
|
if remote_connection:
|
48
57
|
session_data.remote_connection = remote_connection.model_dump()
|
49
|
-
if
|
50
|
-
session_data.
|
51
|
-
if
|
52
|
-
session_data.
|
58
|
+
if remote_profiler_folder:
|
59
|
+
session_data.remote_profiler_folder = remote_profiler_folder.model_dump()
|
60
|
+
if remote_performance_folder:
|
61
|
+
session_data.remote_performance_folder = remote_performance_folder.model_dump()
|
53
62
|
|
54
63
|
if clear_remote:
|
55
64
|
clear_remote_data(session_data)
|
@@ -61,8 +70,8 @@ def update_existing_instance(
|
|
61
70
|
|
62
71
|
def clear_remote_data(session_data):
|
63
72
|
session_data.remote_connection = None
|
64
|
-
session_data.
|
65
|
-
session_data.
|
73
|
+
session_data.remote_profiler_folder = None
|
74
|
+
session_data.remote_performance_folder = None
|
66
75
|
|
67
76
|
|
68
77
|
def handle_sqlalchemy_error(error):
|
@@ -82,16 +91,16 @@ def commit_and_log_session(session_data, instance_id):
|
|
82
91
|
def update_paths(
|
83
92
|
session_data, active_report, remote_connection
|
84
93
|
):
|
85
|
-
if active_report.get("
|
86
|
-
session_data.
|
87
|
-
|
94
|
+
if active_report.get("performance_name"):
|
95
|
+
session_data.performance_path = get_performance_path(
|
96
|
+
performance_name=active_report["performance_name"],
|
88
97
|
current_app=current_app,
|
89
98
|
remote_connection=remote_connection,
|
90
99
|
)
|
91
100
|
|
92
|
-
if active_report.get("
|
93
|
-
session_data.
|
94
|
-
|
101
|
+
if active_report.get("profiler_name"):
|
102
|
+
session_data.profiler_path = get_profiler_path(
|
103
|
+
profiler_name=active_report["profiler_name"],
|
95
104
|
current_app=current_app,
|
96
105
|
remote_connection=remote_connection,
|
97
106
|
)
|
@@ -105,41 +114,41 @@ def update_paths(
|
|
105
114
|
|
106
115
|
def create_new_instance(
|
107
116
|
instance_id,
|
108
|
-
|
109
|
-
|
117
|
+
profiler_name,
|
118
|
+
performance_name,
|
110
119
|
npe_name,
|
111
120
|
remote_connection,
|
112
|
-
|
113
|
-
|
121
|
+
remote_profiler_folder,
|
122
|
+
remote_performance_folder,
|
114
123
|
clear_remote,
|
115
124
|
):
|
116
125
|
active_report = {}
|
117
|
-
if
|
118
|
-
active_report["
|
119
|
-
if
|
120
|
-
active_report["
|
126
|
+
if profiler_name:
|
127
|
+
active_report["profiler_name"] = profiler_name
|
128
|
+
if performance_name:
|
129
|
+
active_report["performance_name"] = performance_name
|
121
130
|
if npe_name:
|
122
131
|
active_report["npe_name"] = npe_name
|
123
132
|
|
124
133
|
if clear_remote:
|
125
134
|
remote_connection = None
|
126
|
-
|
127
|
-
|
135
|
+
remote_profiler_folder = None
|
136
|
+
remote_performance_folder = None
|
128
137
|
|
129
138
|
session_data = InstanceTable(
|
130
139
|
instance_id=instance_id,
|
131
140
|
active_report=active_report,
|
132
|
-
|
133
|
-
active_report,
|
141
|
+
profiler_path=get_profiler_path(
|
142
|
+
active_report["profiler_name"],
|
134
143
|
current_app=current_app,
|
135
144
|
remote_connection=remote_connection,
|
136
145
|
),
|
137
146
|
remote_connection=(
|
138
147
|
remote_connection.model_dump() if remote_connection else None
|
139
148
|
),
|
140
|
-
|
141
|
-
|
142
|
-
|
149
|
+
remote_profiler_folder=remote_profiler_folder.model_dump() if remote_profiler_folder else None,
|
150
|
+
remote_performance_folder=(
|
151
|
+
remote_performance_folder.model_dump() if remote_performance_folder else None
|
143
152
|
),
|
144
153
|
)
|
145
154
|
db.session.add(session_data)
|
@@ -148,12 +157,12 @@ def create_new_instance(
|
|
148
157
|
|
149
158
|
def update_instance(
|
150
159
|
instance_id,
|
151
|
-
|
152
|
-
|
160
|
+
profiler_name=None,
|
161
|
+
performance_name=None,
|
153
162
|
npe_name=None,
|
154
163
|
remote_connection=None,
|
155
|
-
|
156
|
-
|
164
|
+
remote_profiler_folder=None,
|
165
|
+
remote_performance_folder=None,
|
157
166
|
clear_remote=False,
|
158
167
|
):
|
159
168
|
try:
|
@@ -162,23 +171,23 @@ def update_instance(
|
|
162
171
|
if session_data:
|
163
172
|
update_existing_instance(
|
164
173
|
session_data,
|
165
|
-
|
166
|
-
|
174
|
+
profiler_name,
|
175
|
+
performance_name,
|
167
176
|
npe_name,
|
168
177
|
remote_connection,
|
169
|
-
|
170
|
-
|
178
|
+
remote_profiler_folder,
|
179
|
+
remote_performance_folder,
|
171
180
|
clear_remote,
|
172
181
|
)
|
173
182
|
else:
|
174
183
|
session_data = create_new_instance(
|
175
184
|
instance_id,
|
176
|
-
|
177
|
-
|
185
|
+
profiler_name,
|
186
|
+
performance_name,
|
178
187
|
npe_name,
|
179
188
|
remote_connection,
|
180
|
-
|
181
|
-
|
189
|
+
remote_profiler_folder,
|
190
|
+
remote_performance_folder,
|
182
191
|
clear_remote,
|
183
192
|
)
|
184
193
|
|
@@ -192,11 +201,11 @@ def update_instance(
|
|
192
201
|
|
193
202
|
def get_or_create_instance(
|
194
203
|
instance_id,
|
195
|
-
|
196
|
-
|
204
|
+
profiler_name=None,
|
205
|
+
performance_name=None,
|
197
206
|
npe_name=None,
|
198
207
|
remote_connection=None,
|
199
|
-
|
208
|
+
remote_profiler_folder=None,
|
200
209
|
):
|
201
210
|
"""
|
202
211
|
Retrieve an existing tab session or create a new one if it doesn't exist.
|
@@ -212,20 +221,20 @@ def get_or_create_instance(
|
|
212
221
|
instance_id=instance_id,
|
213
222
|
active_report={},
|
214
223
|
remote_connection=None,
|
215
|
-
|
224
|
+
remote_profiler_folder=None,
|
216
225
|
)
|
217
226
|
db.session.add(session_data)
|
218
227
|
db.session.commit()
|
219
228
|
|
220
229
|
# Update the session if any new data is provided
|
221
|
-
if
|
230
|
+
if profiler_name or performance_name or npe_name or remote_connection or remote_profiler_folder:
|
222
231
|
update_instance(
|
223
232
|
instance_id=instance_id,
|
224
|
-
|
225
|
-
|
233
|
+
profiler_name=profiler_name,
|
234
|
+
performance_name=performance_name,
|
226
235
|
npe_name=npe_name,
|
227
236
|
remote_connection=remote_connection,
|
228
|
-
|
237
|
+
remote_profiler_folder=remote_profiler_folder,
|
229
238
|
)
|
230
239
|
|
231
240
|
# Query again to get the updated session data
|
@@ -270,30 +279,30 @@ def create_random_instance_id():
|
|
270
279
|
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=10))
|
271
280
|
|
272
281
|
|
273
|
-
def create_instance_from_local_paths(
|
274
|
-
_report_path = Path(report_path) if report_path else None
|
282
|
+
def create_instance_from_local_paths(profiler_path, performance_path):
|
275
283
|
_profiler_path = Path(profiler_path) if profiler_path else None
|
284
|
+
_performance_path = Path(performance_path) if performance_path else None
|
276
285
|
|
277
|
-
if
|
286
|
+
if _profiler_path and (not _profiler_path.exists() or not _profiler_path.is_dir()):
|
278
287
|
raise InvalidReportPath()
|
279
288
|
|
280
|
-
if
|
289
|
+
if _performance_path and (not _performance_path.exists() or not _performance_path.is_dir()):
|
281
290
|
raise InvalidProfilerPath()
|
282
291
|
|
283
|
-
|
284
|
-
|
292
|
+
profiler_name = _profiler_path.parts[-1] if _profiler_path and len(_profiler_path.parts) > 2 else ""
|
293
|
+
performance_name = _performance_path.parts[-1] if _performance_path and len(_performance_path.parts) > 2 else ""
|
285
294
|
session_data = InstanceTable(
|
286
295
|
instance_id=create_random_instance_id(),
|
287
296
|
active_report={
|
288
|
-
"
|
289
|
-
"
|
297
|
+
"profiler_name": profiler_name,
|
298
|
+
"performance_name": performance_name,
|
290
299
|
"npe_name": None,
|
291
300
|
},
|
292
|
-
|
293
|
-
|
301
|
+
profiler_path=f"{_profiler_path}/db.sqlite" if profiler_path else None,
|
302
|
+
performance_path=performance_path if performance_path else None,
|
294
303
|
remote_connection=None,
|
295
|
-
|
296
|
-
|
304
|
+
remote_profiler_folder=None,
|
305
|
+
remote_performance_folder=None,
|
297
306
|
)
|
298
307
|
db.session.add(session_data)
|
299
308
|
db.session.commit()
|
ttnn_visualizer/settings.py
CHANGED
@@ -18,10 +18,13 @@ class DefaultConfig(object):
|
|
18
18
|
PRINT_ENV = True
|
19
19
|
|
20
20
|
# Path Settings
|
21
|
+
DB_VERSION = "0.29.0" # App version when DB schema last changed
|
21
22
|
REPORT_DATA_DIRECTORY = Path(__file__).parent.absolute().joinpath("data")
|
22
|
-
DB_VERSION = "0.26.0" # App version when DB schema last changed
|
23
23
|
LOCAL_DATA_DIRECTORY = Path(REPORT_DATA_DIRECTORY).joinpath("local")
|
24
24
|
REMOTE_DATA_DIRECTORY = Path(REPORT_DATA_DIRECTORY).joinpath("remote")
|
25
|
+
PROFILER_DIRECTORY_NAME = "profiler-reports"
|
26
|
+
PERFORMANCE_DIRECTORY_NAME = "performance-reports"
|
27
|
+
NPE_DIRECTORY_NAME = "npe-reports"
|
25
28
|
APPLICATION_DIR = os.path.abspath(os.path.join(__file__, "..", os.pardir))
|
26
29
|
STATIC_ASSETS_DIR = Path(APPLICATION_DIR).joinpath("ttnn_visualizer", "static")
|
27
30
|
SEND_FILE_MAX_AGE_DEFAULT = 0
|