Skip to content

Commit

Permalink
.. fixed most of the issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx committed May 3, 2024
1 parent f732aa9 commit 678289c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/databricks/labs/ucx/source_code/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def build_graph_from_python_source(self, python_code: str) -> MaybeGraph:
problems.append(problem)
return MaybeGraph(self, problems)

def __repr__(self):
return f"<DependencyGraph {self.path}>"


class Dependency(abc.ABC):

Expand Down
4 changes: 4 additions & 0 deletions src/databricks/labs/ucx/source_code/notebooks/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def is_runnable(self) -> bool:
def build_dependency_graph(self, parent: DependencyGraph) -> MaybeGraph:
raise NotImplementedError()

def __repr__(self):
return f"{self.language.name}: {self._original_code[:20]}"


class PythonCell(Cell):

Expand Down Expand Up @@ -158,6 +161,7 @@ def build_dependency_graph(self, parent: DependencyGraph) -> MaybeGraph:
maybe.graph,
[
problem.replace(
source_path=parent.dependency.path,
start_line=start_line,
start_col=0,
end_line=start_line,
Expand Down
7 changes: 5 additions & 2 deletions src/databricks/labs/ucx/source_code/notebooks/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ def build_dependency_graph(self, parent: DependencyGraph) -> list[DependencyProb
problems: list[DependencyProblem] = []
for cell in self._cells:
maybe = cell.build_dependency_graph(parent)
if maybe.problems:
problems.extend(maybe.problems)
for problem in maybe.problems:
problems.append(problem.replace(source_path=parent.path))
return problems

def __repr__(self):
return f"<Notebook {self._path}>"


class NotebookLinter:
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/source_code/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def get_status_side_effect(*args):
]
)
builder = DependencyGraphBuilder(dependency_resolver)
builder.build_notebook_dependency_graph(Path("root3.run.py.txt"))
maybe = builder.build_notebook_dependency_graph(Path("root3.run.py.txt"))
assert not maybe.failed
assert len(visited) == len(paths)


Expand Down

0 comments on commit 678289c

Please sign in to comment.