-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Synthesized lockfile targets should never err on missing lockfiles. #18406
Conversation
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 seems like a lot of code, to avoid a one-time problem. Why not just not synthesize the target when the source doesn't exist?
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.
To clarify my comment - we're carving out some new and non-trivial functionality here (namely a target that can confusingly override global glob matching error behavior) just to handle a situation with a synthetic target the user didn't define or know about to begin with.
The purpose of the target is to track deps on the file when it changes, but since it is allowed to not exist, in that case I think it's better - and simpler - to just not synthesize it in the first place.
Can you depend on a synthesized target? Eg, if I wanted to include a lockfile in an Logically, the target does exist, but it has to be synthesized from the contents of pants.toml, not from something defined in a BUILD file. So, I would be surprised if a resolve I explicitly defined (in pants.toml) did not get the synthesized target just because I haven't generated the lockfile yet. From a different angle: lockfiles are like codegen, but unlike codegen, it gets materialized in the workspace, not under |
The fact that the user didn't know about the target to me contradicts the argument that it would be confusing to not adhere to the global glob matching error behavior.
Although the lockfile is allowed to not exist, that is an intermediate broken state of affairs as we know where it is supposed to exist. I agree that the idea with checking for the existence and not synthesize the |
Yes, that was the primary motivation to introduce synthetic targets, to be able to depend on the generated lockfiles. Not in order to include them, but for identifying targets for changed since when you have regenerated lockfiles. pants/src/python/pants/backend/python/macros/common_requirements_rule.py Lines 77 to 110 in c9def21
Thank you. Although the connection between the synthesized target and the source file is looser than for codegen, I agree that we have all the pieces to expect the target to exist, also when the actual source file it represents is not there.
Another difference here is that the synthetic target plays no role in the materialization of the source files, so to me it makes little sense in having codegen involved at all here. |
@cognifloyd there's also #17253 for more context (and linked PR #16998) |
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 love it - simpler code yet more functionality!
Eh... hrrm. It seems to me that this fix never actually worked to begin with 😞 😬 Thanks for discovering @danxmoran -- I'll look into it right away. |
Fixes pantsbuild#18933 (and pantsbuild#18404). Original attempt at fixing this but failed was in pantsbuild#18406 due to an oversight that it was the `_lockfiles` target generator with a `sources` field that was being synthesized, not the `_lockfile` target with a single `source` file only. Either use should work equally well, and now they do.
Fixes #18933 (and #18404). Original attempt at fixing this but failed was in #18406 due to an oversight that it was the `_lockfiles` target generator with a `sources` field that was being synthesized, not the `_lockfile` target with a single `source` file only. Either use should work equally well, and now they do.
Fixes pantsbuild#18933 (and pantsbuild#18404). Original attempt at fixing this but failed was in pantsbuild#18406 due to an oversight that it was the `_lockfiles` target generator with a `sources` field that was being synthesized, not the `_lockfile` target with a single `source` file only. Either use should work equally well, and now they do.
Fixes pantsbuild#18933 (and pantsbuild#18404). Original attempt at fixing this but failed was in pantsbuild#18406 due to an oversight that it was the `_lockfiles` target generator with a `sources` field that was being synthesized, not the `_lockfile` target with a single `source` file only. Either use should work equally well, and now they do.
Fixes #18933 (and #18404). Original attempt at fixing this but failed was in #18406 due to an oversight that it was the `_lockfiles` target generator with a `sources` field that was being synthesized, not the `_lockfile` target with a single `source` file only. Either use should work equally well, and now they do.
Fixes #18933 (and #18404). Original attempt at fixing this but failed was in #18406 due to an oversight that it was the `_lockfiles` target generator with a `sources` field that was being synthesized, not the `_lockfile` target with a single `source` file only. Either use should work equally well, and now they do.
Fixes #18404