api,ops: config.EXECUTION_ONLY and op._execution_only flags
introduces a flag to direct execution of commands without checks for idempotency, allowing users to rely on Pyinfra's already good abstractions.
Why
Because, in the API usecase, users often use Facts to implement custom idempotency checks (for instance, to introduce two-way declarativity), and in order to reuse Pyinfra's already existing abstractions without the CLI, there is a use for a bare execution with no checks. This effectively reduces the necessity of a server.shell call for basic operations in API usage by a lot in batch-collecting fact edge cases.
This allows Pyinfra operations to be reused as execution primitives, without duplicating logic outside of the framework.
How
Just added a new "operation execution path" to Pyinfra. Now there is the Optional direct_execution flag inside of the @operation() decorator, which only gets used when config.EXECUTION_ONLY is set to true.
It works like so: If EXECUTION_ONLY is enabled, the system attempts to use the operation's direct_execution callable. If not provided, it falls back to the standard execution path (including fact checks).
Note: This is a feature only PR in order to make it more atomic, this does not introduce any operation changes and all features in it are completely opt-in.
This closes #1624
- [x] Pull request is based on the default branch (
3.xat this time) - [N/A] Pull request includes tests for any new/updated operations/facts
- [x] Pull request includes documentation for any new/updated operations/facts
- [x] Tests pass (see
scripts/dev-test.sh) - [x] Type checking & code style passes (see
scripts/dev-lint.sh)