Skip to content
Snippets Groups Projects

Compute plot in parallel

Merged Bryan BRANCOTTE requested to merge compute-plot-in-parallel into master
1 file
+ 13
6
Compare changes
  • Side-by-side
  • Inline
+ 13
6
@@ -74,31 +74,38 @@ def create_project_csv_file(project_id):
return project.create_csv_file()
@celery.task
def dummy_task():
print("This task to nothing, but help the chain to have a valid status")
def run_project_analysis_if_needed(project):
if project.has_computation_going_on():
return
tasks = []
post_worktable_tasks = []
if not os.path.exists(project.get_worktable_path()):
tasks.append(create_project_worktable.si(project.id))
if project.get_global_manhattan_plot_path() and not os.path.exists(project.get_global_manhattan_plot_path()):
tasks.append(create_project_global_plot.si(project.id))
post_worktable_tasks.append(create_project_global_plot.si(project.id))
if project.get_quadrant_plot_path() and not os.path.exists(project.get_quadrant_plot_path()):
tasks.append(create_project_quadrant_plot.si(project.id))
post_worktable_tasks.append(create_project_quadrant_plot.si(project.id))
if project.get_qq_plot_path() and not os.path.exists(project.get_qq_plot_path()):
tasks.append(create_project_qq_plot.si(project.id))
post_worktable_tasks.append(create_project_qq_plot.si(project.id))
if project.get_csv_path() and not os.path.exists(project.get_csv_path()):
tasks.append(create_project_csv_file.si(project.id))
post_worktable_tasks.append(create_project_csv_file.si(project.id))
if len(tasks) == 0:
if len(tasks) + len(post_worktable_tasks) == 0:
return
main_wf = chain(
*tasks,
group(post_worktable_tasks),
# it is mandatory to add a task that do nothing if group is used in order to have a success/failure status
# dummy_task.si(),
dummy_task.si(),
)
task = main_wf.delay()
project.celery_id = task.id
Loading