Just an idea.. that follows up on a question I had...
# general
c
Just an idea.. that follows up on a question I had last summer, or there abouts, regarding how feasible it would be to re-use the pants rule engine as a lib. Now that I’ve come to know things better, I think the answer could be “a lot easier than you initially though”. Consider the
RuleRunner
test util.. it pretty much does this already.. so I’ve got a little toy POC, that is a mix of the regular
PantsRunner
and the test
RuleRunner
, where I can create a scheduler session with some “backends” registered and then issue requests against that rule graph. Perfect! 😄 This gives me the possibility to write arbitrary applications, leveraging the structure and semantics of
@rule
methods for the core logic. Awesome! 🚀 As stated, it’s still on a toy level, so haven’t actually used this for anything meaningful yet.. that’ll be for the coming month to show how this scales up 😉
👀 2
b
I'm interested in your findings 😄
👍 2
I'm also wondering how much size the engine adds to the library. And if it can be shared with Pants if the engine is being used by a tool eventually integrated with Pants (say, a linter)
c
Posted my toy POC of using Pants as an embedded rule engine in its current state on GitHub. This is the main file showcasing what the client application API could look like: https://github.com/kaos/underpants/blob/main/src/pr/main.py cc @bitter-ability-32190
🙌 3
I think the size added could be quite considerable… as my toy pex weighs in on 24M.
But I think it would be safe to share with pants as a tool.. as long as the version matches.. 🤔
b
I was actually thinking you could have a flavor that's engineless so you don't end up with 2 pants engines
h
Why use the engine as a lib rather than write a plugin?
c
To not restrict or impose pants way of handling command line options and invocation.
👍 1
Also, consider an existing application, it’s less work to incrementally implement rules, than to toss out the applications cli integration for pants’.
👍 1
I was actually thinking you could have a flavor that’s engineless so you don’t end up with 2 pants engines
Sure, shipping the lib, will just have pants as a dependency, so it shouldn’t end up with two engines…
But when used in an application that doesn’t otherwise use pants, it will incur that extra 20 something M’s..
b
Sure, shipping the lib, will just have pants as a dependency, so it shouldn’t end up with two engines… (edited)
oh duh
😉 1
h
This is really cool
I wonder if it makes sense to upstream any of this to Pants itself. Give you a light weight way to write Pants rules in build scripts without using Pants itself yet, maybe? Does that make sense? @rapid-bird-79300 have you seen this thread?
w
neat! experiments to simplify the
Scheduler
API upstream are also very welcome… i’ve found in the past that making it as easy as possible to write tests without shim code is a good sign that the API is easy to use. and right now, RuleRunner abstracts/shims away a bunch of rough edges of
Scheduler
which could probably also be directly smoothed out
1
👌 1
💯 1
h
Great idea! And it might be easier to clean things up now that we use PyO3 so FFI is much easier to work with
r
this is a great idea! It can definitely help incremental adoption and make it faster to iterate on simple use cases while leveraging the power of the rules engine. The example shared above is a very familiar pattern for a majority of python engineers which can help get more interest in the community and what pants offers.
also love the name
underpants
hahah
💯 1
🙈 4
😂 2