We want to offer an implementation through which the user can now stop the long-running task at any given point in time, and can choose to resume or terminate it. This will ensure that the resources like compute/memory/storage/time are used efficiently at our end, and do not go into processing tasks that have already been stopped (and then to roll back the work done post the stop-action)
- I have created /task, /resume, /stop, /terminate, /list_tasks endpoints.
- /task will help to upload the necessary files in to the pipeline.
- for the pipeline purpose I have used Queue DataStructure(FIFO).
- /stop helps to stop the current running task and with this next task in the queue will start running.
- /resume will resume the task based on the id provided for this the current task should stop running.
- /terminate helps to completely stop the task fro further execution and now you wont be able to resume the task.
- /list_tasks will list all the task in the queue with its metadata.
- Flask framework for creating API's.
- Redis for scheduling tasks
- test.py : help to prepare the test data csv.
- app.py : the main program responsible to perform task.
- SQL Database can be used to persist task and its metadata.
- Its can be deployed in kubernetes through docker image.
- Create a python3 virtual enviornment.
- Install the requirements via
pip install -r requirements.txt
. - Open two terminals in one run
flask run
and in second runrq worker
(make sure redis-server is installed). - Now that the server is running, you can make POST and GET request now.