Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uclouvain/osis-async
https://github.com/uclouvain/osis-async
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/uclouvain/osis-async
- Owner: uclouvain
- Created: 2021-07-01T08:45:45.000Z (over 3 years ago)
- Default Branch: dev
- Last Pushed: 2024-11-13T09:57:01.000Z (about 2 months ago)
- Last Synced: 2024-11-13T10:34:50.721Z (about 2 months ago)
- Language: Python
- Size: 11.1 MB
- Stars: 0
- Watchers: 16
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OSIS Async
`OSIS Async` is a Django application to create and display asynchronous tasks across OSIS platform.
Requirements
===========`OSIS Async` requires
- Django 2.2+
- Django REST Framework 3.12+
- Vue 3# How to install ?
## For production
```bash
# From your osis install, with python environment activated
pip install git+https://github.com/uclouvain/osis-async.git@dev#egg=osis_async
```## For development
```bash
# From your osis install, with python environment activated
git clone [email protected]:uclouvain/osis-async.git
pip install -e ./osis-async
```## Configuring Django
Add `osis_async` to `INSTALLED_APPS` and apply migrations :
```python
INSTALLED_APPS = (
...,
'osis_async',
)
```# Using OSIS Async
`osis_async` provides an API to create and manage async tasks and also a VueJS component to view them in the interface.
## Create an async task
Initialize an object describing the notification you want to send:
```python
from osis_async.models.task import AsyncTasktask_uuid = AsyncTask.objects.create(
name="My task name",
description="My task longer description",
person=person, # Person for which to display the task
time_to_live=5, # Time-to-live in minutes
).uuid
# Store its uuid for easy retrieval
```## Update an async task
It is the implementer role's to start and update its async tasks, you can use the `update_task()` for that matter:
```python
from django.utils.timezone import now
from osis_async.utils import update_task
from osis_async.models.enums.task import TaskStateupdate_task(uuid, state=TaskState.PROCESSING, started_at=now())
update_task(uuid, progression=50)
update_task(uuid, state=TaskState.DONE, completed_at=now())
```# Integrate the front async component
Make the dependencies available:
```html```
Then you can integrate the component:
```html
```
- `data-url` : API endpoint that returns all the tasks.
- `data-interval` : The interval, in seconds, to fetch tasks from server (default to 300).
# Update the front async component via custom event
```html
let customEvent=new CustomEvent('AsyncTasksViewer:fetchAsyncTasks');
document.dispatchEvent(customEvent);