Skip to content

Tech Debt: Reuse defaults from WorkspaceConfig in WorkspaceInstaller._prompt_for_new_installation #3825

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 18 additions & 5 deletions src/databricks/labs/ucx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,26 @@ def _is_testing(self):

def _prompt_for_new_installation(self) -> WorkspaceConfig:
logger.info("Please answer a couple of questions to configure Unity Catalog migration")

default_database = "ucx"

# if a workspace is configured to use external hive metastore, the majority of the time that metastore will be
# shared with other workspaces. we need to add the suffix to ensure uniqueness of the inventory database
if self.policy_installer.has_ext_hms():
default_database = f"ucx_{self.workspace_client.get_workspace_id()}"
default_config = WorkspaceConfig(default_database)
inventory_database = self.prompts.question(
"Inventory Database stored in hive_metastore", default=default_database, valid_regex=r"^\w+$"
"Inventory Database stored in hive_metastore",
default=default_config.inventory_database,
valid_regex=r"^\w+$",
)
ucx_catalog = self.prompts.question(
"Catalog to store UCX artifacts in", default=default_config.ucx_catalog, valid_regex=r"^\w+$"
)
log_level = self.prompts.question("Log level", default=default_config.log_level).upper()
num_threads = int(
self.prompts.question("Number of threads", default=str(default_config.num_threads), valid_number=True)
)
ucx_catalog = self.prompts.question("Catalog to store UCX artifacts in", default="ucx", valid_regex=r"^\w+$")
log_level = self.prompts.question("Log level", default="INFO").upper()
num_threads = int(self.prompts.question("Number of threads", default="8", valid_number=True))
configure_groups = ConfigureGroups(self.prompts)
configure_groups.run()
include_databases = self._select_databases()
Expand All @@ -256,7 +265,11 @@ def _prompt_for_new_installation(self) -> WorkspaceConfig:
)
trigger_job = self.prompts.confirm("Do you want to trigger assessment job after installation?")
recon_tolerance_percent = int(
self.prompts.question("Reconciliation threshold, in percentage", default="5", valid_number=True)
self.prompts.question(
"Reconciliation threshold, in percentage",
default=str(default_config.recon_tolerance_percent),
valid_number=True,
)
)

return WorkspaceConfig(
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/install/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def test_configure_sets_expected_workspace_configuration_values(
"ucx_catalog": "ucx",
"inventory_database": "ucx",
"log_level": "INFO",
"num_threads": 8,
"num_threads": 10,
"min_workers": 1,
"max_workers": 10,
"policy_id": "foo",
Expand Down Expand Up @@ -409,7 +409,7 @@ def test_configure_with_default_owner_group(
"ucx_catalog": "ucx",
"inventory_database": "ucx",
"log_level": "INFO",
"num_threads": 8,
"num_threads": 10,
"min_workers": 1,
"max_workers": 10,
"policy_id": "foo",
Expand Down Expand Up @@ -501,7 +501,7 @@ def test_create_cluster_policy(ws, mock_installation) -> None:
'inventory_database': 'ucx',
'log_level': 'INFO',
'num_days_submit_runs_history': 30,
'num_threads': 8,
'num_threads': 10,
'min_workers': 1,
'max_workers': 10,
'policy_id': 'foo1',
Expand Down Expand Up @@ -1746,7 +1746,7 @@ def test_save_config_ext_hms(ws, mock_installation) -> None:
'include_databases': ['db1', 'db2'],
'inventory_database': 'ucx_12345678',
'log_level': 'INFO',
'num_threads': 8,
'num_threads': 10,
'min_workers': 1,
'max_workers': 10,
'policy_id': 'foo',
Expand Down