openedx / django-user-tasks Goto Github PK
View Code? Open in Web Editor NEWA Django application for managing user-triggered asynchronous tasks.
License: Apache License 2.0
A Django application for managing user-triggered asynchronous tasks.
License: Apache License 2.0
The version of pyyaml was pinned back in 2021 due to a swagger2rst issue that was resolved on the same day it was reported. It should be safe to unpin this now.
Currently the create_user_task
signal handler always fails with TypeError('tuple indices must be integers or slices, not str')
when using task message protocol version 2 (https://docs.celeryq.dev/en/stable/internals/protocol.html), which should be the celery default for many years now. The exception is catched and logged by celery and it seems to have no impact for simple use cases.
To workaround this issue the following code can be used:
from celery import signals
from user_tasks.signals import create_user_task
from myproject.celery.celery import app
signals.before_task_publish.disconnect(create_user_task)
signals.before_task_publish.connect(create_user_task_wrapper)
def create_user_task_wrapper(sender=None, body=None, **kwargs):
return create_user_task(
sender,
body
if app.conf.task_protocol == 1
else proto2_to_proto1(body, kwargs.get("headers", {})),
)
# Based on some old celery code:
def proto2_to_proto1(body, headers):
args, kwargs, embed = body
embedded = _extract_proto2_embed(**embed)
chained = embedded.pop("chain")
new_body = dict(
_extract_proto2_headers(**headers), args=args, kwargs=kwargs, **embedded
)
if chained:
new_body["callbacks"].append(chain(chained))
return new_body
def _extract_proto2_headers(id, retries, eta, expires, group, timelimit, task, **_):
return {
"id": id,
"task": task,
"retries": retries,
"eta": eta,
"expires": expires,
"utc": True,
"taskset": group,
"timelimit": timelimit,
}
def _extract_proto2_embed(callbacks, errbacks, chain, chord, **_):
return {
"callbacks": callbacks or [],
"errbacks": errbacks,
"chain": chain,
"chord": chord,
}
This repository is using Ubuntu 20.04 for testing. That version of Ubuntu will be out of support before Teak. Therefore this repo needs to be updated to testing with Ubuntu 24.04 before Sumac is cut to allow everyone sufficient time to switch to the new version.
Update this repository to test with Ubuntu 24.04 so that we can make the switch.
Note: In some cases, it may not make sense to test with both the old and the new version. For example, if the workflow is running linting or publishing to a package manager. In these cases, simply update the workflow to run on the newer version or opt to set it to ubuntu-latest
instead if it doesn't matter what version it's running on. If you're unsure, reach out to the maintenance working group in #wg-maintenance in slack for guidance.
Known affected workflow files:
Given that this package hasn't been released in 7 years or received any commits in 2 years, we should refactor our documentation builds to no longer use it. This would also unblock #291 .
I was trying to connect signals to the one i guess were emited when a task was created or succeeded. So I added a function in signals and tried to work out signals in django by also putting login signal to ensure signals were working.
Despite the task being conducted and finished (successfully i guess since it does what i want it to do) i have no signal emitted in any case.
I tried multiples ways and endded up adding django-debug-toolbar 3.1.1
Using this package i saw an error message in the logs
So I looked into the create_user_task()
method inside user_tasks/signals.py
in the package
It looks like there is conflicts between body argument where args and kwars should be, but they seems to be in the header
argument passed in **kwarg
of create_user_task()
under the name "argsrepr"
and "kwargsrepr"
(i dont know much about these names tho)
Am i doing something wrong?
Thank you,
Yoann
my tasks.py file inside my app
class ImportTask(UserTask):
@classmethod
def generate_name(cls, arguments_dict):
serie = Serie.objects.get(pk=arguments_dict['serie_id'])
return 'Import of {}'.format(serie)
@staticmethod
def calculate_total_steps(arguments_dict):
return 100
@shared_task(base=ImportTask, bind=True)
def import_csv(self, user_id, notification_key, path_file, serie_id, **kwargs):
uploadCandles(path_file, serie_id)
my signals.py file with logged_in and out working as espected but nothing happening for the others
def user_logged_in_handler(sender, request, user, **kwargs):
print('OUI')
def user_logged_out_handler(sender, request, user, **kwargs):
print('NON')
def user_task_stopped_handler(**kwargs):
print('User task stoped')
@receiver(task_success)
def task_success_handler(result, **kwargs):
print('User task succeed')
@task_success.connect
def task_succeeded_handler(sender=None, **kwargs):
print(sender)
if isinstance(sender, UserTaskMixin):
print('User task succeed')
user_logged_in.connect(user_logged_in_handler)
user_logged_out.connect(user_logged_out_handler)
user_task_stopped.connect(user_task_stopped_handler)
This repository is a depedency of edx-platform and needs to be upgraded to Python 3.11 before
the Readwood release is cut (mid-April).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.