CSC/ECE 517 Fall 2014/OSS S1454 ccc: Difference between revisions
(Created page with "= Sahana Eden: Extract The Progress Details = == Introduction to Sahana Eden == Sahana is a software foundation with the express intent of “saving lives by providing informati...") |
No edit summary |
||
Line 11: | Line 11: | ||
return “even” | return “even” | ||
return “odd” | return “odd” | ||
===== Queuing Tasks ===== | |||
Tasks can then be queued up with additional meta-parameters for running the function, such as when the task should die, how long can the process run until timeout occurs, how many times to repeat the function, what parameters to send to the task (if applicable), et cetera. | Tasks can then be queued up with additional meta-parameters for running the function, such as when the task should die, how long can the process run until timeout occurs, how many times to repeat the function, what parameters to send to the task (if applicable), et cetera. | ||
scheduler.queue_task(‘task_getParity’, [8], …) | scheduler.queue_task(‘task_getParity’, [8], …) | ||
===== Scheduler Creation ===== | |||
The scheduler is the manager for the tasks and workers. Creating a scheduler requires a database at the least in order to store the states of tasks. However, the scheduler can be instantiated with additional parameters that allow specifications for the time between each check of the queue, specific names of functions to queue, the amount of times the queue is checked before a worker must be terminated, et cetera. | The scheduler is the manager for the tasks and workers. Creating a scheduler requires a database at the least in order to store the states of tasks. However, the scheduler can be instantiated with additional parameters that allow specifications for the time between each check of the queue, specific names of functions to queue, the amount of times the queue is checked before a worker must be terminated, et cetera. | ||
from gluon.scheduler import Scheduler | from gluon.scheduler import Scheduler | ||
scheduler = Scheduler(database [,…]) | scheduler = Scheduler(database [,…]) | ||
===== Task Lifecycle ===== | |||
Similar to Java threads and Linux processes, a Web2Py process (interchangeable at this point with task) lifecycle is as follows: | |||
* '''Queued''' a task is queued to be picked up by a worker. | |||
* '''Expired''' the task died in the queue (the amount of time designated to cause the task to die has passed). | |||
* '''Assigned''' a worker is assigned to this task. | |||
* '''Running''' the task is being carried out. | |||
* '''Timeout''' the task timed out (the amount of time designated to case the task to timeout during processing has passed). | |||
* '''Failed''' an error was detected or an exception was thrown. | |||
* '''Completed''' the task finished correctly. |
Revision as of 03:21, 29 October 2014
Sahana Eden: Extract The Progress Details
Introduction to Sahana Eden
Sahana is a software foundation with the express intent of “saving lives by providing information management solutions that enable organizations and communities to better prepare for and respond to disasters.” [1] This is achieved by developing free and open source software to make disaster response coordination more efficient. Eden (or Emergency Development ENvironment for Rapid Deployment Humanitarian Response Management), one of their main products is a feature-rich and rapidly customizable humanitarian platform that allows its modules to be specialized for particular organizations and management needs. Eden has been used to help address the wildfires in Chile, earthquakes and tsunamis in Japan, flooding in Colombia, flooding in Venezuela, flooding in Pakistan, and hurricane in Veracruz, Mexico [2]. The idea is to mix and match several modules that Eden has to best suit the needs and context of an organization. The main modules are an Organization Registry, which can create databases of organizations to help facilitate coordination; Project Tracking, which tells who is doing what where and when and can tell who is working on similar projects to help facilitate collaboration; Human Resources, a tool that helps track and manage the people involved including what skills those people have; Inventory Management, which allows for recording and automating shipments and deliveries of supplies; Asset Management, which helps facilitate management of assets like vehicles, communication equipment, and generators as well as tell to whom each are assigned; Assessments, which can be used to collect and analyze information; Shelter Management, which helps facilitate the management of temporary shelters including required resources, staff and volunteer assignments, and check-in/check-out systems; Scenario and Event planning, which helps facilitate planning for various emergency scenarios; Mapping, which enables location-based visualization on maps; and Messaging, which facilitates communications over various protocol and social media mediums. Eden’s WebSetup is the tool that facilitates the setup process of a new Eden tool. The process of setting up a new Eden project entails many moving parts, so detecting bugs and troubleshooting issues in the process can be tricky. A developer created a New Enhancement ticket that requested work on being able to extract the progress details of the setup into a single local file, not dissimilar to a log file. [3]
Web2Py Tasks and Task Scheduler
Sahana Eden uses the Web2Py; an application development framework written in Python that uses a typical MVC pattern. In order to best manage work on large and complicated functionality in the background, Web2Py implemented a scheduler that allows control over processes. A task is a function defined in a model:
def task_getParity(i): if i % 2 == 0: return “even” return “odd”
Queuing Tasks
Tasks can then be queued up with additional meta-parameters for running the function, such as when the task should die, how long can the process run until timeout occurs, how many times to repeat the function, what parameters to send to the task (if applicable), et cetera.
scheduler.queue_task(‘task_getParity’, [8], …)
Scheduler Creation
The scheduler is the manager for the tasks and workers. Creating a scheduler requires a database at the least in order to store the states of tasks. However, the scheduler can be instantiated with additional parameters that allow specifications for the time between each check of the queue, specific names of functions to queue, the amount of times the queue is checked before a worker must be terminated, et cetera.
from gluon.scheduler import Scheduler scheduler = Scheduler(database [,…])
Task Lifecycle
Similar to Java threads and Linux processes, a Web2Py process (interchangeable at this point with task) lifecycle is as follows:
- Queued a task is queued to be picked up by a worker.
- Expired the task died in the queue (the amount of time designated to cause the task to die has passed).
- Assigned a worker is assigned to this task.
- Running the task is being carried out.
- Timeout the task timed out (the amount of time designated to case the task to timeout during processing has passed).
- Failed an error was detected or an exception was thrown.
- Completed the task finished correctly.