File tree Expand file tree Collapse file tree 5 files changed +72
-2
lines changed
Expand file tree Collapse file tree 5 files changed +72
-2
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,10 @@ find . -name "*.bak" -exec rm {} \;
8484
8585cp ${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.
8892cd xprof
8993mkdir -p static
Original file line number Diff line number Diff 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' : [
Original file line number Diff line number Diff line change 22# A collection of classes to bypass Tensorboard dependencies.
33
44load ("@python_deps//:requirements.bzl" , "requirement" )
5+ load ("@rules_python//python:defs.bzl" , "py_test" )
56load ("@rules_python//python:py_library.bzl" , "py_library" )
67
78visibility = ["//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+ )
Original file line number Diff line number Diff line change 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+
2645def 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
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments