Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/databricks/labs/ucx/account/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
self._workspace_context_factory = workspace_context_factory

@cached_property
def _workspace_contexts(self):
def _workspace_contexts(self) -> list[WorkspaceContext]:
contexts = []
for workspace_client in self._account_workspaces.workspace_clients():
ctx = self._workspace_context_factory(workspace_client)
Expand Down
12 changes: 10 additions & 2 deletions src/databricks/labs/ucx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,19 @@ def assign_metastore(
ctx: AccountContext | None = None,
):
"""Assign metastore to a workspace"""
if workspace_id is None:
logger.error("--workspace-id is a required parameter.")
return
try:
workspace_id_casted = int(workspace_id)
except ValueError:
logger.error("--workspace-id should be an integer.")
return
logger.info(f"Account ID: {a.config.account_id}")
ctx = ctx or AccountContext(a)
ctx.account_metastores.assign_metastore(
ctx.prompts,
workspace_id,
workspace_id_casted,
metastore_id=metastore_id,
default_catalog=default_catalog,
)
Expand Down Expand Up @@ -635,7 +643,7 @@ def migrate_tables(
deployed_workflows = workspace_context.deployed_workflows
deployed_workflows.run_workflow("migrate-tables")

tables = workspace_context.tables_crawler.snapshot()
tables = list(workspace_context.tables_crawler.snapshot())
hiveserde_tables = [table for table in tables if table.what == What.EXTERNAL_HIVESERDE]
if len(hiveserde_tables) > 0:
percentage_hiveserde_tables = len(hiveserde_tables) / len(tables) * 100
Expand Down
10 changes: 5 additions & 5 deletions src/databricks/labs/ucx/contexts/account_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ def account_client(self) -> AccountClient:
return self._ac

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

@cached_property
def account_workspaces(self):
def account_workspaces(self) -> AccountWorkspaces:
return AccountWorkspaces(self.account_client, self.workspace_ids)

@cached_property
def account_aggregate(self):
def account_aggregate(self) -> AccountAggregate:
return AccountAggregate(self.account_workspaces)

@cached_property
def is_account_install(self):
def is_account_install(self) -> bool:
return environ.get("UCX_FORCE_INSTALL") == "account"

@cached_property
def account_metastores(self):
def account_metastores(self) -> AccountMetastores:
return AccountMetastores(self.account_client)
Loading
Loading