Skip to content

Commit

Permalink
Prevent updating imported offline calibrations v1
Browse files Browse the repository at this point in the history
  • Loading branch information
pfaion committed Jun 26, 2020
1 parent fd83914 commit 1fecc8d
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import file_methods as fm
from gaze_producer.model.calibration import Calibration
from gaze_producer.model.calibration_storage import CalibrationStorage
from pupil_recording import PupilRecording

from .calibration_v1 import CalibrationV1

Expand Down Expand Up @@ -53,7 +54,7 @@ def update_offline_calibrations_to_latest_version(cls, rec_dir):
)
continue # Success
except Exception as err:
logger.debug(str(err))
logger.warning(str(err))

# Failed to update
logger.warning(
Expand All @@ -63,6 +64,15 @@ def update_offline_calibrations_to_latest_version(cls, rec_dir):
@classmethod
def __update_and_save_calibration_v1_as_latest_version(cls, rec_dir, data):
legacy_calibration = CalibrationV1.from_tuple(data)

recording_uuid = str(PupilRecording(rec_dir).meta_info.recording_uuid)
is_imported = legacy_calibration.recording_uuid != recording_uuid
if is_imported:
raise ValueError(
"Updating imported (read-only) calibrations is not supported. "
f"{legacy_calibration.name}"
)

updated_calibration = legacy_calibration.updated()
cls._save_calibration_to_file(
rec_dir, updated_calibration, overwrite_if_exists=False
Expand Down

0 comments on commit 1fecc8d

Please sign in to comment.