fresh-cat-90827
04/18/2024, 2:58 PMfiles target generator and have issues with the caching ๐งตfresh-cat-90827
04/18/2024, 2:58 PMfrom pants.engine.target import COMMON_TARGET_FIELDS, SingleSourceField, Target
class ProjectVersionSourceField(SingleSourceField):
alias = "source"
help = "Path to the file with the project version."
default = "VERSION"
required = False
class ProjectVersionTarget(Target):
alias = "version_file"
core_fields = (*COMMON_TARGET_FIELDS, ProjectVersionSourceField)
help = "A project version target representing the VERSION file."
I also have a python_test target in addition to the instance of that custom target:
version_file(
name="main-project-version",
source="VERSION",
)
python_tests(
name="tests",
dependencies=[
":main-project-version",
],
)
When I run pants test tests/cli , it runs fine, caching the results. I expect that after I modify the contents of the VERSION file used by that target, the test target should be considered changed and the --changed-since does suggest that this is the case since the dependencies have been declared correctly.
However, caching mechanism is broken - no matter the changes made to the VERSION file, the test never actually runs, relying on the local cache.
I think I may need to request some kind of rule for this target so that the digest of the files could be evaluated to invalidate the cache, but not sure what should it be? Replacing the custom target with the file built-in target makes caching works fine again upon subsequent changes to the VERSION file.fresh-cat-90827
04/18/2024, 3:00 PMawait Get(Digest, PathGlobs([f"{target.address.spec_path}**/*"])) , but I am not sure what union rule should that be part of, if any? ๐fresh-cat-90827
04/18/2024, 4:18 PMcurved-television-6568
04/18/2024, 6:53 PMcurved-television-6568
04/18/2024, 6:54 PMversion_file into a file file..fresh-cat-90827
04/19/2024, 9:55 AMIs your VERSION file actually part of the test run sandbox, when using your target?no, it is not - i.e. it is not copied into the sandbox. It only should invalidate the dependents as their behavior may change
fresh-cat-90827
04/19/2024, 9:55 AMif not, I suspect you need a codegen to translate the VERSION file from aoh I see. Is that something trivial I'd be able to see how we do for the built-in codegen or is it something esoteric?into aversion_filefile.. (edited)file
curved-television-6568
04/19/2024, 10:09 AMfresh-cat-90827
04/19/2024, 10:10 AMcurved-television-6568
04/19/2024, 10:10 AMfresh-cat-90827
04/19/2024, 10:10 AMcurved-television-6568
04/19/2024, 10:11 AMfresh-cat-90827
04/19/2024, 10:12 AMcurved-television-6568
04/19/2024, 10:12 AMcurved-television-6568
04/19/2024, 10:14 AMfresh-cat-90827
04/19/2024, 10:15 AM