Taskflow Backend¶
The taskflowbackend
backend app is an optional add-on used if your site
setup contains the separate SODAR Taskflow data transaction service.
If you have not set up a SODAR Taskflow service for any purpose, this backend is not needed and can be ignored.
Basics¶
The taskflowbackend
backend app is used in the main SODAR site to
communicate with an external SODAR Taskflow service to manage large-scale data
transactions. It has no views or database models and only provides an API for
other apps to use.
Note
At the time of writing, SODAR Taskflow is in development and has not been made public.
Installation¶
Warning
To install this app you must have the django-sodar-core
package
installed and the projectroles
app integrated into your Django site.
See the projectroles integration document
for instructions.
Django Settings¶
The taskflowbackend app is available for your Django site after installing
django-sodar-core
. Add the app into THIRD_PARTY_APPS
as follows:
THIRD_PARTY_APPS = [
# ...
'taskflowbackend.apps.TaskflowbackendConfig',
]
Next add the backend to the list of enabled backend plugins:
ENABLED_BACKEND_PLUGINS = env.list('ENABLED_BACKEND_PLUGINS', None, [
# ...
'taskflow',
])
The following app settings must be included in order to use the backend.
Note that the values for TASKFLOW_TARGETS
depend on your SODAR Taskflow
configuration.
# Taskflow backend settings
TASKFLOW_BACKEND_HOST = env.str('TASKFLOW_BACKEND_HOST', 'http://0.0.0.0')
TASKFLOW_BACKEND_PORT = env.int('TASKFLOW_BACKEND_PORT', 5005)
TASKFLOW_SODAR_SECRET = env.str('TASKFLOW_SODAR_SECRET', 'CHANGE ME!')
TASKFLOW_TARGETS = [
'sodar',
# ..
]
Register Plugin¶
To register the taskflowbackend plugin, run the following management command:
$ ./manage.py syncplugins
You should see the following output:
Registering Plugin for taskflowbackend.plugins.BackendPlugin
Usage¶
Once enabled, Retrieve the backend API class with the following in your Django app python code:
from projectroles.plugins import get_backend_api
taskflow = get_backend_api('taskflow')
See the docstrings of the API for more details.
To initiate sync of existing data with your SODAR Taskflow service, you can use the following management command:
./manage.py synctaskflow
Django API Documentation¶
The TaskflowAPI
class contains the SODAR Taskflow backend API. It should be
initialized using the Projectroles.plugins.get_backend_api()
function.
-
class
taskflowbackend.api.
TaskflowAPI
[source]¶ SODAR Taskflow API to be used by Django apps
-
cleanup
()[source]¶ Send a cleanup command to SODAR Taskflow. Only allowed in test mode.
- Returns
Boolean
- Raise
ImproperlyConfigured if TASKFLOW_TEST_MODE is not set True
- Raise
CleanupException if SODAR Taskflow raises an error
-
get_error_msg
(flow_name, submit_info)[source]¶ Return a printable version of a SODAR Taskflow error message.
- Parameters
flow_name – Name of submitted flow
submit_info – Returned information from SODAR Taskflow
- Returns
String
-
classmethod
get_inherited_roles
(project, user, roles=None)[source]¶ Return list of inherited owner roles to be used in taskflow sync.
- Parameters
project – Project object
user – User object
- Pram roles
Previously collected roles (optional, list or None)
- Returns
List of dicts
-
classmethod
get_inherited_users
(project, roles=None)[source]¶ Return list of all inherited users within a project and its children, to be used in taskflow sync.
- Parameters
project – Project object
- Pram roles
Previously collected roles (optional, list or None)
- Returns
List of dicts
-
submit
(project_uuid, flow_name, flow_data, request=None, targets=None, request_mode='sync', timeline_uuid=None, force_fail=False, sodar_url=None)[source]¶ Submit taskflow for SODAR project data modification.
- Parameters
project_uuid – UUID of the project (UUID object or string)
flow_name – Name of flow to be executed (string)
flow_data – Input data for flow execution (dict)
request – Request object (optional)
targets – Names of backends to sync with (list)
request_mode – “sync” or “async”
timeline_uuid – UUID of corresponding timeline event (optional)
force_fail – Make flow fail on purpose (boolean, default False)
sodar_url – URL of SODAR server (optional, for testing)
- Returns
Boolean
- Raise
FlowSubmitException if submission fails
-