is there a way to turn off the python-dependency-d...
# general
a
is there a way to turn off the python-dependency-discovery? It just doesn't feel like it works that great. I'm adding
//3rdparty:xyz
to my dependencies more often than not. at the point I want to just make it explicit.
e
a
cheers
h
How come you're having to add? Is xyz imported? If so, you may have to update the module mapping for third-party requirements
a
haven't been able to get the google-cloud packages to work. (e.g. google-cloud-kms provides
google.cloud.kms
) One package (graphtik) is slightly broken and has an unspecified dependency on pandas, but if I add
pandas: [graphtik]
to my
module_mapping
I then get errors about ambiguous dependencies. and another package (spacy) also depends on the dataset library. small things, and ultimately not really a Pants issue.
h
What pants version are you on? There's a workaround for the unspecified dependencies issue, altho a little clunky atm. 2.8 adds a general "overrides mechanism" to allow macros / target generators to override metadata for a specific target. If you're able to use Pants 2.8, I can add that feature to python_requirements() macro so that this problem is fixed in a easy, declarative way For Google cloud mapping, definitely we want to fix that! Would you be willing to open a ticket please with more info?
a
ok
h
Thanks! While it's valid to not use dep inference, we strongly encourage using it. Not only does it greatly reduce maintenance burden, but also usually results in much more precise dependencies. No risk that when you delete an import you forget to update the BUILD file, for example And the dependencies are between individual files (what 2.8+ calls
python_source
targets). Whereas when maintaining a BUILD file by hand it would be too much boilerplate to specify dependencies at a file level, so dependencies are usually between
python_sources
targets (formerly
python_library
), which are much coarser. For both Pants and Toolchain repos, dependencies became 30% more precise after adopting dependency inference -- But, it's key dependency inference works well. So we're highly motivated to solve the problems you mentioned. Thank you for flagging them!
As promised @ambitious-actor-36781 🙂 https://github.com/pantsbuild/pants/pull/13458 cc @narrow-activity-17405, you've mentioned this would help you in the past. I will cherry-pick into 2.8's release candidate
👍 1
a
oh neat.
❤️ 1
h
Glad that'll work for you! As alluded to in PR description, this
overrides
mechanism is a flagship feature of Pants 2.8 in general. Allows you to do things like
Copy code
python_tests(
  overrides={
     "foo_test.py": {"timeout": 120},
     "bar_test.py": {"timeout": 200},
  },
)
Upcoming blog and docs changes will share more about that
a
I was going to ask "How do I treat this one file as a special snowflake?" and now that's answered too.
💯 1