Skip to content

Commit

Permalink
Fixed issue with workspace listing process on None type object_type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HariGS-DB authored and larsgeorge-db committed Oct 21, 2023
1 parent d83db79 commit 3a34867
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/databricks/labs/ucx/workspace_access/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _crawl(self) -> list[WorkspaceObjectInfo]:

ws_listing = WorkspaceListing(self._ws, num_threads=self._num_threads, with_directories=False)
for obj in ws_listing.walk(self._start_path):
if obj is None:
if obj is None or obj.object_type is None:
continue
raw = obj.as_dict()
yield WorkspaceObjectInfo(
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/workspace_access/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,33 @@ def test_workspaceobject_crawl():
assert result_set[0] == WorkspaceObjectInfo("NOTEBOOK", "123", "/rootobj/notebook1", "PYTHON")


def test_workspaceobject_withexperiment_crawl():
sample_objects = [
ObjectInfo(
object_type=ObjectType.NOTEBOOK,
path="/rootobj/notebook1",
language=Language.PYTHON,
created_at=0,
modified_at=0,
object_id=123,
size=0,
),
ObjectInfo(
path="/rootobj/experiment1",
created_at=0,
modified_at=0,
object_id=456,
),
]
ws = Mock()
with patch("databricks.labs.ucx.workspace_access.listing.WorkspaceListing.walk", return_value=sample_objects):
crawler = WorkspaceListing(ws, MockBackend(), "ucx")._crawl()
result_set = list(crawler)

assert len(result_set) == 1
assert result_set[0] == WorkspaceObjectInfo("NOTEBOOK", "123", "/rootobj/notebook1", "PYTHON")


def test_workspace_snapshot():
sample_objects = [
WorkspaceObjectInfo(
Expand Down

0 comments on commit 3a34867

Please sign in to comment.