Skip to content

Commit

Permalink
Merge pull request #22 from vladkol/vladkol/windows-fixes01
Browse files Browse the repository at this point in the history
Windows fixes
  • Loading branch information
Vlad Kolesnikov authored Mar 13, 2021
2 parents 6d8096e + bab38fb commit f5870aa
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
30 changes: 10 additions & 20 deletions azdebugrelay/debug_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,14 @@ def _install_azure_relay_bridge():

azrelay_folder = os.path.join(
Path.home(), DebugRelay.relay_dir_name, DebugRelay.relay_version_name)
azrelay_parent = os.path.join(
Path.home(), DebugRelay.relay_dir_name)
azrelay_symlink = os.path.join(
azrelay_parent, DebugRelay.relay_app_name)
relay_file = os.path.join(
azrelay_folder, DebugRelay.relay_app_name)
DebugRelay._relay_config_file = os.path.join(
azrelay_folder, DebugRelay.relay_app_name) + ".yml"

if DebugRelay.is_windows:
relay_file += ".exe"

exists = os.path.exists(azrelay_folder)
if not exists:
if DebugRelay.is_windows:
Expand All @@ -384,35 +383,29 @@ def _install_azure_relay_bridge():
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

filestream = urllib.request.urlopen(download, context=ctx)

if download.lower().endswith(".zip"):
with zipfile.ZipFile(filestream, 'r') as zip_ref:
zip_file, _ = urllib.request.urlretrieve(download)
with zipfile.ZipFile(zip_file, 'r') as zip_ref:
zip_ref.extractall(azrelay_folder)
os.remove(zip_file)
else:
filestream = urllib.request.urlopen(download, context=ctx)
with tarfile.open(fileobj=filestream, mode="r|gz") as thetarfile:
thetarfile.extractall(azrelay_folder)

if not DebugRelay.is_windows:
st = os.stat(relay_file)
os.chmod(relay_file, st.st_mode | stat.S_IEXEC)

if not exists or not os.path.exists(azrelay_symlink):
tmp_link = f"{azrelay_symlink}.tmp"
os.symlink(relay_file, tmp_link)
os.replace(tmp_link, azrelay_symlink)
st = os.stat(azrelay_symlink)
os.chmod(azrelay_symlink, st.st_mode | stat.S_IEXEC)

if not os.path.exists(DebugRelay._relay_config_file):
with open(DebugRelay._relay_config_file, "a") as yml:
yml.write("ExitOnForwardFailure: true")

existing_path_var = os.environ["PATH"]
paths = existing_path_var.split(os.pathsep)
if azrelay_parent not in paths:
os.environ["PATH"] += os.pathsep + azrelay_parent
if azrelay_folder not in paths:
os.environ["PATH"] = azrelay_folder + os.pathsep + os.environ["PATH"]


def _main(connect: bool, host: str, ports: typing.List[str] = ["5678"], connection_string: str = None, relay_connection_name: str = None, config_file: str = None):
Expand Down Expand Up @@ -482,7 +475,7 @@ def _cli_main(argv):
Connection string of an Azure Relay Hybrid Connection
--connection-name - optional, defaults to None
Hybrid connection name. Required if --connection-string is specified.
--config-file - optional, defaults to None
--config_file - optional, defaults to None
Configuration file path. Only used if connection_string is not specified.
"""
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -520,6 +513,3 @@ def _cli_main(argv):
# DebugRelays can work as a CLI tool.
if __name__ == '__main__':
_cli_main(sys.argv[1:])



2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "azure-debug-relay",
"displayName": "Azure Debug Relay",
"description": "Azure Debug Relay Debugger Extension for Python",
"version": "0.3.8",
"description": "Distributed Debugging Extension for Python",
"version": "0.3.9",
"publisher": "VladKolesnikov-vladkol",
"repository": "https://github.com/vladkol/azure-debug-relay",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "azure-debug-relay"
version = "0.3.8"
version = "0.3.9"
description = "Cross-network remote debugging for Python"
authors = ["Vlad Kolesnikov"]
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions samples/azure_ml_advanced/publish_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create_and_publish_pipeline() -> any:
'argparse==1.4.0',
'azureml-core==1.22.0',
'debugpy==1.2.1',
'azure-debug-relay==0.3.8'
'azure-debug-relay==0.3.9'
])
batch_env = Environment(name="train-env")
batch_env.docker.enabled = True
Expand All @@ -83,7 +83,7 @@ def create_and_publish_pipeline() -> any:
tf_env.python.conda_dependencies.add_pip_package('argparse==1.4.0')
tf_env.python.conda_dependencies.add_pip_package('debugpy==1.2.1')
tf_env.python.conda_dependencies.add_pip_package(
'azure-debug-relay==0.3.8')
'azure-debug-relay==0.3.9')

print("Create pipeline steps")
steps = get_pipeline(
Expand Down
2 changes: 1 addition & 1 deletion samples/azure_ml_simple/deploy_and_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
conda_dependencies.add_conda_package("pip")
conda_dependencies.add_pip_package("azureml-sdk==" + amlcore.__version__)
conda_dependencies.add_pip_package("debugpy==1.2.1")
conda_dependencies.add_pip_package("azure-debug-relay==0.3.8")
conda_dependencies.add_pip_package("azure-debug-relay==0.3.9")

train_step = PythonScriptStep(name='Train Step with Debugging',
script_name="samples/azure_ml_simple/steps/train.py",
Expand Down
12 changes: 11 additions & 1 deletion vscode-extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Listener {
port: string;
}

var pythonPath = ""
var taskNamePrefix = "AzureRelayBridge_"
var listeners: Array<Listener> = new Array<Listener>()
var azDebugRelayTaskExecution: any
Expand Down Expand Up @@ -67,7 +68,7 @@ function startRelay(context: vscode.ExtensionContext, credentialOptions: string,

var pythonScriptPath = path.join(context.extensionPath, "azdebugrelay", "debug_relay.py")
var execution =
new vscode.ShellExecution(`python3 ${pythonScriptPath} --no-kill --mode listen ` +
new vscode.ShellExecution(`"${pythonPath}" "${pythonScriptPath}" --no-kill --mode listen ` +
`${credentialOptions} ` +
`--ports ${portsArgString} --host ${host}`);
var task_name = `${taskNamePrefix}${host}_${portsString}`
Expand Down Expand Up @@ -105,6 +106,15 @@ function stopRelay(_: vscode.ExtensionContext){
export function activate(context: vscode.ExtensionContext) {
console.log('Azure Relay Bridge extension activated.');

pythonPath = "python"
var pythonConfig = vscode.workspace.getConfiguration("python1")
if (pythonConfig !== undefined){
var pythonPathResult = pythonConfig.get("pythonPath")
if (pythonPathResult !== undefined) {
pythonPath = pythonPathResult as string
}
}

readConfig()
vscode.workspace.onDidChangeConfiguration((_: any) => {
readConfig()
Expand Down

0 comments on commit f5870aa

Please sign in to comment.