Skip to content
Snippets Groups Projects
Commit 896b7dc0 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-152: logging

parent af0ba75b
No related branches found
No related tags found
1 merge request!180Resolve TMSS-152
...@@ -125,7 +125,7 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model ...@@ -125,7 +125,7 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model
Create a task_blueprint from the task_draft Create a task_blueprint from the task_draft
:raises Exception if instantiate fails. :raises Exception if instantiate fails.
""" """
logger.debug("Create Task Blueprint from Task Draft (id=%s)", task_draft.pk) logger.debug("creating task_blueprint from task_draft id=%s", task_draft.pk)
# get or create a scheduling_unit_blueprint from the scheduling_unit_draft # get or create a scheduling_unit_blueprint from the scheduling_unit_draft
scheduling_unit_blueprint = task_draft.scheduling_unit_draft.scheduling_unit_blueprints.last() scheduling_unit_blueprint = task_draft.scheduling_unit_draft.scheduling_unit_blueprints.last()
...@@ -144,12 +144,12 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model ...@@ -144,12 +144,12 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model
specifications_template=task_draft.specifications_template specifications_template=task_draft.specifications_template
) )
logger.info("Task Blueprint (id=%s) created from Task Draft (id=%s)", task_blueprint.pk, task_draft.pk) logger.info("created task_blueprint id=%s from task_draft id=%s", task_blueprint.pk, task_draft.pk)
# now that we have a task_blueprint, its time to refresh the task_draft so we get the non-cached fields # now that we have a task_blueprint, its time to refresh the task_draft so we get the non-cached fields
task_draft.refresh_from_db() task_draft.refresh_from_db()
# loop over consumers/producers, and 'copy'' the TaskRelationBlueprint from the TaskRelationDraft # loop over consumers/producers, and 'copy' the TaskRelationBlueprint from the TaskRelationDraft
# this is only possible if both 'ends' of the task_relation are converted to a TaskBlueprint # this is only possible if both 'ends' of the task_relation are converted to a TaskBlueprint
# so, when converting two TaskDrafts (for example an observation and a pipeline), then for the conversion # so, when converting two TaskDrafts (for example an observation and a pipeline), then for the conversion
# of the first TaskDraft->TaskBlueprint no relation is setup, # of the first TaskDraft->TaskBlueprint no relation is setup,
...@@ -171,10 +171,10 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model ...@@ -171,10 +171,10 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model
selection_doc=task_relation_draft.selection_doc, selection_doc=task_relation_draft.selection_doc,
selection_template=task_relation_draft.selection_template, selection_template=task_relation_draft.selection_template,
dataformat=task_relation_draft.dataformat) dataformat=task_relation_draft.dataformat)
logger.info("Task Blueprint (id=%s) connected to Task Blueprint (id=%s) via Task Relation Blueprint (id=%s)", logger.info("created task_relation_blueprint id=%s which connects task_blueprints producer_id=%s and consumer_id=%s",
task_blueprint.pk, producing_task_blueprint.pk, task_relation_blueprint.pk) task_relation_blueprint.pk, producing_task_blueprint.pk, consuming_task_blueprint.pk,)
# Do the sam 'trick' for Task Scheduling Relation Draft to Blueprint # Do the same 'trick' for Task Scheduling Relation Draft to Blueprint
task_draft_scheduling_relations = list(task_draft.first_to_connect.all()) + list(task_draft.second_to_connect.all()) task_draft_scheduling_relations = list(task_draft.first_to_connect.all()) + list(task_draft.second_to_connect.all())
for task_scheduling_relation_draft in task_draft_scheduling_relations: for task_scheduling_relation_draft in task_draft_scheduling_relations:
for first_task_blueprint in task_scheduling_relation_draft.first.task_blueprints.all(): for first_task_blueprint in task_scheduling_relation_draft.first.task_blueprints.all():
...@@ -185,16 +185,13 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model ...@@ -185,16 +185,13 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model
second_id=second_task_blueprint.id) second_id=second_task_blueprint.id)
except models.TaskSchedulingRelationBlueprint.DoesNotExist: except models.TaskSchedulingRelationBlueprint.DoesNotExist:
# ...'else' create it. # ...'else' create it.
task_scheduling_relation_blueprint = models.TaskSchedulingRelationBlueprint.objects.create( task_scheduling_relation_blueprint = models.TaskSchedulingRelationBlueprint.objects.create(first=first_task_blueprint,
first=first_task_blueprint, second=second_task_blueprint,
second=second_task_blueprint, time_offset=task_scheduling_relation_draft.time_offset,
time_offset=task_scheduling_relation_draft.time_offset, placement=task_scheduling_relation_draft.placement)
placement=task_scheduling_relation_draft.placement) logger.info("created task_scheduling_relation_blueprint id=%s which connects task_blueprints first_id=%s and second_id=%s, placement=%s time_offset=%s[sec]",
logger.info("Task Blueprint (id=%s) connected via scheduling relation with id=%s", task_scheduling_relation_blueprint.pk, first_task_blueprint.pk, second_task_blueprint.pk, task_scheduling_relation_draft.placement, task_scheduling_relation_draft.time_offset)
task_blueprint.pk, task_scheduling_relation_blueprint.pk)
logger.info("The scheduling relation is: '%s' (id=%s) '%s' '%s' (id=%s)",
first_task_blueprint.name, first_task_blueprint.pk, task_scheduling_relation_blueprint.placement,
second_task_blueprint.name, second_task_blueprint.pk)
return task_blueprint return task_blueprint
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment