Skip to content
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

Difference between constraints and warnings? (and complex checks) #1322

Open
chrisjsewell opened this issue Oct 8, 2024 · 3 comments
Open

Comments

@chrisjsewell
Copy link
Member

chrisjsewell commented Oct 8, 2024

needs_constraints and needs_warnings (and to a lesser extent need_statuses and need_tags) are very similar in their function:

prohibit/warn about problematic needs

It is unclear to me why there needs to be two concepts for this, I feel that it is possible they could be merged and essentially warnings are a sub-set of constraints that apply to all needs (as opposed to usually constraint "sets" are specified by the need).

At a minimum, this functionality should be expanded on in: https://sphinx-needs.readthedocs.io/en/latest/tutorial.html#enforcing-valid-need-items

It is also of note that for both of these concepts, more complex checks involving all needs have been requested: #1217, #1238, which neither currently support directly.


It is of note that, if warnings were merged with constraints (or called at the same time), AND we improve the detection of need modifications, these may not need to be re-computed for every re-build (as is the case now)


One note-to-self here is that possibly the needs should be "sealed" before checking for constraints here:

process_constraints(needs, needs_config)
,
then constraints/warnings would be processed, allowing for access to the immutable NeedsView, and then the constraints_ fields would be updated as a "special exception" to sealing the needs

@chrisjsewell chrisjsewell self-assigned this Oct 8, 2024
@chrisjsewell chrisjsewell changed the title Difference between constraints and warnings? Difference between constraints and warnings? (and complex checks) Oct 8, 2024
@ubmarco
Copy link
Member

ubmarco commented Oct 28, 2024

I completely agree with @chrisjsewell on this write-up. needs-constraint-failed-options make it possible to end up with the same behavior as needs_warnings.
Additionally needs_constraints integrate with the individual needs, so the result can be used for rendering and later consumption in the needs dictionary.

I also agree on sealing the needs before evaluating the constraints.

@danwos
Copy link
Member

danwos commented Oct 28, 2024

I'm not 100% sure if we cover here all use cases.
A Constraint allows to set custom user text, if it fails. So the user get feedback in the docs, and maybe help what to change. Warnings as of now do not support such a custom feedback,or am I wrong?

An example of such an integration can be found here: https://sphinx-needs-demo.readthedocs.io/en/latest/teen_car/requirements.html#TEEN_AUTO (process feedback)

@chrisjsewell
Copy link
Member Author

Warnings as of now do not support such a custom feedback,or am I wrong?

but then doesn't that support my assertion that warnings are just a sub-set of constraints 😅 (i.e. we can deprecate warnings without any loss of functionality)

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

No branches or pull requests

3 participants