is it possible to get Pants warnings collected to ...
# general
f
is it possible to get Pants warnings collected to be able to process later? I’d love to be able to see whether a warning is of particular interest or not (deprecated: something is going to be renamed in version X is not as interesting as _Unmatched glob from_…)
Copy code
00:15:35.08 [WARN] Unmatched glob from project/project:project's `sources` field: "project/project/othersrc/*.py"

Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.8/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
h
The best I could think of is if we taught
[GLOBAL].ignore_warnings
about inverted filters: ignore everything except for this pattern. Wdyt?
f
If those messages result in warning-level work units, then you could write a “streaming workunit handler” to parse those out.
but I don’t know without further investigation if log messages map into work units.
h
but I don’t know without further investigation if log messages map into work units.
Not all. Adding a stray
logger.warning()
isn't associated w/ a particular workunit iiuc
f
thanks folks. I thought perhaps we could extend
./pants update-build-files --check
to report deprecations in some parsable form? 😕 The ambition is to fail a build in CI if someone has an unmatched glob pattern in their
BUILD
file but using something that is going to be deprecated should pass. The
./pants validate
perhaps could be used as well.
grepping
[WARN] Unmatched glob
would of course work short-term, but I think being able to distinguish between warnings and allow programmatic iteration through them is ideal for long-term, imho
h
Every deprecation message starts with DEPRECATED iirc, so I think the inverted filters idea is probably a good way to go. Especially if we give you the snippet to use on the Upgrade Tips docs I don't think
update-build-files
has the capability to do this in particular, and
validate
is being merged into
lint
Thoughts?
f
let me think about! So we say that if
[WARN]
is found in the output, then we can fail because it’s not deprecation (since it’s ignored as per config) but something of interest. However, it can be the case that there are multiple types of warnings so you still end parsing the warning to differentiate between them. FWIW, if you run
./pants test project::
, the warnings are shown, but if you re-run
./pants test --force project::
, the warnings are gone. Is this intentional (hiding warnings if hitting the cache)? I am worried we may be missing some warnings due to cache hits 😕