Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Data from AIStore #11241

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Fix: Data from AIStore #11241

wants to merge 16 commits into from

Conversation

monica-sekoyan
Copy link
Collaborator

What does this PR do ?

Changing path patterns to also take into account paths starting with s3:// and adding cache manifests for NeMoLazyIterator.

Collection: common

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

Signed-off-by: monica-sekoyan <msekoyan@nvidia.com>
monica-sekoyan and others added 4 commits November 9, 2024 07:27
Signed-off-by: monica-sekoyan <monica-sekoyan@users.noreply.github.com>
Signed-off-by: monica-sekoyan <msekoyan@nvidia.com>
@github-actions github-actions bot added the core Changes to NeMo Core label Nov 13, 2024
Signed-off-by: monica-sekoyan <monica-sekoyan@users.noreply.github.com>
@@ -902,17 +902,15 @@ def setup(self, stage: Optional[str] = None):
if stage in ('fit', 'validate'):
val_deferred_setup = (
'validation_ds' in self._cfg
and self._cfg.validation_ds is not None
and not self._cfg.validation_ds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change? the change not self._cfg.validation_ds seems to be the opposite of the previous self._cfg.validation_ds is not None

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, sorry, the condition should be changed for self.test_dataloader(), as it is not None but [], corrected now

'test_ds' in self._cfg
and self._cfg.test_ds is not None
and self._cfg.test_ds.get('defer_setup', False)
'test_ds' in self._cfg and not self._cfg.test_ds and self._cfg.test_ds.get('defer_setup', False)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as @stevehuang52 raised above

@@ -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."""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lots of formatting changes that I'm not sure if necessary

Signed-off-by: monica-sekoyan <msekoyan@nvidia.com>
Signed-off-by: monica-sekoyan <msekoyan@nvidia.com>
@monica-sekoyan monica-sekoyan marked this pull request as ready for review November 13, 2024 11:44
@@ -92,6 +92,8 @@ def __init__(
self.shuffle_shards = shuffle_shards
self.shard_seed = shard_seed
paths = expand_sharded_filepaths(path)
cache_datastore_manifests(paths)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Wondering since this is not in LazyNeMoTarredIterator, and that lhotse should be able to automatically fetch and cache the data? @pzelasko what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lhotse supports URLs but doesn't perform caching. If we tried caching tarred data we would run out of local space in many cases. For non-tarred data it is probably fine as these datasets would typically be rather small.

I am not familiar with NeMo's original cache_datastore_manifests function, does it gracefully handle datasets larger than available local disk space? @monica-sekoyan @stevehuang52

@@ -46,18 +46,16 @@ def is_datastore_path(path) -> bool:
"""Check if a path is from a data object store.
Currently, only AIStore is supported.
"""
return path.startswith('ais://')
return path.startswith('ais://') or path.startswith('s3://')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change to is_valid_url(path) instead? You can use from lhotse.utils import is_valid_url or just paste

def is_valid_url(value: str) -> bool:
    try:
        result = urlparse(value)
        return bool(result.scheme) and bool(result.netloc)
    except AttributeError:
        return False

Returns:
Local path of the object.
"""
if path.startswith('ais://'):
if path.startswith('ais://') or path.startswith('s3://'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -155,7 +150,7 @@ def datastore_path_to_local_path(store_path: str) -> str:
Returns:
Path to the same object in local cache.
"""
if store_path.startswith('ais://'):
if store_path.startswith('ais://') or store_path.startswith('s3://'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -298,7 +290,7 @@ def datastore_path_to_webdataset_url(store_path: str):
Returns:
URL which can be directly used with WebDataset.
"""
if store_path.startswith('ais://'):
if store_path.startswith('ais://') or store_path.startswith('s3://'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

monica-sekoyan and others added 6 commits November 15, 2024 12:59
Signed-off-by: monica-sekoyan <msekoyan@nvidia.com>
Signed-off-by: monica-sekoyan <monica-sekoyan@users.noreply.github.com>
Signed-off-by: monica-sekoyan <msekoyan@nvidia.com>
Copy link
Contributor

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.


Your code was analyzed with PyLint. The following annotations have been identified:

************* Module nemo.collections.common.data.lhotse.nemo_adapters
nemo/collections/common/data/lhotse/nemo_adapters.py:50:0: C0301: Line too long (124/119) (line-too-long)
nemo/collections/common/data/lhotse/nemo_adapters.py:291:0: C0301: Line too long (125/119) (line-too-long)
nemo/collections/common/data/lhotse/nemo_adapters.py:292:0: C0301: Line too long (133/119) (line-too-long)
nemo/collections/common/data/lhotse/nemo_adapters.py:361:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:496:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:500:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:509:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:514:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:518:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:522:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:544:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:566:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:588:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/data/lhotse/nemo_adapters.py:24:0: W0611: Unused import lhotse.serialization (unused-import)
************* Module nemo.collections.common.parts.preprocessing.manifest
nemo/collections/common/parts/preprocessing/manifest.py:124:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/common/parts/preprocessing/manifest.py:257:0: C0301: Line too long (245/119) (line-too-long)
nemo/collections/common/parts/preprocessing/manifest.py:272:0: C0301: Line too long (162/119) (line-too-long)
nemo/collections/common/parts/preprocessing/manifest.py:27:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/common/parts/preprocessing/manifest.py:34:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/common/parts/preprocessing/manifest.py:204:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.core.classes.modelPT
nemo/core/classes/modelPT.py:82:0: C0301: Line too long (130/119) (line-too-long)
nemo/core/classes/modelPT.py:177:0: C0301: Line too long (121/119) (line-too-long)
nemo/core/classes/modelPT.py:184:0: C0301: Line too long (154/119) (line-too-long)
nemo/core/classes/modelPT.py:252:0: C0301: Line too long (131/119) (line-too-long)
nemo/core/classes/modelPT.py:256:0: C0301: Line too long (132/119) (line-too-long)
nemo/core/classes/modelPT.py:304:0: C0301: Line too long (160/119) (line-too-long)
nemo/core/classes/modelPT.py:384:0: C0301: Line too long (135/119) (line-too-long)
nemo/core/classes/modelPT.py:1226:0: C0301: Line too long (123/119) (line-too-long)
nemo/core/classes/modelPT.py:1463:0: C0301: Line too long (140/119) (line-too-long)
nemo/core/classes/modelPT.py:1674:0: C0301: Line too long (128/119) (line-too-long)
nemo/core/classes/modelPT.py:1693:0: C0301: Line too long (135/119) (line-too-long)
nemo/core/classes/modelPT.py:1703:0: C0301: Line too long (122/119) (line-too-long)
nemo/core/classes/modelPT.py:1757:0: C0301: Line too long (166/119) (line-too-long)
nemo/core/classes/modelPT.py:1826:0: C0301: Line too long (120/119) (line-too-long)
nemo/core/classes/modelPT.py:1957:0: C0301: Line too long (151/119) (line-too-long)
nemo/core/classes/modelPT.py:217:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:863:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:920:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:924:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:931:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:1199:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:1623:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/core/classes/modelPT.py:1741:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.65/10

Thank you for improving NeMo's documentation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common core Changes to NeMo Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants