Skip to main content

Order processing due-date pipeline steps for MPT Extension SDK projects.

Project description

mpt-extension-contrib-due-date

Shared order processing due-date helpers for SoftwareONE MPT extensions built on the Extension SDK. The library sets a maximum date by which an order must be processed and fails the order once that date passes, so orders never hang in processing forever.

It replaces the per-extension due-date logic previously re-implemented in the Adobe and FinOps extensions.

See AGENTS.md for the module documentation map.

Install

pip install mpt-extension-contrib-due-date

Requires the Extension SDK (mpt-extension-sdk >= 6.3, < 7), which is pulled in as a dependency.

Public API

mpt_extension_contrib.due_date exposes three pipeline steps and one settings contract:

Object Purpose
SetDueDate(days=N) Set today + N days as the due date and persist it (once).
EnforceDueDate() Fail the order when its due date has been reached.
ResetDueDate() Clear the due date, e.g. before completing the order.
DueDateSettings Protocol describing the settings the steps read.

Usage

Expose the due-date 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.due_date import DueDateSettings


@dataclass(frozen=True)
class ExtensionSettings(BaseExtensionSettings, DueDateSettings):
    due_date_parameter: str = "dueDate"

    @override
    @classmethod
    def load(cls) -> Self:
        return cls()

Add the steps to an order pipeline:

from mpt_extension_sdk.pipeline import BasePipeline, BaseStep

from mpt_extension_contrib.due_date import EnforceDueDate, ResetDueDate, SetDueDate


class PurchasePipeline(BasePipeline):
    @property
    def steps(self) -> list[BaseStep]:
        return [
            SetDueDate(days=14),  # assign the deadline on first run
            EnforceDueDate(),  # fail the order once the deadline passes
            # ... order processing steps ...
            ResetDueDate(),  # clear the deadline before completing
        ]

The steps read the parameter external id from context.ext_settings.due_date_parameter and the deadline length from SetDueDate(days=...).

EnforceDueDate does not fail the order itself: it records the intent on context.order_state.action and raises DueDateReachedError (a StopStepError subclass). Following the SDK pipeline-hooks contract, the order is failed by the extension's pipeline in an on_step_stopped / on_step_failed hook:

from mpt_extension_sdk.errors.step import StopStepError
from mpt_extension_sdk.pipeline import BasePipeline, OrderStatusActionType

from mpt_extension_contrib.due_date import DueDateReachedError


class OrderPipeline(BasePipeline):
    async def on_step_stopped(self, step, ctx, error: StopStepError) -> None:
        await super().on_step_stopped(step, ctx, error)
        action = ctx.order_state.action
        if action and not ctx.order_state.handled:
            if action.target_status == OrderStatusActionType.FAIL:
                await ctx.mpt_api_service.orders.fail(ctx.order_id, action.status_notes)
            ctx.order_state.handled = True

The hook above applies any declared action generically. When you need due-date-specific handling (a notification, a metric, a distinct status note), identify it by the exception type — isinstance(error, DueDateReachedError) — since several steps may raise StopStepError in the same pipeline.

Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpt_extension_contrib_due_date-1.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpt_extension_contrib_due_date-1.0.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mpt_extension_contrib_due_date-1.0.0.tar.gz.

File metadata

  • Download URL: mpt_extension_contrib_due_date-1.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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

Hashes for mpt_extension_contrib_due_date-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a81d6d3d9302782b0fd3d6eebb1acdf70edd239176fe2bb6ecaf33e904a988ea
MD5 f87fd4c65dd426641ff7c1f36b679fe0
BLAKE2b-256 0e20acfe92657e0606982038985f075fe3db1633c36674e695e2c57ce79d6362

See more details on using hashes here.

File details

Details for the file mpt_extension_contrib_due_date-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mpt_extension_contrib_due_date-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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

Hashes for mpt_extension_contrib_due_date-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5936976acdd6d365d465e8420b4d38268950a013e5e4900e9117bdc47d1f87b8
MD5 6a8b25a27449f9d5ffb14eafe412b06d
BLAKE2b-256 1e05f18ec6b7a54826d3d61c24f0dd1cc71addbbc8c6d3941d9e3388a62fbb3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page