Skip to content

Add options for sparse checkout in GitFetcher#45473

Merged
psakievich merged 18 commits intospack:developfrom
psakievich:f/git-sparse-checkout
Aug 15, 2024
Merged

Add options for sparse checkout in GitFetcher#45473
psakievich merged 18 commits intospack:developfrom
psakievich:f/git-sparse-checkout

Conversation

@psakievich
Copy link
Copy Markdown
Contributor

@psakievich psakievich commented Jul 26, 2024

Newer versions of git have a beta feature called sparse checkout that allow users to check out a portion of a large repo.

This feature will be ideal for monolithic repo projects that want to model their infrastructure via spack. This PR implements an addition to the GitFetcher that allows users to add a git_sparse_paths attribute to package classes or versions which will then use sparse checkout on those directories/files for the package.

Steps for completion

  • Add in git_sparse_paths attribute and test it can be called for versions and package attributes
  • Update git fetch calls to operate with sparse fetch under these conditions
  • Update unit-test infrastructure to handle case with sparse checkout
  • Test on a live application
  • Update documentation

This PR also refactors the GitFetcher.clone method to break it up into somewhat smaller functions. This is to improve readability and compatibility with further refactors with #44319 when we will be able to do the vast majority of git clones per commit instead per branch/tag.

Newer versions of git have a beta feature called sparse checkout
that allow users to check out a portion of a large repo.

This feature will be ideal for monolithic repo projects that want to
model their infrastructure via spack.  This PR implements an addition
to the GitFetcher that allows users to add a `git_sparse_paths`
attribute to package classes or versions which will then use sparse
checkout on those directories/files for the package.
@spackbot-app spackbot-app bot added core PR affects Spack core functionality fetching new-version tests General test capability(ies) labels Jul 26, 2024
@spackbot-app spackbot-app bot added the documentation Improvements or additions to documentation label Aug 1, 2024
@psakievich
Copy link
Copy Markdown
Contributor Author

@spackbot fix-style

@psakievich
Copy link
Copy Markdown
Contributor Author

@spackbot fix style

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 6, 2024

Let me see if I can fix that for you!

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 6, 2024

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, black, flake8, mypy
==> Modified files
  lib/spack/spack/fetch_strategy.py
  lib/spack/spack/test/conftest.py
  lib/spack/spack/test/git_fetch.py
  lib/spack/spack/test/packages.py
  lib/spack/spack/version/git_ref_lookup.py
  var/spack/repos/builtin.mock/packages/git-monorepo-mock/package.py
==> Running isort checks
  isort checks were clean
==> Running black checks
reformatted lib/spack/spack/test/git_fetch.py
reformatted lib/spack/spack/test/conftest.py
All done! ✨ 🍰 ✨
2 files reformatted, 4 files left unchanged.
  black checks were clean
==> Running flake8 checks
  flake8 checks were clean
==> Running mypy checks
lib/spack/spack/version/version_types.py:145: error: Argument 2 to "StandardVersion" has incompatible type "*Tuple[Tuple[Any, ...], Tuple[Any, ...]]"; expected "Tuple[Tuple[Any, ...], Tuple[Any, ...]]"  [arg-type]
lib/spack/spack/version/version_types.py:452: error: Argument 2 to "StandardVersion" has incompatible type "*Tuple[Tuple[Any, ...], Tuple[Any, ...]]"; expected "Tuple[Tuple[Any, ...], Tuple[Any, ...]]"  [arg-type]
lib/spack/spack/version/version_types.py:481: error: Argument 2 to "StandardVersion" has incompatible type "*Tuple[Tuple[Any, ...], Tuple[Any, ...]]"; expected "Tuple[Tuple[Any, ...], Tuple[Any, ...]]"  [arg-type]
Found 3 errors in 1 file (checked 621 source files)
  mypy found errors
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with style fixes.

@psakievich psakievich marked this pull request as ready for review August 8, 2024 03:55
@tgamblin tgamblin self-requested a review August 8, 2024 19:30
@mdmosby
Copy link
Copy Markdown
Contributor

mdmosby commented Aug 8, 2024

We are modeling the internal products in the SIERRA code suite as spack packages and this sparse checkout feature is reducing the fetch times from O(min) to O(s) for each package and there are O(50) packages and growing (we are actively converting things). This is a huge win for us in monorepo land!

@psakievich
Copy link
Copy Markdown
Contributor Author

@spackbot fix style

@psakievich psakievich enabled auto-merge (squash) August 14, 2024 19:39
@psakievich psakievich merged commit 1b82779 into spack:develop Aug 15, 2024
@psakievich psakievich deleted the f/git-sparse-checkout branch August 15, 2024 14:29
Chrismarsh pushed a commit to Chrismarsh/spack that referenced this pull request Aug 16, 2024
* Add options for sparse checkout in GitFetcher

Newer versions of git have a beta feature called sparse checkout
that allow users to check out a portion of a large repo.

This feature will be ideal for monolithic repo projects that want to
model their infrastructure via spack.  This PR implements an addition
to the GitFetcher that allows users to add a `git_sparse_paths`
attribute to package classes or versions which will then use sparse
checkout on those directories/files for the package.

* Style

* Split git clone into multiple functions

* Add sparse-checkout impl

* Internalize src clone functions

* Docs

* Adding sparse clone test

* Add test for partial clone

* [@spackbot] updating style on behalf of psakievich

* Small fixes

* Restore default branch status

* Fix attributes for package

* Update lib/spack/docs/packaging_guide.rst

Co-authored-by: Matthew Mosby <[email protected]>

* Extend unit test to multiple git versions

* style

---------

Co-authored-by: psakievich <[email protected]>
Co-authored-by: Matthew Mosby <[email protected]>
tldahlgren pushed a commit to AcriusWinter/spack that referenced this pull request Aug 20, 2024
* Add options for sparse checkout in GitFetcher

Newer versions of git have a beta feature called sparse checkout
that allow users to check out a portion of a large repo.

This feature will be ideal for monolithic repo projects that want to
model their infrastructure via spack.  This PR implements an addition
to the GitFetcher that allows users to add a `git_sparse_paths`
attribute to package classes or versions which will then use sparse
checkout on those directories/files for the package.

* Style

* Split git clone into multiple functions

* Add sparse-checkout impl

* Internalize src clone functions

* Docs

* Adding sparse clone test

* Add test for partial clone

* [@spackbot] updating style on behalf of psakievich

* Small fixes

* Restore default branch status

* Fix attributes for package

* Update lib/spack/docs/packaging_guide.rst

Co-authored-by: Matthew Mosby <[email protected]>

* Extend unit test to multiple git versions

* style

---------

Co-authored-by: psakievich <[email protected]>
Co-authored-by: Matthew Mosby <[email protected]>
FrederickDeny pushed a commit to FrederickDeny/spack that referenced this pull request Aug 26, 2024
* Add options for sparse checkout in GitFetcher

Newer versions of git have a beta feature called sparse checkout
that allow users to check out a portion of a large repo.

This feature will be ideal for monolithic repo projects that want to
model their infrastructure via spack.  This PR implements an addition
to the GitFetcher that allows users to add a `git_sparse_paths`
attribute to package classes or versions which will then use sparse
checkout on those directories/files for the package.

* Style

* Split git clone into multiple functions

* Add sparse-checkout impl

* Internalize src clone functions

* Docs

* Adding sparse clone test

* Add test for partial clone

* [@spackbot] updating style on behalf of psakievich

* Small fixes

* Restore default branch status

* Fix attributes for package

* Update lib/spack/docs/packaging_guide.rst

Co-authored-by: Matthew Mosby <[email protected]>

* Extend unit test to multiple git versions

* style

---------

Co-authored-by: psakievich <[email protected]>
Co-authored-by: Matthew Mosby <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core PR affects Spack core functionality documentation Improvements or additions to documentation fetching new-version tests General test capability(ies) versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants