Commit 8a9bdc27c9f60ead1025e2adb33ff2de996307c5
1 parent
c39802e5
Exists in
dev
add transaction atomic when submitting sequence
Showing
1 changed file
with
6 additions
and
5 deletions
Show diff stats
src/core/pyros_django/seq_submit/functions.py
... | ... | @@ -8,7 +8,7 @@ from django.forms.models import model_to_dict |
8 | 8 | from user_mgmt.models import PyrosUser, ScientificProgram, Period |
9 | 9 | from seq_submit.models import Sequence, Album, Plan |
10 | 10 | from .forms import SequenceForm, PlanForm #, AlbumForm |
11 | -from django.db import IntegrityError | |
11 | +from django.db import IntegrityError, transaction | |
12 | 12 | # Project imports |
13 | 13 | from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig |
14 | 14 | from django.http import HttpRequest |
... | ... | @@ -20,6 +20,7 @@ import vendor.guitastro.src.guitastro as guitastro |
20 | 20 | import numpy |
21 | 21 | |
22 | 22 | #@silk_profile(name="check_sequence_file") |
23 | +@transaction.atomic | |
23 | 24 | def check_sequence_file_validity_and_save(yaml_content: dict, request: HttpRequest): |
24 | 25 | ''' Create a sequence in DB from the uploaded sequence (yaml_content) ''' |
25 | 26 | |
... | ... | @@ -39,10 +40,10 @@ def check_sequence_file_validity_and_save(yaml_content: dict, request: HttpReque |
39 | 40 | is_simplified = yaml_content.get("simplified", False) |
40 | 41 | # Get scientific programs for the user who is submitting the sequence file |
41 | 42 | user_sp = request.user.get_scientific_programs() |
43 | + | |
42 | 44 | process_sequence(yaml_content, seq, config, is_simplified, result, user_sp) |
43 | - | |
44 | 45 | process_albums(yaml_content, result, config, seq, is_simplified) |
45 | - | |
46 | + | |
46 | 47 | |
47 | 48 | # optim possible ? |
48 | 49 | #[ process_plans(a["Album"].get("Plans")) for a in albums_from_file ] |
... | ... | @@ -442,8 +443,8 @@ def create_sequence_pickle(sequence): |
442 | 443 | config = OBSConfig(os.environ["PATH_TO_OBSCONF_FILE"], unit_name) |
443 | 444 | pyros_config = ConfigPyros(os.environ["pyros_config_file"]) |
444 | 445 | config.fn.fcontext = "pyros_seq" |
445 | - home = guitastro.Home(config.getHome()) | |
446 | - config.fn.longitude(home.longitude) | |
446 | + # home = guitastro.Home(config.getHome()) | |
447 | + # config.fn.longitude = home.longitude | |
447 | 448 | period_id = str(period.id) |
448 | 449 | if len(str(period.id)) < 3: |
449 | 450 | while len(period_id) < 3: | ... | ... |