Skip to content

Commit 7fb017a

Browse files
authored
drop workspace path.stat() workaround (#2650)
## Changes Blueprint 0.8.3 implements path.stat() for workspace paths. This PR removes the corresponding workaround ### Linked issues None ### Functionality None ### Tests - [x] ran unit tests - [x] ran integration tests Co-authored-by: Eric Vergnaud <[email protected]>
1 parent 818f440 commit 7fb017a

File tree

1 file changed

+3
-17
lines changed
  • src/databricks/labs/ucx/source_code

1 file changed

+3
-17
lines changed

src/databricks/labs/ucx/source_code/jobs.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from urllib import parse
1212

1313
from databricks.labs.blueprint.parallel import ManyError, Threads
14-
from databricks.labs.blueprint.paths import DBFSPath, WorkspacePath
14+
from databricks.labs.blueprint.paths import DBFSPath
1515
from databricks.labs.lsql.backends import SqlBackend
1616
from databricks.sdk import WorkspaceClient
1717
from databricks.sdk.errors import NotFound
@@ -502,20 +502,6 @@ def _process_dependency(
502502
yield LocatedAdvice(advice, dependency.path)
503503

504504

505-
def _get_path_modified_datetime(path: Path) -> datetime:
506-
if isinstance(path, WorkspacePath):
507-
# TODO add stats method in blueprint, see https://github.com/databrickslabs/blueprint/issues/142
508-
# pylint: disable=protected-access
509-
unix_time = float(path._object_info.modified_at) / 1000.0 if path._object_info.modified_at else 0.0
510-
elif isinstance(path, DBFSPath):
511-
# TODO add stats method in blueprint, see https://github.com/databrickslabs/blueprint/issues/143
512-
# pylint: disable=protected-access
513-
unix_time = float(path._file_info.modification_time) / 1000.0 if path._file_info.modification_time else 0.0
514-
else:
515-
unix_time = path.stat().st_mtime
516-
return datetime.fromtimestamp(unix_time, timezone.utc)
517-
518-
519505
class DfsaCollectorWalker(DependencyGraphWalker[DirectFsAccess]):
520506

521507
def __init__(
@@ -546,7 +532,7 @@ def _collect_from_notebook(
546532
self, source: str, language: CellLanguage, path: Path, inherited_tree: Tree | None
547533
) -> Iterable[DirectFsAccess]:
548534
notebook = Notebook.parse(path, source, language.language)
549-
src_timestamp = _get_path_modified_datetime(path)
535+
src_timestamp = datetime.fromtimestamp(path.stat().st_mtime, timezone.utc)
550536
src_id = str(path)
551537
for cell in notebook.cells:
552538
for dfsa in self._collect_from_source(cell.original_code, cell.language, path, inherited_tree):
@@ -568,7 +554,7 @@ def _collect_from_source(
568554
if iterable is None:
569555
logger.warning(f"Language {language.name} not supported yet!")
570556
return
571-
src_timestamp = _get_path_modified_datetime(path)
557+
src_timestamp = datetime.fromtimestamp(path.stat().st_mtime, timezone.utc)
572558
src_id = str(path)
573559
for dfsa in iterable:
574560
yield dfsa.replace_source(source_id=src_id, source_lineage=self.lineage, source_timestamp=src_timestamp)

0 commit comments

Comments
 (0)