-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add recursive argument to spack develop #46885
base: develop
Are you sure you want to change the base?
Conversation
This effort allows for a recursive develop call which will traverse from the develop spec given back to the root(s) and mark all packages along the path as develop. If people are doing development across the graph then paying fetch and full rebuild costs every time spack develop is called is unnecessary and expensive. Also remove the constraint for concrete specs and simply take the max(version) if a version is not given. This should default to the highest infinity version which is also the logical best guess for doing development.
c7dccf3
to
b2ff04b
Compare
Can you split this into two PRs -- one for the removal of the constraint and the other for the recursive option? |
I put them together because the recursive makes sense to default to just the package name since it is already concretized. So we should do remove constraint first and then recursive dependent on that merging IMO. |
I started a unit-test for this, but it's looking like a big lift at the moment. It needs a concretized environment to work, and so far all I've found is mock concretization of a spec. Seems like a notable gap in our testing infrastructure but would dramatically extend the scope of this PR to implement and should be a PR in and of itself IMHO. |
Testing this locally for now: $ spack env activate --temp
$ spack add exawind
$ spack concretize
$ spack develop -r trilinos
# trilinos actually has a fetch error that I've documented but never fixed #25370
$ spack develop -r trilinos
# clones see yaml file below # This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
# add package specs to the `specs` list
specs:
- exawind
view: true
concretizer:
unify: true
develop:
nalu-wind:
spec: nalu-wind@=master
exawind:
spec: exawind@=master
trilinos:
spec: trilinos@=16.0.0 |
@haampie this should meet your |
I doesn't: what I meant was I want be able to select an individual spec from a concrete env, so that the following: ![]() would take the matching curl@8.4.0 and add I don't want to run Also, apparently ![]() So, in short: I wanna be able to add |
Ah well I can add the single spec logic to this PR (prefer concrete if a version is omitted), but me thinks skipping re-concretization is a more fundamental change for another PR. |
Thinking about this more I think to skip concretization we'd likely need to change how develop is recognized (make it an environment property rather than a spec property). It messes with a lot of fundamental stuff though. The other option I can think of is a surgical change to the DAG. Modify specs, change hashes, but don't actually solve. |
Note that
Yeah, this is my suggestion too. In my opinion a major flaw in the develop command is that you don't know what to develop until the env is concretized, yet it wants to fetch sources ahead of time (including resources and patches which depend on variants, compiler choices). The order should've been: concretize first, then mark things as dev spec, then fetch sources. |
@haampie That order makes sense to me. The only reason I see develop needs to be part of the spec with a variant is to mark for differentiation of the install/future reuse. From an install point dev spec doesn't really matter? I guess it does in that you probably don't want to reuse a develop spec or rather don't want it masquerading as something it is not. Other than that I think it should be an environment property and not a spec property with the order you outlined. Oh and hash computation. New variant ensures new hash. I do like that develop can happen pre concretization for reuse of developer environments etc, but I don't see why that would have to change. I suspect that the install situation could be alleviated by not installing develop specs or their dependents into the same install tree. Have it be a special one. That actually aligns well with another request of having develop specs link and possibly rebuild out of a build tree and skip installation all together. Rational being linking to build directly means tighter changes (update a header and not have to reinstall just rebuild) and less file system work. |
@spackbot fix style |
Let me see if I can fix that for you! |
I was able to run spack style --fix==> Running style checks on spack
selected: isort, black, flake8, mypy
==> Modified files
lib/spack/spack/cmd/develop.py
lib/spack/spack/test/cmd/develop.py
var/spack/repos/builtin.mock/packages/indirect-mpich/package.py
==> Running isort checks
Fixing /tmp/tmpt0b_m93s/spack/lib/spack/spack/test/cmd/develop.py
isort checks were clean
==> Running black checks
All done! ✨ 🍰 ✨
3 files left unchanged.
black checks were clean
==> Running flake8 checks
lib/spack/spack/cmd/develop.py:93: [E501] line too long (100 > 99 characters)
lib/spack/spack/test/cmd/develop.py:247: [F841] local variable 'specs' is assigned to but never used
flake8 found errors
==> 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]
lib/spack/spack/variant.py:131: error: Unsupported right operand type for in ("Union[Collection[Any], Callable[..., Any]]") [operator]
Found 4 errors in 2 files (checked 620 source files)
mypy found errors
I've updated the branch with style fixes. |
Co-authored-by: Greg Becker <becker33@llnl.gov>
this cached value is not properly invalidated when develop config is written, as in the `spack develop` command. Some accesses are accidentally correct because a read or write transaction on the environment will invalidate the `self._dev_specs` as a side-effect. Considered adding invalidation but determined it was not worth the effort to bridge the gap in interface between `spack.config` and `spack.environment`.
@@ -38,28 +40,22 @@ def setup_parser(subparser): | |||
"--clone", | |||
action="store_true", | |||
dest="clone", | |||
default=None, | |||
default=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change -- this seems to suggest in the default case we clone regardless of whether the path is already cloned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is suggesting we call the _clone
method and attempt to clone. Additional checks are there to explain why we skip cloning. It's been a while but IIRC the logic was embedded off state of None
True
or False
before. But for a recursive clone we need better inferences that I moved inside a method.
@spackbot fix style |
Let me see if I can fix that for you! |
I was able to run spack style --fix==> Running style checks on spack
selected: import, isort, black, flake8, mypy
==> Modified files
lib/spack/spack/cmd/develop.py
lib/spack/spack/environment/environment.py
lib/spack/spack/test/cmd/develop.py
var/spack/repos/builtin.mock/packages/indirect-mpich/package.py
==> Running import checks
import check requires Python 3.9 or later
import checks were clean
==> Running isort checks
isort checks were clean
==> Running black checks
reformatted lib/spack/spack/cmd/develop.py
All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
black checks were clean
==> Running flake8 checks
flake8 checks were clean
==> Running mypy checks
lib/spack/spack/version/version_types.py:134: error: Incompatible types in assignment (expression has type "Tuple[Any, ...]", variable has type "Tuple[str]") [assignment]
lib/spack/spack/variant.py:130: error: Unsupported right operand type for in ("Union[Collection[Any], Callable[..., Any]]") [operator]
lib/spack/spack/build_environment.py:171: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
lib/spack/spack/build_environment.py:171: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [misc]
Found 4 errors in 3 files (checked 636 source files)
mypy found errors
I've updated the branch with style fixes. |
lib/spack/spack/cmd/develop.py
Outdated
version = matching_specs[0].version | ||
test_spec = spack.spec.Spec(f"{spec}@{version}") | ||
for m_spec in matching_specs: | ||
if not test_spec.satisfies(m_spec): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be
if not test_spec.satisfies(m_spec): | |
if not test_spec.intersects(m_spec): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order was wrong here. we should be checking that all the matching specs in the environment satisfy the test spec which was constructed from the name and version of the first matching spec.
@spackbot fix style |
Let me see if I can fix that for you! |
I was able to run spack style --fix==> Running style checks on spack
selected: import, isort, black, flake8, mypy
==> Modified files
lib/spack/spack/cmd/develop.py
lib/spack/spack/environment/environment.py
lib/spack/spack/test/cmd/develop.py
var/spack/repos/builtin.mock/packages/indirect-mpich/package.py
==> Running import checks
import checks were clean
==> Running isort checks
isort checks were clean
==> Running black checks
reformatted lib/spack/spack/cmd/develop.py
All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
black checks were clean
==> Running flake8 checks
flake8 checks were clean
==> Running mypy checks
Success: no issues found in 637 source files
mypy checks were clean
==> spack style checks were clean
I've updated the branch with style fixes. |
This effort allows for a recursive develop call
which will traverse from the develop spec given back to the root(s) and mark all packages along the path as develop.
If people are doing development across the graph then paying fetch and full rebuild costs every time
spack install
is called is unnecessary and expensive. Since this requires an already concrete environment the exact versions can be used and there is no need to guess or provide versions for concrete specs.Additional changes:
--path
or--build-directory
.max(package_class.versions)