From: Thomas Mansencal Date: Mon, 19 Jan 2015 14:52:48 +0000 (+0100) Subject: Add "create_aces_config" and "tests_aces_config" binaries. X-Git-Url: http://users.mur.at/ms/git/gitweb/?p=OpenColorIO-Configs.git;a=commitdiff_plain;h=e4267330034323ce04c3a3ce813cfee42482eb22 Add "create_aces_config" and "tests_aces_config" binaries. --- diff --git a/aces_1.0.0/python/aces_ocio/__init__.py b/aces_1.0.0/python/aces_ocio/__init__.py index 73ec153..7a50220 100644 --- a/aces_1.0.0/python/aces_ocio/__init__.py +++ b/aces_1.0.0/python/aces_ocio/__init__.py @@ -11,19 +11,33 @@ Usage Python ****** ->>> import sys ->>> sys.path.append('/path/to/script') ->>> import create_aces_config as cac ->>> acesReleaseCTLDir = '/path/to/github/checkout/releases/v0.7.1/transforms/ctl' ->>> configDir = '/path/to/config/dir' ->>> cac.createACESConfig(acesReleaseCTLDir, configDir, 1024, 33, True) +>>> from aces_ocio.create_aces_config import create_ACES_config +>>> aces_CTL_directory = '/path/to/github/checkout/releases/v1.0.0/transforms/ctl' +>>> config_directory = '/path/to/configuration/dir' +>>> create_ACES_config(aces_CTL_directory, config_directory, 1024, 33, True) Command Line ************ -From the directory with 'create_aces_config.py': +Using the *create_aces_config* binary: -$ python create_aces_config.py -a '/path/to/github/checkout/releases/v0.7.1/transforms/ctl' -c '/path/to/config/dir' --lut_resolution_1d 1024 --lut_resolution_3d 33 --keepTempImages +$ create_aces_config -a '/path/to/github/checkout/releases/v0.7.1/transforms/ctl' -c '/path/to/config/dir' --lutResolution1d 1024 --lutResolution3d 33 --keepTempImages + +It is possible to set the following environment variables to avoid passing +the paths to the binary: + +- *ACES_OCIO_CTL_DIRECTORY* +- *ACES_OCIO_CONFIGURATION_DIRECTORY* + +The above command line call would be done as follows: + +$ create_aces_config --lutResolution1d 1024 --lutResolution3d 33 --keepTempImages + +Testing the generated configuration is needs the +*ACES_OCIO_CTL_DIRECTORY* environment variable to be set and is done as +follows: + +$ tests_aces_config Build ----- diff --git a/aces_1.0.0/python/aces_ocio/create_aces_config.py b/aces_1.0.0/python/aces_ocio/create_aces_config.py index 44dc565..71fd1a7 100755 --- a/aces_1.0.0/python/aces_ocio/create_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/create_aces_config.py @@ -13,11 +13,6 @@ import shutil import string import sys -# TODO: This restores the capability of running the script without having -# added the package to PYTHONPATH, this is ugly and should ideally replaced by -# dedicated executable in a /bin directory. -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) - import PyOpenColorIO as ocio import aces_ocio.create_arri_colorspaces as arri @@ -1818,9 +1813,9 @@ def main(): version='createACESConfig 0.1', usage='%prog [options]') p.add_option('--acesCTLDir', '-a', default=os.environ.get( - 'ACES_OCIO_CTL_DIRECTORY', None)) + ACES_OCIO_CTL_DIRECTORY_ENVIRON, None)) p.add_option('--configDir', '-c', default=os.environ.get( - 'ACES_OCIO_CONFIGURATION_DIRECTORY', None)) + ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON, None)) p.add_option('--lutResolution1d', default=4096) p.add_option('--lutResolution3d', default=64) p.add_option('--dontBakeSecondaryLUTs', action='store_true') @@ -1835,9 +1830,10 @@ def main(): config_directory = options.configDir lut_resolution_1d = int(options.lutResolution1d) lut_resolution_3d = int(options.lutResolution3d) - bake_secondary_LUTs = not (options.dontBakeSecondaryLUTs) - cleanup_temp_images = not (options.keepTempImages) + bake_secondary_LUTs = not options.dontBakeSecondaryLUTs + cleanup_temp_images = not options.keepTempImages + # TODO: Investigate the following statements. try: args_start = sys.argv.index('--') + 1 args = sys.argv[args_start:] @@ -1847,16 +1843,16 @@ def main(): print('command line : \n%s\n' % ' '.join(sys.argv)) - # TODO: Use assertion and mention environment variables. - if not aces_CTL_directory: - print('process: No ACES CTL directory specified') - return - if not config_directory: - print('process: No configuration directory specified') - return - # - # Generate the configuration - # + assert aces_CTL_directory is not None, ( + 'process: No "{0}" environment variable defined or no "ACES CTL" ' + 'directory specified'.format( + ACES_OCIO_CTL_DIRECTORY_ENVIRON)) + + assert config_directory is not None, ( + 'process: No "{0}" environment variable defined or no configuration ' + 'directory specified'.format( + ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON)) + return create_ACES_config(aces_CTL_directory, config_directory, lut_resolution_1d, diff --git a/aces_1.0.0/python/aces_ocio/generate_lut.py b/aces_1.0.0/python/aces_ocio/generate_lut.py old mode 100644 new mode 100755 index ac5a875..bd2640a --- a/aces_1.0.0/python/aces_ocio/generate_lut.py +++ b/aces_1.0.0/python/aces_ocio/generate_lut.py @@ -534,8 +534,8 @@ def main(): p.add_option('--lut', '-l', type='string', default='') p.add_option('--ctl', '-c', type='string', action='append') - p.add_option('--lut_resolution_1d', '', type='int', default=1024) - p.add_option('--lut_resolution_3d', '', type='int', default=33) + p.add_option('--lutResolution1d', '', type='int', default=1024) + p.add_option('--lutResolution3d', '', type='int', default=33) p.add_option('--ctlReleasePath', '-r', type='string', default='') p.add_option('--bitDepth', '-b', type='string', default='float') p.add_option('--keepTempImages', '', action='store_true') @@ -565,7 +565,7 @@ def main(): ctl_release_path = options.ctlReleasePath generate_1d = options.generate1d is True generate_3d = options.generate3d is True - bitdepth = options.bitDepth + bit_depth = options.bitDepth cleanup = not options.keepTempImages params = {} @@ -600,14 +600,14 @@ def main(): print('output scale : %s' % output_scale) print('ctl render params : %s' % params) print('ctl release path : %s' % ctl_release_path) - print('bit depth of input : %s' % bitdepth) + print('bit depth of input : %s' % bit_depth) print('cleanup temp images : %s' % cleanup) if generate_1d: generate_1d_LUT_from_CTL(lut, ctls, lut_resolution_1d, - bitdepth, + bit_depth, input_scale, output_scale, params, @@ -620,7 +620,7 @@ def main(): generate_3d_LUT_from_CTL(lut, ctls, lut_resolution_3d, - bitdepth, + bit_depth, input_scale, output_scale, params, diff --git a/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py b/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py index 61acfa5..8814e90 100644 --- a/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py @@ -9,12 +9,6 @@ import hashlib import os import re import shutil -import sys - -# TODO: Temporary ugly thing to be discussed, ideally the package should be -# in PYTHONPATH. -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) - import tempfile import unittest @@ -39,7 +33,7 @@ __all__ = ['REFERENCE_CONFIG_ROOT_DIRECTORY', # TODO: Investigate how the current config has been generated to use it for # tests. # REFERENCE_CONFIG_ROOT_DIRECTORY = os.path.abspath( -# os.path.join(os.path.dirname(__file__), '..', '..', '..')) +# os.path.join(os.path.dirname(__file__), '..', '..', '..')) REFERENCE_CONFIG_ROOT_DIRECTORY = '/colour-science/colour-ramblings/ocio/aces' HASH_TEST_PATTERNS = ('\.3dl', '\.lut', '\.csp') diff --git a/aces_1.0.0/python/bin/create_aces_config b/aces_1.0.0/python/bin/create_aces_config new file mode 100755 index 0000000..b59fa39 --- /dev/null +++ b/aces_1.0.0/python/bin/create_aces_config @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Creates the *ACES* configuration. +""" + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +from aces_ocio.create_aces_config import main + +__author__ = 'ACES Developers' +__copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers' +__license__ = '' +__maintainer__ = 'ACES Developers' +__email__ = 'aces@oscars.org' +__status__ = 'Production' + +__all__ = [] + +if __name__ == '__main__': + main() diff --git a/aces_1.0.0/python/bin/tests_aces_config b/aces_1.0.0/python/bin/tests_aces_config new file mode 100755 index 0000000..6fe08ed --- /dev/null +++ b/aces_1.0.0/python/bin/tests_aces_config @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Tests the *ACES* configuration. +""" + +import os +import unittest +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +from aces_ocio.tests.tests_aces_config import * + +__author__ = 'ACES Developers' +__copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers' +__license__ = '' +__maintainer__ = 'ACES Developers' +__email__ = 'aces@oscars.org' +__status__ = 'Production' + +if __name__ == '__main__': + unittest.main()