Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-vault
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jérémy Bobbio (Lunar)
swh-vault
Commits
5fd219cd
Commit
5fd219cd
authored
6 years ago
by
David Douard
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite celery tasks as a decorated function
parent
5c56566d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/vault/backend.py
+0
-1
0 additions, 1 deletion
swh/vault/backend.py
swh/vault/cooking_tasks.py
+8
-15
8 additions, 15 deletions
swh/vault/cooking_tasks.py
with
8 additions
and
16 deletions
swh/vault/backend.py
+
0
−
1
View file @
5fd219cd
...
...
@@ -15,7 +15,6 @@ from swh.scheduler import get_scheduler
from
swh.scheduler.utils
import
create_oneshot_task_dict
from
swh.vault.cache
import
VaultCache
from
swh.vault.cookers
import
get_cooker
from
swh.vault.cooking_tasks
import
SWHCookingTask
# noqa
cooking_task_name
=
'
swh.vault.cooking_tasks.SWHCookingTask
'
...
...
This diff is collapsed.
Click to expand it.
swh/vault/cooking_tasks.py
+
8
−
15
View file @
5fd219cd
...
...
@@ -3,26 +3,19 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
swh.scheduler.task
import
Task
from
celery
import
current_app
as
app
from
swh.vault.cookers
import
get_cooker
class
SWHCookingTask
(
Task
):
@app.task
(
name
=
__name__
+
'
.SWHCookingTask
'
)
def
cook_bundle
(
obj_type
,
obj_id
):
"""
Main task to cook a bundle.
"""
task_queue
=
'
swh_vault_cooking
'
def
run_task
(
self
,
obj_type
,
obj_id
):
cooker
=
get_cooker
(
obj_type
)(
obj_type
,
obj_id
)
cooker
.
cook
()
get_cooker
(
obj_type
)(
obj_type
,
obj_id
).
cook
()
# TODO: remove once the scheduler handles priority tasks
class
SWHBatchCookingTask
(
Task
):
@app.task
(
name
=
__name__
+
'
.SWHBatchCookingTask
'
)
def
batch_cook_bundle
(
obj_type
,
obj_id
):
"""
Temporary task for the batch queue.
"""
task_queue
=
'
swh_vault_batch_cooking
'
def
run_task
(
self
,
obj_type
,
obj_id
):
cooker
=
get_cooker
(
obj_type
)(
obj_type
,
obj_id
)
cooker
.
cook
()
get_cooker
(
obj_type
)(
obj_type
,
obj_id
).
cook
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment