File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ commands:
6565
6666 - name : create-table-mapping
6767 description : create initial table mapping for review
68+ flags :
69+ - name : run-as-collection
70+ description : (Optional) boolean flag to indicate to run the cmd as a collection. Default is False.
6871
6972 - name : ensure-assessment-run
7073 description : ensure the assessment job was run on a workspace
Original file line number Diff line number Diff line change @@ -153,11 +153,21 @@ def manual_workspace_info(w: WorkspaceClient, prompts: Prompts):
153153
154154
155155@ucx .command
156- def create_table_mapping (w : WorkspaceClient ):
156+ def create_table_mapping (
157+ w : WorkspaceClient ,
158+ ctx : WorkspaceContext | None = None ,
159+ run_as_collection : bool = False ,
160+ a : AccountClient | None = None ,
161+ ):
157162 """create initial table mapping for review"""
158- ctx = WorkspaceContext (w )
159- path = ctx .table_mapping .save (ctx .tables_crawler , ctx .workspace_info )
160- webbrowser .open (f"{ w .config .host } /#workspace{ path } " )
163+ workspace_contexts = _get_workspace_contexts (w , a , run_as_collection )
164+ if ctx :
165+ workspace_contexts = [ctx ]
166+ for workspace_ctx in workspace_contexts :
167+ logger .info (f"Running cmd for workspace { workspace_ctx .workspace_client .get_workspace_id ()} " )
168+ path = workspace_ctx .table_mapping .save (workspace_ctx .tables_crawler , workspace_ctx .workspace_info )
169+ if len (workspace_contexts ) == 1 :
170+ webbrowser .open (f"{ w .config .host } /#workspace{ path } " )
161171
162172
163173@ucx .command
Original file line number Diff line number Diff line change @@ -265,9 +265,10 @@ def test_manual_workspace_info(ws):
265265 manual_workspace_info (ws , prompts )
266266
267267
268- def test_create_table_mapping (ws ):
268+ def test_create_table_mapping (ws , acc_client ):
269+ ctx = WorkspaceContext (ws )
269270 with pytest .raises (ValueError , match = 'databricks labs ucx sync-workspace-info' ):
270- create_table_mapping (ws )
271+ create_table_mapping (ws , ctx , False , acc_client )
271272
272273
273274def test_validate_external_locations (ws ):
You can’t perform that action at this time.
0 commit comments