2525
2626from databricks .labs .ucx .assessment .crawlers import runtime_version_tuple
2727from databricks .labs .ucx .hive_metastore .table_migration_status import TableMigrationIndex
28- from databricks .labs .ucx .mixins .cached_workspace_path import WorkspaceCache
28+ from databricks .labs .ucx .mixins .cached_workspace_path import WorkspaceCache , InvalidPath
2929from databricks .labs .ucx .source_code .base import (
3030 CurrentSessionState ,
3131 LocatedAdvice ,
@@ -160,7 +160,7 @@ def _as_path(self, path: str) -> Path:
160160 return DBFSPath (self ._ws , parsed_path .path )
161161 case other :
162162 msg = f"Unsupported schema: { other } (only DBFS or Workspace paths are allowed)"
163- raise ValueError (msg )
163+ raise InvalidPath (msg )
164164
165165 @classmethod
166166 @contextmanager
@@ -183,7 +183,7 @@ def _register_library(self, graph: DependencyGraph, library: compute.Library) ->
183183 yield from self ._register_whl (graph , library )
184184 if library .requirements :
185185 yield from self ._register_requirements_txt (graph , library )
186- except WorkspaceCache . InvalidWorkspacePath as e :
186+ except InvalidPath as e :
187187 yield DependencyProblem ('cannot-load-file' , str (e ))
188188 except BadRequest as e :
189189 # see https://github.com/databrickslabs/ucx/issues/2916
@@ -209,9 +209,12 @@ def _register_requirements_txt(self, graph, library) -> Iterable[DependencyProbl
209209 yield from graph .register_library (clean_requirement )
210210
211211 def _register_whl (self , graph , library ) -> Iterable [DependencyProblem ]:
212- wheel_path = self ._as_path (library .whl )
213- with self ._temporary_copy (wheel_path ) as local_file :
214- yield from graph .register_library (local_file .as_posix ())
212+ try :
213+ wheel_path = self ._as_path (library .whl )
214+ with self ._temporary_copy (wheel_path ) as local_file :
215+ yield from graph .register_library (local_file .as_posix ())
216+ except InvalidPath as e :
217+ yield DependencyProblem ('cannot-load-file' , str (e ))
215218
216219 def _register_egg (self , graph , library ) -> Iterable [DependencyProblem ]:
217220 if self .runtime_version > (14 , 0 ):
@@ -220,9 +223,12 @@ def _register_egg(self, graph, library) -> Iterable[DependencyProblem]:
220223 message = 'Installing eggs is no longer supported on Databricks 14.0 or higher' ,
221224 )
222225 logger .info (f"Registering library from { library .egg } " )
223- egg_path = self ._as_path (library .egg )
224- with self ._temporary_copy (egg_path ) as local_file :
225- yield from graph .register_library (local_file .as_posix ())
226+ try :
227+ egg_path = self ._as_path (library .egg )
228+ with self ._temporary_copy (egg_path ) as local_file :
229+ yield from graph .register_library (local_file .as_posix ())
230+ except InvalidPath as e :
231+ yield DependencyProblem ('cannot-load-file' , str (e ))
226232
227233 def _register_notebook (self , graph : DependencyGraph ) -> Iterable [DependencyProblem ]:
228234 if not self ._task .notebook_task :
@@ -237,7 +243,7 @@ def _register_notebook(self, graph: DependencyGraph) -> Iterable[DependencyProbl
237243 try :
238244 # Notebooks can't be on DBFS.
239245 path = self ._cache .get_workspace_path (notebook_path )
240- except WorkspaceCache . InvalidWorkspacePath as e :
246+ except InvalidPath as e :
241247 return [DependencyProblem ('cannot-load-notebook' , str (e ))]
242248 return graph .register_notebook (path , False )
243249
@@ -249,7 +255,7 @@ def _register_spark_python_task(self, graph: DependencyGraph) -> Iterable[Depend
249255 logger .info (f'Discovering { self ._task .task_key } entrypoint: { python_file } ' )
250256 try :
251257 path = self ._as_path (python_file )
252- except WorkspaceCache . InvalidWorkspacePath as e :
258+ except InvalidPath as e :
253259 return [DependencyProblem ('cannot-load-file' , str (e ))]
254260 return graph .register_file (path )
255261
@@ -326,7 +332,7 @@ def _register_notebook_path(self, graph: DependencyGraph, notebook_path: str) ->
326332 try :
327333 # Notebooks can't be on DBFS.
328334 path = self ._cache .get_workspace_path (notebook_path )
329- except WorkspaceCache . InvalidWorkspacePath as e :
335+ except InvalidPath as e :
330336 yield DependencyProblem ('cannot-load-notebook' , str (e ))
331337 return
332338 # the notebook is the root of the graph, so there's no context to inherit
0 commit comments