2424from ..cfg import ProjectConfig
2525from ..fs import AbstractFileSystem , get_filesystem
2626# from ..utils.misc import update_config_from_dict
27- from ..settings import BACKEND_PROPERTIES
27+ from ..settings import BACKEND_PROPERTIES , CACHE_DIR , CONFIG_DIR , PIPELINES_DIR
2828
2929
3030class BackendType (str , Enum ):
@@ -350,12 +350,21 @@ def __init__(
350350 self ._storage_options = storage_options or {}
351351 self ._backend = backend
352352 self ._type = type
353- self ._pipelines_dir = kwargs .get ("pipelines_dir" , "pipelines" )
354- self ._conf_dir = "conf"
353+ self ._pipelines_dir = kwargs .get ("pipelines_dir" , PIPELINES_DIR )
354+ self ._conf_dir = CONFIG_DIR
355355
356- if fs is None :
357- fs = get_filesystem (self ._base_dir , ** (self ._storage_options or {}))
356+ if storage_options is not None :
357+ cached = True
358+ cache_storage = posixpath .join (posixpath .expanduser (CACHE_DIR ), self ._base_dir .split ("://" )[- 1 ])
359+ posixpath .makedirs (cache_storage , exist_ok = True )
360+ else :
361+ cached = False
362+ cache_storage = None
363+ if not fs :
364+ fs = get_filesystem (self ._base_dir , storage_options = storage_options , cached = cached , cache_storage = cache_storage )
358365 self ._fs = fs
366+ if cached :
367+ self ._fs .sync ()
359368
360369 self ._add_modules_path ()
361370 self ._load_config ()
@@ -378,11 +387,17 @@ def _add_modules_path(self):
378387 None
379388 """
380389 if self ._fs .is_cache_fs :
381- self ._fs .sync ()
390+ self ._fs .sync_cache ()
391+ project_path = self ._fs .mapper .directory
392+ modules_path = posixpath .join (project_path , self ._pipelines_dir )
393+
394+ else :
395+ # Use the base directory directly if not using cache
396+ project_path = self ._fs .path
397+ modules_path = posixpath .join (project_path , self ._pipelines_dir )
382398
383- if self . _fs . path not in sys .path :
384- sys .path .insert (0 , self . _fs . path )
399+ if project_path not in sys .path :
400+ sys .path .insert (0 , project_path )
385401
386- modules_path = posixpath .join (self ._fs .path , self ._pipelines_dir )
387402 if modules_path not in sys .path :
388- sys .path .insert (0 , modules_path )
403+ sys .path .insert (0 , modules_path )
0 commit comments