Provisioning-phase gating for MPT Extension SDK pipeline steps.
Project description
mpt-extension-contrib-phase-step
Shared provisioning-phase gating for SoftwareONE MPT extensions built on the Extension SDK. A step declares the single provisioning phase it runs for; when the order's phase parameter holds a different value the step is skipped and the pipeline records the skip, instead of the step deciding to no-op inside its own body.
It replaces ad-hoc phase checks inside individual extension steps with one reusable gating mechanism shared across pipelines.
See AGENTS.md for the module documentation map.
Install
pip install mpt-extension-contrib-phase-step
Requires the Extension SDK (mpt-extension-sdk >= 6.3, < 7), which is pulled in as a
dependency.
Public API
mpt_extension_contrib.phase_step exposes a base step, two functions, and one
settings contract:
| Object | Purpose |
|---|---|
PhaseGatedStep(expected_phases) |
Base step that runs only when the order phase is one of expected_phases (a phase or a list of phases); subclass and implement process(). |
require_phase(context, expected_phases) |
Guard for a hand-written pre(): skip the step unless the phase is one of expected_phases. |
advance_phase(context, phase) |
Persist a new phase on the order (and refresh the context) to move the flow forward; call it from process(). |
PhaseStepSettings |
Protocol describing the settings the API reads. |
Design in one line
The SDK already skips a step when its pre() raises SkipStepError (the
pipeline logs the skip and continues). This library adds only the missing
convention — read the phase parameter, compare, raise — as a function and a
thin base step, and keeps phase values and the parameter id out of the library.
No decorators or wrappers: gating is expressed by subclassing and, when needed,
an explicit await super().pre(context).
Usage
Expose the phase parameter external id in the extension settings:
from dataclasses import dataclass
from typing import Self, override
from mpt_extension_sdk.settings.extension import BaseExtensionSettings
from mpt_extension_contrib.phase_step import PhaseStepSettings
@dataclass(frozen=True)
class ExtensionSettings(BaseExtensionSettings, PhaseStepSettings):
phase_parameter: str = "phase"
@override
@classmethod
def load(cls) -> Self:
return cls()
Seed the phase before the first gated step: PhaseGatedStep.pre() runs before
process(), so a first step with an unset phase would skip before it could
initialize it. Set an initial value via a product default or an ungated
initializer step.
Gate a step by subclassing PhaseGatedStep and binding the phase when the
pipeline is composed:
from typing import override
from mpt_extension_sdk.pipeline import BasePipeline, BaseStep, OrderContext
from mpt_extension_contrib.phase_step import PhaseGatedStep
class CreateSubscription(PhaseGatedStep):
@override
async def process(self, context: OrderContext) -> None:
# runs only while the phase parameter equals the bound value
...
class PurchasePipeline(BasePipeline):
@property
def steps(self) -> list[BaseStep]:
return [
CreateSubscription("createSubscription"),
# ... more phase-gated steps ...
]
See Usage for a step that adds its own pre() guard and for
advancing the phase.
Documentation
- Usage — install, configure, gate steps, advance the phase
- Architecture
- Contributing
- Testing
- Releases
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mpt_extension_contrib_phase_step-1.0.0.tar.gz.
File metadata
- Download URL: mpt_extension_contrib_phase_step-1.0.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d782c292f0987d39e0a728473f5098c9017923be337707935f2a604e7a384d03
|
|
| MD5 |
7219517a7b3e3c1f20c7b53012f2ae1c
|
|
| BLAKE2b-256 |
a7c2642a821ab62a81d71dddc950dbc3790fe1645f4ed4b7f98e9aee71b83918
|
File details
Details for the file mpt_extension_contrib_phase_step-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mpt_extension_contrib_phase_step-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa48b3ea5c5172ecca1423f91db94123256975b9c1b46be0b49b8ccd4ccda137
|
|
| MD5 |
17de5534e9444917ba0b85151be0fb9d
|
|
| BLAKE2b-256 |
779cc09bf4bc3d1c68e87c99b995f527a2d9a1a75c1fafbe3367149f434ccdc2
|