8000 Espnet3/install only by Masao-Someki · Pull Request #6139 · espnet/espnet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Espnet3/install only #6139

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

Open
wants to merge 86 commits into
base: espnet3
Choose a base branch
from

Conversation

Masao-Someki
Copy link
Contributor

What?

Update installation of espnet. With this PR, we can install espnet in a structured way.
E.g., pip install espnet[all], pip install espnet[core,task-asr]

Why?

The dependencies of espnet becomes very large. We wanted to split it.

See also

#6133
#6135

Note

This PR might include formatting automatically done by precommit.ci, but that will be merged to the master branch in another PR. This PR should only be merged after that PR.

Fhrozen and others added 7 commits June 11, 2025 10:26
- Included only installation-related script.
- Original commit message: Refactor Docker setup and CI configuration: update Dockerfile to use ARG for base image, streamline test scripts, and enhance .gitignore; add build image script and devcontainer configuration for Debian CI.
- I only included devcontainer document.
- original message: Refactor Dockerfile user creation logic for improved readability; add devcontainer documentation and images for better guidance.
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 11, 2025
@Masao-Someki
Copy link
Contributor Author

@Fhrozen Could you review this PR, and if there is any missing files please let me know!!

@mergify mergify bot added the Installation label Jun 11, 2025
@dosubot dosubot bot added the dependencies Pull requests that update a dependency file label Jun 11, 2025
@Fhrozen
Copy link
Member
Fhrozen commented Jun 11, 2025

@Masao-Someki Under review.

Copilot

This comment was marked as outdated.

@Masao-Someki
Copy link
Contributor Author

Thank you @Fhrozen and I didn't know that we had the copilot review! I'll definitely need that in my future PRs!
I'll fix them

Masao-Someki and others added 2 commits June 11, 2025 13:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Masao-Someki
Copy link
Contributor Author
Masao-Someki commented Jun 11, 2025

@Fhrozen just commented me that the devcontainer-related script should be the another PR, as it is not specifically related on installation.

I will remove those, and after merging the #6140 the number of files should be 5 (document, pyproject.toml, Makefile, setup.py, and .gitignore)

- I removed devcontainer-related scripts, but keet gitignore. it has pyproject.toml inside.

- original message: This reverts commit dd823c7.
@Masao-Someki Masao-Someki mentioned this pull request Jun 11, 2025
40 tasks
@mergify mergify bot added the CI Travis, Circle CI, etc label Jun 11, 2025
Comment on lines +7 to +15
try:
import hydra
from omegaconf import DictConfig, ListConfig
except ImportError:
import logging

logging.warning(
"If you are running state-space model," "run `pip install espnet['task-asr']`."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it correct?
hydra and omegaconf are related to espnet-3.
Why do they appear here?
What we need to install task-asr

Copy link
Contributor Author
@Masao-Someki Masao-Someki Jun 13, 2025

Choose a reason for hiding this comment

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

It looks like the files under espnet2/asr/state_spaces/ use Hydra and OmegaConf.
Also, opt_einsum is only used within this directory, so I’ve included these in the task-asr group...

@sw005320
Copy link
Contributor

@Masao-Someki and @Fhrozen, this might help

To reflect flake8 in the .pre-commit-config.yaml file in the @espnet/espnet repository, you should add a flake8 hook configuration under the repos: section. This ensures that flake8 will run as part of your pre-commit checks.

Here’s how you can do it:

  1. Locate .pre-commit-config.yaml
    Open the .pre-commit-config.yaml file at the root of your repository (or in the /files directory if that’s where it is).

  2. Add or Update the flake8 Hook
    Add the following block under the repos: section if it doesn’t exist, or update it if it does:

    - repo: https://github.com/pycqa/flake8
      rev: 6.1.0  # or the latest stable version
      hooks:
        - id: flake8
          additional_dependencies: []  # Add any flake8 plugins you use here
  3. Example of a Complete Section:

    repos:
      - repo: https://github.com/pycqa/flake8
        rev: 6.1.0
        hooks:
          - id: flake8
            additional_dependencies: [flake8-bugbear]
            # You can add more flake8 plugins to the array if needed
  4. Install/Update Pre-commit Hooks
    After editing the file, run:

    pre-commit install
    pre-commit autoupdate
    

Summary:

  • Add the flake8 repo block to your .pre-commit-config.yaml
  • Specify the rev (version)
  • Use the additional_dependencies list for any plugins

Would you like to see the current contents of your .pre-commit-config.yaml file to get a context-aware example?

8000

- Still investigating some of the unit tests from espnet-2.
@Masao-Someki Masao-Someki requested a review from sw005320 June 14, 2025 15:59
pyproject.toml Outdated
Comment on lines 152 to 157
all = [
"espnet[task-asr]",
"espnet[task-tts]",
"espnet[task-enh]",
"espnet[task-spk]",
]
Copy link
Contributor

Choose a reason for hiding this comment

The re 9E88 ason will be displayed to describe this comment to others. Learn more.

all does not seem to include all.
This will also cause some issues in the future when someone extends the task.
They may forget to add it to all (like you do).
Is there a way to include all tasks by using task* or something like that?

Copy link
Member

Choose a reason for hiding this comment

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

From Gemini:

That is an excellent and insightful question that explores the boundaries of what pyproject.toml is designed to do.

The short answer is no, it is not possible to use wildcards (task-*) or loops directly within the pyproject.toml file to dynamically group dependencies.

The Reason: pyproject.toml is Declarative, Not Programmatic

The `pyproject.toml file is designed to be a declarative and static configuration file. This means you declare what your project's configuration is, but you cannot include logic—like loops, conditionals, or wildcards—to compute that configuration. Its strength lies in its simplicity and predictability; any tool can read the file and know the project's metadata without executing any code.

The Standard Way: Explicitly Listing the Extras

The correct and standard way to achieve your goal is to explicitly list each extra you want to include in your my-packages group. While it may feel repetitive, it is unambiguous and the officially supported method.

# pyproject.toml

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "my-component-package"
version = "1.0.0"

# 1. Define your individual component extras
[project.optional-dependencies]
task-1 = [
    "pandas",
]
task-2 = [
    "matplotlib",
    "seaborn"
]
task-3 = [
    "scikit-learn"
]
# ...and so on for task-4, task-5, etc.

# 2. Create the group that explicitly includes the others
all-tasks = [
    "my-component-package[task-1]",
    "my-component-package[task-2]",
    "my-component-package[task-3]",
]

# You might also want a group for development tools
dev = [
    "my-component-package[all-tasks]", # Include all the above
    "pytest",
    "ruff"
]

The Advanced Way: Adding Dynamic Logic with setup.py

If you absolutely must have dynamic logic (for example, in a very complex project with dozens of auto-generated extras), you can fall back to using a setup.py script.

This involves telling pyproject.toml that the optional-dependencies are "dynamic," meaning they will be determined at build time by the build backend (setuptools) running the setup.py script.

This adds complexity and is generally not recommended unless you have a strong reason.

Conclusion

Method How It Works Pros Cons
Standard (pyproject.toml only) Explicitly list each extra in the group. Simple, clear, standard, easy for tools to analyze. Requires manual updating if you add a new task-N.
Advanced (Dynamic setup.py) Use Python code to generate the list of extras. Automated, powerful for complex scenarios. Adds complexity, dependencies are not statically visible, can be harder to debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Fhrozen Could you try copilot review? If it can detect this error, we can continue with that.

@Fhrozen Fhrozen requested a review from Copilot June 15, 2025 09:23
Copilot

This comment was marked as outdated.

@Masao-Someki
Copy link
Contributor Author

Okay, it seems we need additional test that checks all includes all dependencies. I'll prepare that in test_import_all.py

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 20, 2025
tools/Makefile Outdated
@@ -128,7 +128,9 @@ lightning.done: pytorch.done
# NOTE(kamo): conda_packages is not necessary for installation of espnet, but add it the dependencies just in case.
espnet.done: pytorch.done conda_packages.done lightning.done
@echo NUMPY_VERSION=$(shell . ./activate_python.sh && python3 -c "import numpy; print(numpy.__version__)")
cp ./setup.py ../ && mv ../pyproject.toml ../pyproject.toml.tmp
Copy link
Contributor

Choose a reason for hiding this comment

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

This must be changed.

@sw005320 sw005320 requested a review from Copilot June 20, 2025 15:35
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR restructures the ESPnet installation process by splitting the dependencies into optional groups, allowing users to install only the required extras (e.g., asr, tts, all). Key changes include updates to setup.py, Makefile, and pyproject.toml for dependency management; additions such as the uninstall_extra.py script; and modifications in task and test modules to support lazy dependency imports.

Reviewed Changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/setup.py Updated package discovery and test dependency version ranges.
tools/Makefile Added steps to temporarily move configuration files during installation.
test_utils/uninstall_extra.py Introduced a helper script to uninstall extra dependencies.
test/espnetez/test_integration_espnetez_ft.py Revised lazy imports and dependency management for inference classes.
test/espnet2/text/test_phoneme_tokenizer.py Adjusted dependency imports to handle missing packages gracefully.
pyproject.toml Split dependencies into optional groups and refined version ranges.
espnetez/task.py Converted static TASK_CLASSES to lazy imports via get_task_class.
espnet2/asr/frontend/asteroid_frontend.py Changed to lazy import asteroid_filterbanks and added an error if missing.
(Other files in tests, CI, and docs) Various adjustments to installation instructions and CI workflows for ESPnet3.
Comments suppressed due to low confidence (2)

espnet2/asr/frontend/asteroid_frontend.py:53

  • The error message in the except clause suggests installing espnet['task-spk'] even though this module belongs to ASR (front-end). Please verify whether the correct dependency group (e.g., task-asr) should be recommended.
        except ImportError:

espnet2/text/phoneme_tokenizer.py:259

  • The runtime error message for a missing 'g2p_en' dependency appears to have inconsistent formatting (e.g. unbalanced quotation/backticks). Consider revising the message for clarity and consistency.
            raise RuntimeError(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Travis, Circle CI, etc dependencies Pull requests that update a dependency file Documentation ESPnet1 ESPnet2 Installation size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0