beanlab / quest_framework

A Python framework for fault-tolerant workflows
0 stars 0 forks source link

Put a `wrap_steps` function in `external.py` #31

Open byubean opened 3 months ago

byubean commented 3 months ago

From the RubberDuck project:

def wrap_steps(obj):
    for field in dir(obj):
        if field.startswith('_'):
            continue

        if callable(method := getattr(obj, field)):
            method = step(method)
            setattr(obj, field, method)

    return obj

This pattern (wanting to wrap every method on an object in step) probably happens frequently enough that we should provide this in quest.