Skip to content

Commit 95c5984

Browse files
Profiler Teamcopybara-github
authored andcommitted
Fix XProf server not coming up on windows machine
PiperOrigin-RevId: 789880022
1 parent 6c7ba4b commit 95c5984

File tree

5 files changed

+72
-2
lines changed

5 files changed

+72
-2
lines changed

plugin/build_pip_package.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ find . -name "*.bak" -exec rm {} \;
8484

8585
cp ${build_workspace}/bazel-bin/xprof/pywrap/_pywrap_profiler_plugin.so xprof/convert/
8686

87+
if [[ "$(uname)" == *MSYS_NT* ]]; then
88+
mv xprof/convert/_pywrap_profiler_plugin.so xprof/convert/_pywrap_profiler_plugin.pyd
89+
fi
90+
8791
# Copy static files.
8892
cd xprof
8993
mkdir -p static

plugin/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_readme():
5959
),
6060
package_data={
6161
'xprof': ['static/**'],
62-
'': ['_pywrap_profiler_plugin.so'],
62+
'': ['_pywrap_profiler_plugin.so', '_pywrap_profiler_plugin.pyd'],
6363
},
6464
entry_points={
6565
'tensorboard_plugins': [

plugin/xprof/standalone/BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# A collection of classes to bypass Tensorboard dependencies.
33

44
load("@python_deps//:requirements.bzl", "requirement")
5+
load("@rules_python//python:defs.bzl", "py_test")
56
load("@rules_python//python:py_library.bzl", "py_library")
67

78
visibility = ["//plugin:internal"]
@@ -66,3 +67,13 @@ py_library(
6667
srcs_version = "PY2AND3",
6768
deps = [],
6869
)
70+
71+
py_test(
72+
name = "plugin_asset_util_test",
73+
srcs = ["plugin_asset_util_test.py"],
74+
deps = [
75+
":plugin_asset_util",
76+
"//testing/pybase",
77+
"//testing/pybase:parameterized",
78+
],
79+
)

plugin/xprof/standalone/plugin_asset_util.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,29 @@
2323
_PROTOCOL_PREFIXES = ("gs://",)
2424

2525

26+
def _get_protocol_from_parsed_url_scheme(scheme: str) -> str:
27+
"""Returns the protocol from the parsed URL scheme.
28+
29+
If the scheme is not recognized, returns "file" as the default protocol.
30+
31+
Args:
32+
scheme: The parsed URL scheme.
33+
34+
Returns:
35+
The protocol from the parsed URL scheme.
36+
"""
37+
if not scheme:
38+
return "file"
39+
for prefix in _PROTOCOL_PREFIXES:
40+
if prefix.startswith(scheme):
41+
return scheme
42+
return "file"
43+
44+
2645
def get_fs_protocol(path):
2746
string_path = str(path)
2847
parsed_url = urllib.parse.urlparse(string_path)
29-
protocol = parsed_url.scheme or "file"
48+
protocol = _get_protocol_from_parsed_url_scheme(parsed_url.scheme)
3049
return fsspec.filesystem(protocol)
3150

3251

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from google3.testing.pybase import googletest
2+
from google3.testing.pybase import parameterized
3+
from xprof.standalone import plugin_asset_util
4+
5+
6+
class PluginAssetUtilTest(parameterized.TestCase):
7+
8+
@parameterized.named_parameters(
9+
dict(
10+
testcase_name="No_Scheme",
11+
scheme="",
12+
expected="file",
13+
),
14+
dict(
15+
testcase_name="GCS_Scheme",
16+
scheme="gs",
17+
expected="gs",
18+
),
19+
dict(
20+
testcase_name="Windows_Path_C_Drive",
21+
scheme="C",
22+
expected="file",
23+
),
24+
dict(
25+
testcase_name="Windows_path_T_Drive",
26+
scheme="T",
27+
expected="file",
28+
),
29+
)
30+
def test_get_protocol_from_parsed_url_scheme(self, scheme, expected):
31+
got = plugin_asset_util._get_protocol_from_parsed_url_scheme(scheme=scheme)
32+
self.assertEqual(expected, got)
33+
34+
35+
if __name__ == "__main__":
36+
googletest.main()

0 commit comments

Comments
 (0)