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