1111from urllib import parse
1212
1313from databricks .labs .blueprint .parallel import ManyError , Threads
14- from databricks .labs .blueprint .paths import DBFSPath , WorkspacePath
14+ from databricks .labs .blueprint .paths import DBFSPath
1515from databricks .labs .lsql .backends import SqlBackend
1616from databricks .sdk import WorkspaceClient
1717from 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-
519505class 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