Skip to content

[BE] Remind users to update submodule #8203

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

Merged
merged 5 commits into from
Feb 5, 2025

Conversation

larryliu0820
Copy link
Contributor

@larryliu0820 larryliu0820 commented Feb 5, 2025

Stack from ghstack (oldest at bottom):

Summary:

Fixing #7243

As titled. This PR adds 2 things:

  1. check_and_update_submodule() check if required submodule folders exist and at least contains a CMakeLists.txt file.
  2. Give useful error when the submodule is corrupted (most likely missing a file, caused by submodule out of sync).

Test Plan:

  1. Test if we can still install, if submodule is not updated
rm -rf third-party/prelude
./install_executorch.sh

See the following log

...
Processing /data/users/larryliu/executorch
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  2025-02-05 11:28:46,430 [ExecuTorch] WARNING: Some required submodules are missing. Updating submodules...
  Submodule path 'third-party/prelude': checked out '851d3f09c452937fc5adef27e2c50f7f304f1646'
  2025-02-05 11:28:46,748 [ExecuTorch] INFO: All required submodules are present.
  2025-02-05 11:28:47,018 [ExecuTorch] INFO: running dist_info
...

This proves that we can update submodule for the user.

  1. Test if we can give useful error message, if we are missing a file.
rm third-party/gflags/src/gflags.cc
./install_executorch.sh --clean
./install_executorch.sh

See the following error:

  2025-02-05 12:08:56,889 [ExecuTorch] ERROR: Failed to query buck for sources. Failed command:

     buck2 cquery inputs(deps('//runtime/executor:program'))

  This is likely due to missing git submodules or outdated CMake cache. Please run the following before retry:

      ./install_executorch.sh --clean
      git submodule update --init --recursive

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: D69156975

Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Feb 5, 2025
Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 4021ed8242b88287aae6ab24b594a00e6332d2a7
Pull Request resolved: #8203
Copy link

pytorch-bot bot commented Feb 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8203

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 5, 2025
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Summary: 

Fixing #7243

As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: 

```
rm -rf third-party/prelude
./install_executorch.sh
```
See the following error messages

```
  Command failed:
  From load at implicit location

  Caused by:
      File not found: `prelude//prelude.bzl`


  CMake Error at build/Utils.cmake:230 (message):
    executorch: source list generation failed
  Call Stack (most recent call first):
    CMakeLists.txt:386 (extract_sources)


  -- Configuring incomplete, errors occurred!
  Traceback (most recent call last):
    File "<string>", line 643, in run
    File "/home/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 388, in spawn
      spawn(cmd, search_path, dry_run=self.dry_run)
    File "/home/larryliu/miniconda3/envs/executorch/lib/python3.11/site-packages/setuptools/_distutils/spawn.py", line 68, in spawn
      raise DistutilsExecError(f"command {cmd!r} failed with exit code {exitcode}")
  distutils.errors.DistutilsExecError: command '/home/larryliu/miniconda3/envs/executorch/bin/cmake' failed with exit code 1
...
  Exception: command '/home/larryliu/miniconda3/envs/executorch/bin/cmake' failed with exit code 1
  ExecuTorch: Either CMake cache is outdated or git submodules are not synced.
  ExecuTorch: Please run the following before retry:
  ExecuTorch:    ./install_executorch.sh --clean
  ExecuTorch:    git submodule update --init --recursive

  error: subprocess-exited-with-error
```

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D69156975](https://our.internmc.facebook.com/intern/diff/D69156975)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Feb 5, 2025
Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 14d8e65e8ca2e2c9b4c0b44369817ee96061c7d6
Pull Request resolved: #8203
@mergennachin
Copy link
Contributor

What happens the submodule exists but it is out of sync, e.g., you just rebased and the underlying hash changed and the user hasn't updated?

In those cases, we should just warn people as opposed to actually syncing on their behalf.

Summary: 

Fixing #7243

As titled. This PR adds 2 things:
1. `check_and_update_submodule()` check if required submodule folders exist and at least contains a CMakeLists.txt file.
2. Give useful error when the submodule is corrupted (most likely missing a file, caused by submodule out of sync).

Test Plan: 

1. Test if we can still install, if submodule is not updated

```
rm -rf third-party/prelude
./install_executorch.sh
```
See the following log

```
...
Processing /data/users/larryliu/executorch
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  2025-02-05 11:28:46,430 [ExecuTorch] WARNING: Some required submodules are missing. Updating submodules...
  Submodule path 'third-party/prelude': checked out '851d3f09c452937fc5adef27e2c50f7f304f1646'
  2025-02-05 11:28:46,748 [ExecuTorch] INFO: All required submodules are present.
  2025-02-05 11:28:47,018 [ExecuTorch] INFO: running dist_info
...
```
This proves that we can update submodule for the user.

2. Test if we can give useful error message, if we are missing a file.

```
rm third-party/gflags/src/gflags.cc
./install_executorch.sh
```

See the following error:


Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D69156975](https://our.internmc.facebook.com/intern/diff/D69156975)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Feb 5, 2025
Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: d38b105df4783d58c416a8946db84304c2ddfd01
Pull Request resolved: #8203
Summary: 

Fixing #7243

As titled. This PR adds 2 things:
1. `check_and_update_submodule()` check if required submodule folders exist and at least contains a CMakeLists.txt file.
2. Give useful error when the submodule is corrupted (most likely missing a file, caused by submodule out of sync).

Test Plan: 

1. Test if we can still install, if submodule is not updated

```
rm -rf third-party/prelude
./install_executorch.sh
```
See the following log

```
...
Processing /data/users/larryliu/executorch
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  2025-02-05 11:28:46,430 [ExecuTorch] WARNING: Some required submodules are missing. Updating submodules...
  Submodule path 'third-party/prelude': checked out '851d3f09c452937fc5adef27e2c50f7f304f1646'
  2025-02-05 11:28:46,748 [ExecuTorch] INFO: All required submodules are present.
  2025-02-05 11:28:47,018 [ExecuTorch] INFO: running dist_info
...
```
This proves that we can update submodule for the user.

2. Test if we can give useful error message, if we are missing a file.

```
rm third-party/gflags/src/gflags.cc
./install_executorch.sh --clean
./install_executorch.sh
```

See the following error:

```
  2025-02-05 12:08:56,889 [ExecuTorch] ERROR: Failed to query buck for sources. Failed command:

     buck2 cquery inputs(deps('//runtime/executor:program'))

  This is likely due to missing git submodules or outdated CMake cache. Please run the following before retry:

      ./install_executorch.sh --clean
      git submodule update --init --recursive

```
Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D69156975](https://our.internmc.facebook.com/intern/diff/D69156975)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Feb 5, 2025
Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 4cbd0699092f8581d791b41593f63a4122b926c0
Pull Request resolved: #8203
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Summary: 

Fixing #7243

As titled. This PR adds 2 things:
1. `check_and_update_submodule()` check if required submodule folders exist and at least contains a CMakeLists.txt file.
2. Give useful error when the submodule is corrupted (most likely missing a file, caused by submodule out of sync).

Test Plan: 

1. Test if we can still install, if submodule is not updated

```
rm -rf third-party/prelude
./install_executorch.sh
```
See the following log

```
...
Processing /data/users/larryliu/executorch
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  2025-02-05 11:28:46,430 [ExecuTorch] WARNING: Some required submodules are missing. Updating submodules...
  Submodule path 'third-party/prelude': checked out '851d3f09c452937fc5adef27e2c50f7f304f1646'
  2025-02-05 11:28:46,748 [ExecuTorch] INFO: All required submodules are present.
  2025-02-05 11:28:47,018 [ExecuTorch] INFO: running dist_info
...
```
This proves that we can update submodule for the user.

2. Test if we can give useful error message, if we are missing a file.

```
rm third-party/gflags/src/gflags.cc
./install_executorch.sh --clean
./install_executorch.sh
```

See the following error:

```
  2025-02-05 12:08:56,889 [ExecuTorch] ERROR: Failed to query buck for sources. Failed command:

     buck2 cquery inputs(deps('//runtime/executor:program'))

  This is likely due to missing git submodules or outdated CMake cache. Please run the following before retry:

      ./install_executorch.sh --clean
      git submodule update --init --recursive

```
Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D69156975](https://our.internmc.facebook.com/intern/diff/D69156975)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Feb 5, 2025
Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 6236566b68a6df7d485ef74566d53c67a771eace
Pull Request resolved: #8203
@larryliu0820
Copy link
Contributor Author

@pytorchbot merge

Copy link

pytorch-bot bot commented Feb 5, 2025

Mergebot is not configured for this repository. Please use the merge button provided by GitHub.

@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@larryliu0820 larryliu0820 merged commit 35369e0 into gh/larryliu0820/60/base Feb 5, 2025
41 checks passed
@larryliu0820 larryliu0820 deleted the gh/larryliu0820/60/head branch February 5, 2025 20:38
kirklandsign pushed a commit that referenced this pull request Feb 5, 2025
Summary: As titled. This adds messages when we suspect the user forgot
to update git submodule or cleanup the CMake cache.

Test Plan: See the following error messages

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 6236566b68a6df7d485ef74566d53c67a771eace
Pull Request resolved: #8203

Co-authored-by: Mengwei Liu <[email protected]>
if missing_submodules:
logger.warning("Some required submodules are missing. Updating submodules...")
try:
subprocess.check_call(["git", "submodule", "sync"])
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like doing this in setup.py because it adds a new assumption that the code lives in git. Until now, we could build from a tarball of the entire tree outside of git. If we were going to do it anywhere I'd prefer doing it in install_executorch or install_requirements: setup.py should not be modifying its environment, only building it.

larryliu0820 added a commit that referenced this pull request Feb 7, 2025
Summary: Per comment in #8203: #8203 (comment)

Moving the logic of checking submodule and update out from setup.py and
into install_executorch.py.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
larryliu0820 added a commit that referenced this pull request Feb 7, 2025
* [BE] Move submodule check out from setup.py

Summary: Per comment in #8203: #8203 (comment)

Moving the logic of checking submodule and update out from setup.py and
into install_executorch.py.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

* lint

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

* Move submodule handling to before install requirements

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants