Skip to content

Commit

Permalink
Merge pull request #1931 from pupil-labs/fix-updating-imported-v1-calibs
Browse files Browse the repository at this point in the history
Fix updating imported v1 calibs
  • Loading branch information
papr authored Jun 29, 2020
2 parents f9db20b + 1fecc8d commit ca77307
Showing 1 changed file with 13 additions and 3 deletions.
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 @@ -48,21 +49,30 @@ def update_offline_calibrations_to_latest_version(cls, rec_dir):
elif data is not None:
try:
if version == CalibrationV1.version == 1:
cls.__update_and_save_calibration_v1_as_latest_verson(
cls.__update_and_save_calibration_v1_as_latest_version(
rec_dir, data
)
continue # Success
except Exception as err:
logger.debug(str(err))
logger.warning(str(err))

# Failed to update
logger.warning(
f'Unable to update calibration "{calib_path.name}" from version {version} to the current version {Calibration.version}'
)

@classmethod
def __update_and_save_calibration_v1_as_latest_verson(cls, rec_dir, data):
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 ca77307

Please sign in to comment.