Skip to content

Commit 005be84

Browse files
committed
Add a flag which allows us to expose aces2.0 support by a flag in the cli
1 parent 69c4bf2 commit 005be84

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

packages/open_vp_cal/src/open_vp_cal/core/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
DEFAULT_RESOLUTION_HEIGHT = 1080
5656

5757
DEFAULT_OCIO_CONFIG = "studio-config-v2.1.0_aces-v1.3_ocio-v2.3"
58+
DEFAULT_ACES_2_OCIO_CONFIG = "studio-config-v4.0.0_aces-v2.0_ocio-v2.5"
59+
5860
ARC_CONFIG = "arc_config.xml"
5961

6062

packages/open_vp_cal/src/open_vp_cal/core/resource_loader.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ class ResourceLoader:
3232
folder within the installed package.
3333
3434
"""
35+
_enable_aces_2: bool = False
36+
37+
@classmethod
38+
def set_enable_aces_2(cls, enable: bool) -> None:
39+
"""Set whether to use ACES 2.0 OCIO config globally.
40+
41+
Args:
42+
enable: If True, use the ACES 2.0 OCIO config instead of the default
43+
"""
44+
cls._enable_aces_2 = enable
45+
3546
@staticmethod
3647
def _get_resource(filename: str) -> str:
3748
""" For the given filename, we return the absolute file path from within the installed package.
@@ -48,13 +59,15 @@ def _get_resource(filename: str) -> str:
4859
def ocio_config_path(cls) -> str:
4960
"""
5061
51-
Returns: The absolute path to the ocio config file
62+
Returns: The absolute path to the ocio config file. Uses ACES 2.0 config if
63+
set_enable_aces_2(True) was called, otherwise uses the default ACES 1.3 config.
5264
5365
"""
66+
config_name = constants.DEFAULT_ACES_2_OCIO_CONFIG if cls._enable_aces_2 else constants.DEFAULT_OCIO_CONFIG
5467
ocio_config_path = os.path.join(
55-
cls.prefs_dir(), f"{constants.DEFAULT_OCIO_CONFIG}{ocio.OCIO_CONFIG_DEFAULT_FILE_EXT}")
68+
cls.prefs_dir(), f"{config_name}{ocio.OCIO_CONFIG_DEFAULT_FILE_EXT}")
5669
if not os.path.exists(ocio_config_path):
57-
ocio.Config().CreateFromBuiltinConfig(constants.DEFAULT_OCIO_CONFIG).serialize(ocio_config_path)
70+
ocio.Config().CreateFromBuiltinConfig(config_name).serialize(ocio_config_path)
5871
return ocio_config_path
5972

6073
@classmethod

packages/open_vp_cal/src/open_vp_cal/main.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
from open_vp_cal.project_settings import ProjectSettings
3535

3636

37-
def open_ui() -> None:
37+
def open_ui(enable_aces_2: bool = False) -> None:
3838
""" Opens the MainWindow as QApplication after the splash screen loads
39+
40+
Args:
41+
enable_aces_2: Whether to use the ACES 2.0 OCIO config instead of the default
3942
"""
43+
ResourceLoader.set_enable_aces_2(enable_aces_2)
4044
from PySide6.QtWidgets import QMessageBox
4145
from PySide6 import QtWidgets
4246
from PySide6.QtGui import QPixmap
@@ -211,7 +215,8 @@ def add_error_to_log(error_log: str, error: str) -> None:
211215
def run_cli(
212216
project_settings_file_path: str,
213217
output_folder: str,
214-
ocio_config_path: str = None, force=False, error_log: str = None, export_analysis_swatches: bool = False ) -> dict[str, LedWallSettings]:
218+
ocio_config_path: str = None, force=False, error_log: str = None, export_analysis_swatches: bool = False,
219+
enable_aces_2: bool = False) -> dict[str, LedWallSettings]:
215220
""" Runs the application in CLI mode to process the given project settings file.
216221
217222
Args:
@@ -222,10 +227,13 @@ def run_cli(
222227
primarily for testing purposes
223228
error_log: The error log file path to store errors in as a json file
224229
export_analysis_swatches: For debugging we can force the swatches to be exported after the analysis
230+
enable_aces_2: Whether to use the ACES 2.0 OCIO config instead of the default
225231
226232
Returns: The list of ProcessingResults
227233
228234
"""
235+
ResourceLoader.set_enable_aces_2(enable_aces_2)
236+
229237
project_settings = ProjectSettings.from_json(project_settings_file_path)
230238
project_settings.output_folder = output_folder
231239
open_vp_cal_base = OpenVPCalBase()
@@ -314,7 +322,7 @@ def run_args(args: argparse.Namespace) -> None:
314322
args: The command line arguments
315323
"""
316324
if args.ui:
317-
open_ui()
325+
open_ui(enable_aces_2=args.enable_aces_2)
318326
else:
319327

320328
if args.generate_patterns:
@@ -328,7 +336,8 @@ def run_args(args: argparse.Namespace) -> None:
328336
args.output_folder,
329337
args.ocio_config_path,
330338
force=args.ignore_errors,
331-
error_log=args.error_log
339+
error_log=args.error_log,
340+
enable_aces_2=args.enable_aces_2
332341
)
333342

334343

@@ -372,6 +381,8 @@ def parse_args() -> argparse.Namespace:
372381
parser.add_argument('--ignore_errors', type=str2bool, default=False,
373382
help='CLI flag to ignore any errors produced during the calibration process and logging them in the provided error log file')
374383
parser.add_argument('--error_log', required=False, help='A file path to store any errors in a json file, the file is created if it does not already exist')
384+
parser.add_argument('--enable_aces_2', type=str2bool, default=False,
385+
help='CLI flag to use the ACES 2.0 OCIO config instead of the default ACES 1.3 config')
375386
args = parser.parse_args(sys.argv[1:])
376387

377388
if not args.ui:

0 commit comments

Comments
 (0)