witty-family-13337
02/10/2022, 8:25 AMGenerateSourcesRequest
-based rules. Assuming that I’ve got a target like mytarget(sources=['source1.ext', 'source2.ext'])
and then I write a custom GenerateMySourcesRequest
like:
class GenerateMySourcesRequest(GenerateSourcesRequest):
input = MySourcesField
output = MyGeneratedSourcesField
How or where does Pants attach that MyGeneratedSourcesField
referenced in the output? Does Pants create a target on the fly with that field or does it simply attach the field to the original mytarget
?curved-television-6568
02/10/2022, 9:28 AMcodegen
rule. What it does, it takes your input sources (the sources from the MySourcesField
) which are associated with your mytarget
and using your codegen rule, translates those into MyGeneratedSourcesField
sources.
The generated sources are not directly addressable besides being requested via codegen, but are instead consumed along with any other sources you may have. In other words, they’re simply generated ad-hoc when requested.
Here’s a trail for such a codegen request:
https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/python/util_rules/python_sources.py#L88-L95
https://github.com/pantsbuild/pants/blob/main/src/python/pants/core/util_rules/source_files.py#L54-L58
https://github.com/pantsbuild/pants/blob/main/src/python/pants/engine/internals/graph.py#L836-L840
And in order for your codegen rule to work, you need to register your union member as UnionRule(GenerateSourcesRequest, GenerateMySourcesRequest)
.
Hope this makes it more clear, but plz do send any follow up questions 🙂witty-family-13337
02/10/2022, 9:37 AMmytarget
and a codegen rule that generates some additional files from the sources
field of mytarget
, and wanted to be able to collect the files referenced in the sources
field plus the generated ones when using SourceFilesRequest
fast-nail-55400
02/10/2022, 12:44 PMenable_codegen=True
for SourceFilesRequest
for_sources_types
)SourceFilesRequest
one with enable_codegen=False
and the other with enable_codegen=True
Digest
’s using MergeDigests
curved-television-6568
02/10/2022, 12:59 PMwitty-family-13337
02/10/2022, 1:42 PM./pants export-codegen
is indeed generating the files but SourceFilesRequest
is not returning them even when I add enable_codegen=True
and the field type that is used in the GenerateSourcesRequest.output
field. The original sources are returned properly thoughGenerateSourcesRequest.input
and GenerateSourcesRequest.output
fields are of different type but in the same target, though that could be an issue but seeing Andreas example now I just discarded that could be reason it doesn’t seem to workfast-nail-55400
02/10/2022, 1:47 PMhundreds-father-404
02/10/2022, 3:06 PMGenerateSourcesRequest.output
is what you are generating into, and that for_sources_types
includes that
Also double checking you have the UnionRule
registered for GenerateSourcesRequest
, although it sounds like you do with export-codegen
workingwitty-family-13337
02/10/2022, 3:59 PMcurved-television-6568
02/14/2022, 11:33 AMwitty-family-13337
02/14/2022, 1:20 PMcurved-television-6568
02/14/2022, 1:30 PMdeploy
goal has floated around the last couple of days, I think helm
support would be a sweet addition along side ansible.. 🙂 (as we happen to use both of those technologies at work)witty-family-13337
02/14/2022, 2:13 PMhelm_chart
(first party custom charts),helm_artifact
(third party helm charts) and helm_deployment
(helm configuration for a given deployment) and it’s capable of inferring dependencies among them and with other Docker images built in the same repo, although it is a bit rough around the edgeshundreds-father-404
02/14/2022, 3:33 PMwitty-family-13337
02/14/2022, 4:04 PMpolite-garden-50641
02/14/2022, 6:52 PMcurved-television-6568
02/14/2022, 7:11 PMpolite-garden-50641
02/14/2022, 7:17 PMcurved-television-6568
02/14/2022, 7:24 PMwitty-family-13337
02/15/2022, 8:06 AMunittest
plugin to run tests, instead of helm test
, we generate README.md
doc files using helm-docs
, etc. etc.) so the version hell problem is quite present in Helm projects (either in relation to the build artifacts or to the versions of the tools being used), specially those that involve medium to large systems.curved-television-6568
02/15/2022, 8:47 AMhundreds-father-404
02/15/2022, 9:00 AM./pants run
because Pants has no value running the bash script for you
With Helm, that would mean integrating with things like helm test
and helm-docs
, but leaving the actual side-effecty deploy for you to do directlywitty-family-13337
02/15/2022, 10:51 AM