Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hailctl] make hailctl work on windows #14090

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 18 additions & 12 deletions hail/python/hailtop/hailctl/dataproc/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,25 @@ def get_chrome_path():
if system == 'Darwin':
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'

if system == 'Linux':
for c in ['chromium', 'chromium-browser']:
release = platform.uname().release
is_wsl = 'Microsoft' in release or 'microsoft' in release

if system == 'Linux' and not is_wsl:
for c in ['chromium', 'chromium-browser', 'chrome.exe']:
chrome = shutil.which(c)
if chrome:
return chrome

raise EnvironmentError("cannot find 'chromium' or 'chromium-browser' on path")
raise EnvironmentError("cannot find 'chromium', 'chromium-browser', or 'chrome.exe' on path")

if system == 'Windows':
return '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
if system == 'Windows' or (system == 'Linux' and is_wsl):
fnames = [
'/mnt/c/Program Files/Google/Chrome/Application/chrome.exe'
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
]
for fname in fnames:
if os.path.exists(fname):
return fname

raise ValueError(f"unsupported system: {system}, set environment variable HAILCTL_CHROME to a chrome executable")

Expand Down Expand Up @@ -109,18 +118,15 @@ def connect(
gcloud.run(cmd)

chrome = os.environ.get('HAILCTL_CHROME') or get_chrome_path()
data_dir = os.path.join(tempfile.gettempdir(), 'hailctl-dataproc-connect-' + secret_alnum_string(6))

# open Chrome with SOCKS proxy configuration
with subprocess.Popen(
[ # pylint: disable=consider-using-with
chrome,
'http://localhost:{}'.format(connect_port_and_path),
'--proxy-server=socks5://localhost:{}'.format(port),
'--host-resolver-rules=MAP * 0.0.0.0 , EXCLUDE localhost',
'--proxy-bypass-list=<-loopback>', # https://chromium.googlesource.com/chromium/src/+/da790f920bbc169a6805a4fb83b4c2ab09532d91
'--user-data-dir={}'.format(
os.path.join(tempfile.gettempdir(), 'hailctl-dataproc-connect-' + secret_alnum_string(6))
),
f'http://{name}-m:{connect_port_and_path}',
f'--proxy-server=socks5://localhost:{port}'
f'--user-data-dir={data_dir}',
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def mkdir_if_not_exists(path):
with open('/opt/conda/default/etc/jupyter/jupyter_notebook_config.py', 'w') as f:
opts = [
'c.Application.log_level = "DEBUG"',
'c.NotebookApp.ip = "127.0.0.1"',
'c.NotebookApp.ip = "0.0.0.0"',
'c.NotebookApp.open_browser = False',
'c.NotebookApp.port = 8123',
'c.NotebookApp.token = ""',
Expand Down