|
17 | 17 | from databricks.labs.blueprint.paths import DBFSPath |
18 | 18 | from databricks.labs.lsql.backends import SqlBackend |
19 | 19 | from databricks.sdk import WorkspaceClient |
20 | | -from databricks.sdk.errors import NotFound, ResourceDoesNotExist |
| 20 | +from databricks.sdk.errors import NotFound, ResourceDoesNotExist, BadRequest |
21 | 21 | from databricks.sdk.service import compute, jobs |
22 | 22 | from databricks.sdk.service.workspace import Language |
23 | 23 |
|
@@ -175,30 +175,41 @@ def _register_library(self, graph: DependencyGraph, library: compute.Library) -> |
175 | 175 | problems = graph.register_library(library.pypi.package) |
176 | 176 | if problems: |
177 | 177 | yield from problems |
178 | | - if library.egg: |
179 | | - yield from self._register_egg(graph, library) |
180 | | - if library.whl: |
181 | | - wheel_path = self._as_path(library.whl) |
182 | | - with self._temporary_copy(wheel_path) as local_file: |
183 | | - yield from graph.register_library(local_file.as_posix()) |
184 | | - if library.requirements: # https://pip.pypa.io/en/stable/reference/requirements-file-format/ |
185 | | - logger.info(f"Registering libraries from {library.requirements}") |
186 | | - requirements_path = self._as_path(library.requirements) |
187 | | - with requirements_path.open() as requirements: |
188 | | - for requirement in requirements: |
189 | | - requirement = requirement.rstrip() |
190 | | - clean_requirement = requirement.replace(" ", "") # requirements.txt may contain spaces |
191 | | - if clean_requirement.startswith("-r"): |
192 | | - logger.warning(f"Reference to other requirements file is not supported: {requirement}") |
193 | | - continue |
194 | | - if clean_requirement.startswith("-c"): |
195 | | - logger.warning(f"Reference to constraints file is not supported: {requirement}") |
196 | | - continue |
197 | | - yield from graph.register_library(clean_requirement) |
| 178 | + try: |
| 179 | + if library.egg: |
| 180 | + yield from self._register_egg(graph, library) |
| 181 | + if library.whl: |
| 182 | + yield from self._register_whl(graph, library) |
| 183 | + if library.requirements: |
| 184 | + yield from self._register_requirements_txt(graph, library) |
| 185 | + except BadRequest as e: |
| 186 | + # see https://github.com/databrickslabs/ucx/issues/2916 |
| 187 | + yield DependencyProblem('library-error', f'Cannot retrieve library: {e}') |
198 | 188 | if library.jar: |
199 | 189 | # TODO: https://github.com/databrickslabs/ucx/issues/1641 |
200 | 190 | yield DependencyProblem('not-yet-implemented', 'Jar library is not yet implemented') |
201 | 191 |
|
| 192 | + def _register_requirements_txt(self, graph, library): |
| 193 | + # https://pip.pypa.io/en/stable/reference/requirements-file-format/ |
| 194 | + logger.info(f"Registering libraries from {library.requirements}") |
| 195 | + requirements_path = self._as_path(library.requirements) |
| 196 | + with requirements_path.open() as requirements: |
| 197 | + for requirement in requirements: |
| 198 | + requirement = requirement.rstrip() |
| 199 | + clean_requirement = requirement.replace(" ", "") # requirements.txt may contain spaces |
| 200 | + if clean_requirement.startswith("-r"): |
| 201 | + logger.warning(f"Reference to other requirements file is not supported: {requirement}") |
| 202 | + continue |
| 203 | + if clean_requirement.startswith("-c"): |
| 204 | + logger.warning(f"Reference to constraints file is not supported: {requirement}") |
| 205 | + continue |
| 206 | + yield from graph.register_library(clean_requirement) |
| 207 | + |
| 208 | + def _register_whl(self, graph, library): |
| 209 | + wheel_path = self._as_path(library.whl) |
| 210 | + with self._temporary_copy(wheel_path) as local_file: |
| 211 | + yield from graph.register_library(local_file.as_posix()) |
| 212 | + |
202 | 213 | def _register_egg(self, graph, library): |
203 | 214 | if self.runtime_version > (14, 0): |
204 | 215 | yield DependencyProblem( |
|
0 commit comments