-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f44c5b
commit 3aedc69
Showing
8 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
from django.db import models | ||
|
||
from constance import config | ||
from django_celery_boost.models import CeleryTaskModel | ||
|
||
from hope_dedup_engine.apps.api.deduplication.lock import DeduplicationSetLock | ||
from hope_dedup_engine.apps.api.models import DeduplicationSet | ||
|
||
|
||
class DedupJob(CeleryTaskModel): | ||
deduplication_set = models.ForeignKey( | ||
"DeduplicationSet", on_delete=models.CASCADE, related_name="jobs" | ||
) | ||
serialized_lock = models.CharField(max_length=128, null=True, editable=False) | ||
|
||
celery_task_name = ( | ||
"hope_dedup_engine.apps.api.deduplication.process.find_duplicates" | ||
) | ||
|
||
def queue(self, use_version: bool = True) -> str | None: | ||
if config.DEDUPLICATION_SET_LOCK_ENABLED: | ||
self.serialized_lock = str( | ||
DeduplicationSetLock.for_deduplication_set(self.deduplication_set) | ||
) | ||
self.save() | ||
|
||
self.deduplication_set.state = DeduplicationSet.State.PROCESSING | ||
self.deduplication_set.save() | ||
|
||
return super().queue(use_version=use_version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/hope_dedup_engine/web/templates/admin/celery_boost/change_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "admin_extra_buttons/change_form.html" %} | ||
{% block object-tools %} | ||
{{ block.super }} | ||
<div> | ||
{{ original.task_status }} | ||
</div> | ||
{% endblock %} |
50 changes: 50 additions & 0 deletions
50
src/hope_dedup_engine/web/templates/admin/celery_boost/inspect.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% extends "admin_extra_buttons/action_page.html" %} | ||
{% block action-content %} | ||
<h1>{{ original }}</h1> | ||
{{ original.curr_async_result_id }} | ||
{% if flower_addr %} | ||
<a class="button" target="flower" href="{{ flower_addr }}/task/{{ original.curr_async_result_id }}">Flower</a> | ||
{% endif %} | ||
<h3>Task Info</h3> | ||
<table> | ||
{% for k,v in original.task_info.items %} | ||
<tr> | ||
<th>{{ k }}</th> | ||
<td>{{ v }}</td> | ||
</tr> | ||
{% endfor %} | ||
<tr> | ||
<th>Position in queue</th> | ||
<td>{{ original.queue_position }}</td> | ||
</tr> | ||
</table> | ||
|
||
|
||
|
||
<h3>Queue Info</h3> | ||
<table> | ||
{% for k,v in original.queue_info.items %} | ||
{% if k == "headers" %} | ||
<tr> | ||
<th>{{ k }}</th> | ||
<td> | ||
<table> | ||
{% for k1,v1 in original.queue_info.headers.items %} | ||
<tr> | ||
<td>{{ k1 }}</td> | ||
<td>{{ v1 }}</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
</td> | ||
</tr> | ||
{% else %} | ||
<tr> | ||
<th>{{ k }}</th> | ||
<td>{{ v }}</td> | ||
</tr> | ||
{% endif %} | ||
{% endfor %} | ||
</table> | ||
|
||
{% endblock %} |
5 changes: 5 additions & 0 deletions
5
src/hope_dedup_engine/web/templates/admin/celery_boost/queue.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends "admin_extra_buttons/confirm.html" %} | ||
{% block action-content %} | ||
1111 | ||
{{block.super }} | ||
{% endblock %} |