Skip to content
This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions tb_plugin/fe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
### Install & Build

1. install [Node.js](https://nodejs.org/)
* ```bash
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs```
2. install [Yarn](https://yarnpkg.com/)
* ```bash
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
```
3. shell `yarn`
4. shell `yarn build`
5. `./dist/index.html`
2 changes: 1 addition & 1 deletion tb_plugin/fe/prettier.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"useTabs": false,
"trailingComma": "none",
"proseWrap": "always",
"endOfLine": "crlf"
"endOfLine": "lf"
}

30 changes: 30 additions & 0 deletions tb_plugin/fe/scripts/add_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
import glob
import os
import sys

HEADER='''/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/

'''

def add_header(file):
with open(file, 'r') as f:
contents = f.readlines()

# do nothing if there is already header
if contents and contents[0].startswith("/*-"):
return

with open(file, 'w') as out:
out.write(HEADER)
out.writelines(contents)

if __name__ == '__main__':
dir = sys.argv[1]
if not os.path.isdir(dir):
raise ValueError("{} is not a directory".format(dir))

for file in glob.glob(dir + "/*.ts"):
add_header(file)
13 changes: 13 additions & 0 deletions tb_plugin/fe/src/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# How to generate the api.ts

## Prerequisites
1. install java
2. run command
```bash
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.25/swagger-codegen-cli-3.0.25.jar -O swagger-codegen-cli.jar
cd fe
java -jar swagger-codegen-cli.jar generate -i ./src/api/openapi.yaml -l typescript-fetch -o ./src/api/generated/
rm ./src/api/generated/api_test.spec.ts
yarn prettier --end-of-line lf
python ./scripts/add_header.py ./src/api/generated/
```
2 changes: 1 addition & 1 deletion tb_plugin/fe/src/api/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as url from 'url'
import * as portableFetch from 'portable-fetch'
import { Configuration } from './configuration'

const BASE_PATH = '/data/plugin/pytorch_profiler'.replace(/\/+$/, '')
const BASE_PATH = '.'.replace(/\/+$/, '')

/**
*
Expand Down
2 changes: 1 addition & 1 deletion tb_plugin/fe/src/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: Pytorch profile API
version: 1.0.0
servers:
- url: /data/plugin/pytorch_profiler
- url: .
paths:
/runs:
get:
Expand Down
2 changes: 1 addition & 1 deletion tb_plugin/fe/src/components/TraceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const TraceView: React.FC<IProps> = (props) => {
<iframe
className={classes.frame}
ref={iframeRef}
src="/data/plugin/pytorch_profiler/trace_embedding.html"
src="./trace_embedding.html"
></iframe>
</ClickAwayListener>
),
Expand Down
2 changes: 1 addition & 1 deletion tb_plugin/fe/src/components/charts/TableChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const TableChart: React.FC<IProps> = (props) => {
* if the height/width change to 0. Since we can't change the code of Google Charts, we temporarily lock the dims
* of the parent container. */
if (element.offsetHeight > 0) {
element.parentElement!.style.height = element.offsetHeight + "px"
element.parentElement!.style.height = element.offsetHeight + 'px'
}
chart.draw(data, options)
element.parentElement!.style.height = ''
Expand Down
2 changes: 1 addition & 1 deletion tb_plugin/fe/src/components/tables/CallStackTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { transformTableData, TransformedCallStackDataInner } from './transform'
import { attachId, getCommonOperationColumns } from './common'
import { OperationGroupBy } from '../../constants/groupBy'
import { makeExpandIcon } from './ExpandIcon'
import { CallFrameList } from './CallframeList'
import { CallFrameList } from './CallFrameList'

export interface IProps {
data: OperationTableDataInner
Expand Down
2 changes: 1 addition & 1 deletion tb_plugin/fe/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function firstOrUndefined<T>(v: T[] | undefined | null): T | undefined {
}

export function sleep(delay: number) {
return new Promise(resolve => setTimeout(resolve, delay))
return new Promise((resolve) => setTimeout(resolve, delay))
}

export function isValueAndFormat(v: any): v is ValueAndFormat {
Expand Down
1 change: 1 addition & 0 deletions tb_plugin/fe/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"strictPropertyInitialization": false,
"module": "esnext",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"rootDir": "src",
"outDir": "dist",
"jsx": "react"
Expand Down
22 changes: 17 additions & 5 deletions tb_plugin/test/test_tensorboard_end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ def test_tensorboard_end2end(self):
print("starting spawn mode testing...")
self._test_tensorboard_with_arguments(test_folder, expected_runs, {'TORCH_PROFILER_START_METHOD':'spawn'})

def _test_tensorboard_with_arguments(self, test_folder, expected_runs, env=None):
def test_tensorboard_with_path_prefix(self):
test_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)),'../samples')
expected_runs = b'["resnet50_num_workers_0", "resnet50_num_workers_4"]'
self._test_tensorboard_with_arguments(test_folder, expected_runs, path_prefix='/tensorboard/viewer/')

def _test_tensorboard_with_arguments(self, test_folder, expected_runs, env=None, path_prefix=None):
host='localhost'
port=6006

Expand All @@ -33,15 +38,22 @@ def _test_tensorboard_with_arguments(self, test_folder, expected_runs, env=None)
env_copy = os.environ.copy()
env_copy.update(env)
env = env_copy
tb = Popen(['tensorboard', '--logdir='+test_folder, '--port='+str(port)], env=env)
self._test_tensorboard(host, port, expected_runs)
if not path_prefix:
tb = Popen(['tensorboard', '--logdir='+test_folder, '--port='+str(port)], env=env)
else:
tb = Popen(['tensorboard', '--logdir='+test_folder, '--port='+str(port), '--path_prefix='+path_prefix], env=env)
self._test_tensorboard(host, port, expected_runs, path_prefix)
finally:
pid = tb.pid
tb.terminate()
print("tensorboard process {} is terminated.".format(pid))

def _test_tensorboard(self, host, port, expected_runs):
link_prefix = 'http://{}:{}/data/plugin/pytorch_profiler/'.format(host, port)
def _test_tensorboard(self, host, port, expected_runs, path_prefix):
if not path_prefix:
link_prefix = 'http://{}:{}/data/plugin/pytorch_profiler/'.format(host, port)
else:
path_prefix = path_prefix.strip('/')
link_prefix = 'http://{}:{}/{}/data/plugin/pytorch_profiler/'.format(host, port, path_prefix)
run_link = link_prefix + 'runs'

expected_links_format=[
Expand Down
2 changes: 1 addition & 1 deletion tb_plugin/torch_tb_profiler/static/index.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tb_plugin/torch_tb_profiler/static/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export async function render() {
document.location.href = 'index.html';
}