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

Search for both databricks.exe and databricks binaries in windows #517

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
15 changes: 13 additions & 2 deletions databricks/sdk/credentials_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os
import pathlib
import platform
import subprocess
import sys
from datetime import datetime
Expand Down Expand Up @@ -473,11 +474,21 @@ def __init__(self, cfg: 'Config'):
args += ['--account-id', cfg.account_id]

cli_path = cfg.databricks_cli_path

# If the path is not specified look for "databricks" / "databricks.exe" in PATH.
if not cli_path:
cli_path = 'databricks'
try:
# Try to find "databricks" in PATH
cli_path = self.__class__._find_executable("databricks")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is __class__ necessary?

>>> class A:
...     @classmethod
...     def hello(cls):
...             print("Hi")
... 
>>> class B(A):
...     def hellob(self):
...             self.hello()
... 
>>> B().hellob()
Hi

except FileNotFoundError as e:
# If "databricks" is not found, try to find "databricks.exe" in PATH (Windows)
if platform.system() == "Windows":
cli_path = self.__class__._find_executable("databricks.exe")
else:
raise e

# If the path is unqualified, look it up in PATH.
if cli_path.count("/") == 0:
elif cli_path.count("/") == 0:
cli_path = self.__class__._find_executable(cli_path)

super().__init__(cmd=[cli_path, *args],
Expand Down
Loading