Skip to content

Commit

Permalink
Set workspace_client on AccountContext
Browse files Browse the repository at this point in the history
Should be solved properly by #2507
  • Loading branch information
JCZuurmond committed Sep 23, 2024
1 parent c1e15e2 commit a211dfb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/databricks/labs/ucx/contexts/account_cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from functools import cached_property
from os import environ

from databricks.sdk import AccountClient

from databricks.sdk import AccountClient, WorkspaceClient

from databricks.labs.ucx.account.aggregate import AccountAggregate
from databricks.labs.ucx.account.metastores import AccountMetastores
Expand All @@ -19,6 +18,14 @@ def __init__(self, ac: AccountClient, named_parameters: dict[str, str] | None =
def account_client(self) -> AccountClient:
return self._ac

@cached_property
def workspace_client(self) -> WorkspaceClient:
"""Return any workspace client available"""
workspace_clients = self.account_workspaces.workspace_clients()
if len(workspace_clients) == 0:
return super().workspace_client
return workspace_clients[0]

@cached_property
def workspace_ids(self):
return [int(_.strip()) for _ in self.named_parameters.get("workspace_ids", "").split(",") if _]
Expand Down

0 comments on commit a211dfb

Please sign in to comment.