Skip to content

Commit 4ded40e

Browse files
JCZuurmondgueniai
andauthored
Remove try-except around verifying the migration progress prerequisites in the migrate-tables cli command (#3439)
## Changes Remove `try-except` around verifying the migration progress prerequistes in the `migrate-tables` cli command as the warning is more specific inside the class ### Linked issues Progresses #3438 ### Functionality - [x] modified existing command: `databricks labs ucx migrate-tables` --------- Co-authored-by: Guenia Izquierdo Delgado <[email protected]>
1 parent 542a29e commit 4ded40e

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

src/databricks/labs/ucx/cli.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -687,16 +687,7 @@ def migrate_tables(
687687
for workspace_context in workspace_contexts:
688688
deployed_workflows = workspace_context.deployed_workflows
689689

690-
try:
691-
workspace_context.verify_progress_tracking.verify()
692-
except RuntimeWarning:
693-
logger.warning(
694-
"We couldn't detect a successful run of the assessment workflow."
695-
"The assessment workflow is a prerequisite for the migrate-tables workflow."
696-
"It can be run by using the `ensure-assessment-run` command."
697-
)
698-
return
699-
690+
workspace_context.verify_progress_tracking.verify()
700691
deployed_workflows.run_workflow("migrate-tables")
701692

702693
tables = list(workspace_context.tables_crawler.snapshot())

tests/unit/test_cli.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,28 +1028,15 @@ def test_migrate_tables_calls_migrate_table_job_run_now(
10281028
workspace_client.jobs.wait_get_run_job_terminated_or_skipped.assert_called_once()
10291029

10301030

1031-
@pytest.mark.parametrize("run_as_collection", [False, True])
1032-
def test_migrate_tables_errors_out_before_assessment(
1033-
run_as_collection,
1034-
workspace_clients,
1035-
acc_client,
1036-
) -> None:
1037-
if not run_as_collection:
1038-
workspace_clients = [workspace_clients[0]]
1039-
run = Run(
1040-
state=RunState(result_state=RunResultState.SUCCESS),
1041-
start_time=0,
1042-
end_time=1000,
1043-
run_duration=1000,
1044-
)
1045-
for workspace_client in workspace_clients:
1046-
workspace_client.jobs.wait_get_run_job_terminated_or_skipped.return_value = run
1047-
workspace_client.jobs.list_runs.return_value = [Run(state=RunState(result_state=RunResultState.FAILED))]
1031+
def test_migrate_tables_errors_out_before_assessment(ws, acc_client) -> None:
1032+
verify_progress_tracking = create_autospec(VerifyProgressTracking)
1033+
verify_progress_tracking.verify.side_effect = RuntimeWarning("Verification failed")
1034+
ctx = WorkspaceContext(ws).replace(verify_progress_tracking=verify_progress_tracking)
10481035

1049-
migrate_tables(workspace_clients[0], MockPrompts({}), run_as_collection=run_as_collection, a=acc_client)
1036+
with pytest.raises(RuntimeWarning, match="Verification failed"):
1037+
migrate_tables(ws, MockPrompts({}), ctx=ctx, a=acc_client)
10501038

1051-
for workspace_client in workspace_clients:
1052-
workspace_client.jobs.run_now.assert_not_called()
1039+
ws.jobs.run_now.assert_not_called()
10531040

10541041

10551042
def test_migrate_tables_calls_external_hiveserde_tables_job_run_now(ws) -> None:

0 commit comments

Comments
 (0)