Skip to content

Commit

Permalink
Merge branch 'msekoyan/aistore_data_fix' of https://github.com/NVIDIA…
Browse files Browse the repository at this point in the history
…/NeMo into msekoyan/aistore_data_fix
  • Loading branch information
monica-sekoyan committed Nov 13, 2024
2 parents 72ab075 + 0ee3a64 commit 5e4ee06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion nemo/collections/common/data/lhotse/nemo_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(
self.shard_seed = shard_seed
paths = expand_sharded_filepaths(path)
cache_datastore_manifests(paths)

if len(paths) == 1:
self.source = LazyJsonlIterator(paths[0])
else:
Expand Down
28 changes: 10 additions & 18 deletions nemo/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ def is_datastore_path(path) -> bool:


def is_tarred_path(path) -> bool:
"""Check if a path is for a tarred file.
"""
"""Check if a path is for a tarred file."""
return path.endswith('.tar')


def is_datastore_cache_shared() -> bool:
"""Check if store cache is shared.
"""
"""Check if store cache is shared."""
# Assume cache is shared by default, e.g., as in resolve_cache_dir (~/.cache)
cache_shared = int(os.environ.get(constants.NEMO_ENV_DATA_STORE_CACHE_SHARED, 1))

Expand All @@ -70,8 +68,7 @@ def is_datastore_cache_shared() -> bool:


def ais_cache_base() -> str:
"""Return path to local cache for AIS.
"""
"""Return path to local cache for AIS."""
override_dir = os.environ.get(constants.NEMO_ENV_DATA_STORE_CACHE_DIR, "")
if override_dir == "":
cache_dir = resolve_cache_dir().as_posix()
Expand All @@ -85,8 +82,7 @@ def ais_cache_base() -> str:


def ais_endpoint() -> str:
"""Get configured AIS endpoint.
"""
"""Get configured AIS endpoint."""
return os.getenv('AIS_ENDPOINT')


Expand Down Expand Up @@ -114,7 +110,7 @@ def ais_endpoint_to_dir(endpoint: str) -> str:
Args:
endpoint: AIStore endpoint in format https://host:port
Returns:
Directory formed as `host/port`.
"""
Expand All @@ -127,8 +123,7 @@ def ais_endpoint_to_dir(endpoint: str) -> str:


def ais_binary() -> str:
"""Return location of `ais` binary.
"""
"""Return location of `ais` binary."""
path = shutil.which('ais')

if path is not None:
Expand Down Expand Up @@ -178,7 +173,7 @@ def get_datastore_object(path: str, force: bool = False, num_retries: int = 5) -
path: path to an object
force: force download, even if a local file exists
num_retries: number of retries if the get command fails
Returns:
Local path of the object.
"""
Expand Down Expand Up @@ -247,14 +242,12 @@ def __init__(self, store_path: str, local_path: str = None, get: bool = False):

@property
def store_path(self) -> str:
"""Return store path of the object.
"""
"""Return store path of the object."""
return self._store_path

@property
def local_path(self) -> str:
"""Return local path of the object.
"""
"""Return local path of the object."""
return self._local_path

def get(self, force: bool = False) -> str:
Expand Down Expand Up @@ -283,8 +276,7 @@ def put(self, force: bool = False) -> str:
raise NotImplementedError()

def __str__(self):
"""Return a human-readable description of the object.
"""
"""Return a human-readable description of the object."""
description = f'{type(self)}: store_path={self.store_path}, local_path={self.local_path}'
return description

Expand Down

0 comments on commit 5e4ee06

Please sign in to comment.