Package: taskcontrol
taskcontrolCreate named shared / isolated workflow task controls, and run them with respective before/after middlewarestaskcontrol is a python library to create tasks in and based on named workflow controls. It allows middlewares before and after each task. taskcontrol can run single or multiple tasks at a task run invocation.It provides a simple decorator calledworkflowthat takes the name, task_instance, task_order, shared, before, after arguments to set up the named workflow controls.It also provides methods to create a plugin and work with tasks as a module and/or pre-created ordered task list.FeaturesCreate Named task controls (tasks) - instance and isolatedAllows middlewares before / after each task (data fetch, auth, data save, logging, logout, cleanup, etc)Access read-only contexts and results of middlewares/tasksAllows Merging two instances of task controls with namespace clash handlingRun instance, shared, and mix of tasks (individual or all groups)In-Development: Allows creating, registering, and using task controls as a pluginInstallationCommand:Pythonpip3 install taskcontrolVersion:In Development Version: 1.2.0 (functional - production ready with plugin and concurrency support)
Current Version: 1.2.0 (functional - production ready with most planned features with MVP)
Previous Version: 1.1.0 (functional - not production ready)Package Link:https://github.com/taskcontrols/py-taskcontrol
https://pypi.org/project/taskcontrol/Technical SpecificationsRequirements:Python 3.xAny OS supporting Python 3.xPackage Dependencies:NoneQuick Demo:demo example - main.pyfromtaskcontrolimportworkflow,Tasksinst=Tasks()defmiddleware(ctx,result,k,c,d,**kwargs):print("Running my Middleware Function: test - task items",k,c,d,kwargs)@workflow(name="taskname",task_order=1,task_instance=inst,shared=False,args=[1,2],kwargs={},before=[{"function":middleware,"args":[11,12],"kwargs":{"d":"Before Testing message Middleware "},"options":{"error":"next","error_next_value":""}}],after=[{"function":test,"args":[13,14],"kwargs":{"d":"After Middleware Testing message"},"options":{"error":"error_handler","error_next_value":"value","error_handler":lambdaerr,value:(err,None)}}],log=False)deftaskone(ctx,result,a,b):print("Running my task function: taskone",a,b)# Run single taskt.run(tasks="taskname")# Run all taskst.run(tasks=["1"])# t.run(tasks=["taskname", ..., "anothertask"])Note:Though it may support Python version 2.x. However, it has not been tested in 2.x. The Syntax and Features of the library supports Python version 2.x. Use at your own risk.WikiGetting startedDescribes in short the usage of the packagetaskcontrolworkflowdecoratorDescribes how to use the taskcontrol workflow decorator in detailtaskcontrolworkflowdecorator argument detailsDescribes in detail the arguments of workflow decoratortaskcontrolworkflowbefore / after argument for middleware declarationDescribes creating, defining, and running middlewarestaskcontrolworkflowinstance and shared tasks argumentDescribes creating a instance (isolated task) and an shared task (available to all instances)Crazy Hint:You can also create a simple workflow without taskcontrol using a simple list or nested list and loop through them using a for/while loop and invoke them during looping# Loop the lists below and invoke the functionslst=["f1","f2","f3"]nest_lst=[["f1","f2"],"f3","f4",["f5"]]# Use a reducer if you want to send args to next function like belowdeftest(a,b):print(a,b)return{"a":a,"b":b}deftester(a,b):print(a,b)returnNonekwargs_for_first_function_the_its_returns_or_other_value_for_next_func={"a":"a","b":"b"}ls=[kwargs_for_first_function_the_its_returns_or_other_value_for_next_func,test,tester]importfunctoolsdefred(kwargs_for_first_then_func,p):i=p(kwargs.get("a"),kwargs.get("b"))returnifunctools.reduce(red,ls)Todoe2e and Unit Tests - Add Tests (Structure of package created - to be cleaned after writing tests)Allow creating and registering a set of task controls as a pluginAdd logging systemStatusIn Active Development (taskcontrol version 1.2.1)SupportPaypal.me/taskcontrolsOpenCollectiveLicenseThe MIT License (MIT) - SeeLICENSEfor further detailsCopyright © 2020 - till library workstaskcontrols@gmail.com