From 8a9bdc27c9f60ead1025e2adb33ff2de996307c5 Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Fri, 20 Oct 2023 12:56:28 +0200 Subject: [PATCH] add transaction atomic when submitting sequence --- src/core/pyros_django/seq_submit/functions.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/pyros_django/seq_submit/functions.py b/src/core/pyros_django/seq_submit/functions.py index a775399..f5470ad 100644 --- a/src/core/pyros_django/seq_submit/functions.py +++ b/src/core/pyros_django/seq_submit/functions.py @@ -8,7 +8,7 @@ from django.forms.models import model_to_dict from user_mgmt.models import PyrosUser, ScientificProgram, Period from seq_submit.models import Sequence, Album, Plan from .forms import SequenceForm, PlanForm #, AlbumForm -from django.db import IntegrityError +from django.db import IntegrityError, transaction # Project imports from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig from django.http import HttpRequest @@ -20,6 +20,7 @@ import vendor.guitastro.src.guitastro as guitastro import numpy #@silk_profile(name="check_sequence_file") +@transaction.atomic def check_sequence_file_validity_and_save(yaml_content: dict, request: HttpRequest): ''' Create a sequence in DB from the uploaded sequence (yaml_content) ''' @@ -39,10 +40,10 @@ def check_sequence_file_validity_and_save(yaml_content: dict, request: HttpReque is_simplified = yaml_content.get("simplified", False) # Get scientific programs for the user who is submitting the sequence file user_sp = request.user.get_scientific_programs() + process_sequence(yaml_content, seq, config, is_simplified, result, user_sp) - process_albums(yaml_content, result, config, seq, is_simplified) - + # optim possible ? #[ process_plans(a["Album"].get("Plans")) for a in albums_from_file ] @@ -442,8 +443,8 @@ def create_sequence_pickle(sequence): config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"], unit_name) pyros_config = ConfigPyros(os.environ["pyros_config_file"]) config.fn.fcontext = "pyros_seq" - home = guitastro.Home(config.getHome()) - config.fn.longitude(home.longitude) + # home = guitastro.Home(config.getHome()) + # config.fn.longitude = home.longitude period_id = str(period.id) if len(str(period.id)) < 3: while len(period_id) < 3: -- libgit2 0.21.2