Skip to content

clean up concreteness detection#5332

Merged
tgamblin merged 4 commits intodevelopfrom
feature/better-concreteness-behavior
Sep 12, 2017
Merged

clean up concreteness detection#5332
tgamblin merged 4 commits intodevelopfrom
feature/better-concreteness-behavior

Conversation

@tgamblin
Copy link
Copy Markdown
Member

@tgamblin tgamblin commented Sep 11, 2017

Fixes #5281.
@obreitwi @ax3l @alalazo @scheibelp @healther

  • Fixes bugs where concretization would fail due to an erroneously cached
    _concrete attribute.

  • Ripped out a bunch of code in spec.py that isn't needed/valid anymore:

    • The various concrete() methods on different types of Specs would
      attempt to statically compute whether the Spec was concrete.
    • This dates back to when DAGs were simpler and there were no optional
      dependencies. It's actually NOT possible to compute statically
      whether a Spec is concrete now. The ONLY way you know is if it goes
      through concretization and is marked concrete once that completes.
    • This commit removes all simple concreteness checks and relies only on
      the _concrete attribute. This should make thinking about
      concreteness simpler.
  • Fixed a couple places where Specs need to be marked concrete explicitly.

    • Specs read from files and Specs that are destructively copied from
      concrete Specs now need to be marked concrete explicitly.
    • These spots may previously have "worked", but they were brittle and
      should be explcitly marked anyway.
  • Fixed bug - _dup() and _dup_deps() that would lose cached
    concreteness of dependencies.

- Dependencies in concrete specs did not previously have their cache
  fields (_concrete, _normal, etc.) preserved.

- _dup and _dup_deps weren't passing each other enough information to
  preserve concreteness properly, so only the root was properly
  preserved.

- cached concreteness is now preserved properly for the entire DAG, not
  just the root.

- added method docs.
@tgamblin
Copy link
Copy Markdown
Member Author

@adamjstewart and everyone else should be happy because this pretty much gets rid of the distinction between concrete and _concrete. The only way you have a concrete spec now is if you concretize a spec.

@tgamblin
Copy link
Copy Markdown
Member Author

Note that this should be rebased; commits here are meaningful.

@tgamblin tgamblin requested a review from scheibelp September 11, 2017 19:03
@scheibelp
Copy link
Copy Markdown
Member

I'll be able to look at this by the end of today.

Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

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

💯 This PR just feels right.

# in build caches are concrete (as they aer built) so
# we need to mark this spec concrete on read-in.
spec = spack.spec.Spec.from_yaml(f)
spec._mark_concrete()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This stuff actually comes out in testing with the new changes. Before it would slip by and could potentially be wrong.


# satisfy_condition = self.owner.satisfies(
# condition, strict=True
# )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am so glad we removed this function. Fixing it following the old logic would have been a real pain.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixing it following the old logic would essentially require reimplementing concretize() 😄 . I looked at that function as part of the work on dependency patching and it's also just wrong. It's the fact that these concrete() functions are still called lazily as part of concretize() that was screwing everything up -- they weren't really intended to do that. Spec is going to get a lot nicer soon.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

and yes this function is horrible.

@tgamblin tgamblin removed the request for review from scheibelp September 11, 2017 20:46
@tgamblin
Copy link
Copy Markdown
Member Author

@scheibelp: I removed the review request since @alalazo got to it first, but feel free to review this if you want.

- Fixes bugs where concretization would fail due to an erroneously cached
  _concrete attribute.

- Ripped out a bunch of code in spec.py that isn't needed/valid anymore:
  - The various concrete() methods on different types of Specs would
    attempt to statically compute whether the Spec was concrete.
  - This dates back to when DAGs were simpler and there were no optional
    dependencies.  It's actually NOT possible to compute statically
    whether a Spec is concrete now.  The ONLY way you know is if it goes
    through concretization and is marked concrete once that completes.
  - This commit removes all simple concreteness checks and relies only on
    the _concrete attribute.  This should make thinking about
    concreteness simpler.

- Fixed a couple places where Specs need to be marked concrete explicitly.
  - Specs read from files and Specs that are destructively copied from
    concrete Specs now need to be marked concrete explicitly.
  - These spots may previously have "worked", but they were brittle and
    should be explcitly marked anyway.
@tgamblin tgamblin force-pushed the feature/better-concreteness-behavior branch from d6ea85b to bbd10a6 Compare September 11, 2017 20:57
@scheibelp
Copy link
Copy Markdown
Member

@scheibelp: I removed the review request since @alalazo got to it first, but feel free to review this if you want.

OK - I think @alalazo's review is sufficient. If I have any comment it's that it it would be nice to write _concrete to yaml and in Spec.to_node_dict to avoid requiring one to have to think about when they should explicitly mark a spec as concrete. For example I wanted to make sure that specs read in Database were marked concrete (and after checking into it, _read_from_file does that). I don't think that needs to happen here though.

I can't actually merge it (since the mac tests didn't complete) but I assume you will do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants