Skip to content

Commit ff4eece

Browse files
authored
Merge pull request #111 from ampas/feature/polish
PR: Use `colour` checks configuration.
2 parents ee1fe3c + 6e7b849 commit ff4eece

29 files changed

+1580
-1179
lines changed

.gitignore

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
# Common Files
12
*.egg-info
23
*.pyc
34
*.pyo
45
.DS_Store
5-
.coverage
6-
.idea
6+
.coverage*
7+
uv.lock
8+
9+
# Common Directories
10+
.fleet/
11+
.idea/
12+
.ipynb_checkpoints/
13+
.python-version
14+
.vs/
15+
.vscode/
16+
.sandbox/
17+
build/
18+
dist/
19+
docs/_build/
20+
docs/generated/
21+
node_modules/
22+
references/
23+
724
__pycache__
8-
poetry.lock
9-
/tests/output/**
25+
26+
# Project Directories
27+
tests/output/

.pre-commit-config.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: "v4.5.0"
3+
rev: "v5.0.0"
44
hooks:
55
- id: check-added-large-files
66
- id: check-case-conflict
77
- id: check-merge-conflict
88
- id: check-symlinks
99
- id: check-yaml
10+
exclude: config-aces-reference.ocio.yaml
1011
- id: debug-statements
1112
- id: end-of-file-fixer
1213
- id: mixed-line-ending
@@ -15,32 +16,30 @@ repos:
1516
- id: requirements-txt-fixer
1617
- id: trailing-whitespace
1718
- repo: https://github.com/codespell-project/codespell
18-
rev: v2.2.6
19+
rev: v2.3.0
1920
hooks:
2021
- id: codespell
21-
- repo: https://github.com/ikamensh/flynt
22-
rev: "1.0.1"
23-
hooks:
24-
- id: flynt
25-
args: [--verbose]
22+
args: ["--ignore-words-list=rIn"]
2623
- repo: https://github.com/PyCQA/isort
2724
rev: "5.13.2"
2825
hooks:
2926
- id: isort
3027
- repo: https://github.com/astral-sh/ruff-pre-commit
31-
rev: "v0.1.14"
28+
rev: "v0.8.2"
3229
hooks:
3330
- id: ruff-format
3431
- id: ruff
32+
args: [--fix]
3533
- repo: https://github.com/adamchainz/blacken-docs
36-
rev: 1.16.0
34+
rev: 1.19.1
3735
hooks:
3836
- id: blacken-docs
3937
language_version: python3.10
4038
- repo: https://github.com/pre-commit/mirrors-prettier
41-
rev: "v3.1.0"
39+
rev: "v4.0.0-alpha.8"
4240
hooks:
4341
- id: prettier
42+
exclude: config-aces-reference.ocio.yaml
4443
- repo: https://github.com/pre-commit/pygrep-hooks
4544
rev: "v1.10.0"
4645
hooks:

aces/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import matplotlib as mpl
2+
3+
mpl.use("Agg")

aces/idt/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"sort_exposure_keys",
8484
"working_directory",
8585
]
86-
8786
__all__ += ["IDTProjectSettings"]
8887
__all__ += [
8988
"GENERATORS",

aces/idt/application.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,26 @@
55
Define the *IDT* generator application class.
66
"""
77

8+
from __future__ import annotations
9+
810
import logging
911
import re
12+
import typing
1013
from pathlib import Path
1114

12-
from colour.hints import List
15+
if typing.TYPE_CHECKING:
16+
from colour.hints import List
17+
1318
from colour.utilities import attest, optional
1419

1520
import aces.idt.core.common
1621
from aces.idt.core.constants import DirectoryStructure
17-
from aces.idt.core.trasform_id import generate_idt_urn, is_valid_idt_urn
22+
from aces.idt.core.transform_id import generate_idt_urn, is_valid_csc_urn
1823
from aces.idt.framework.project_settings import IDTProjectSettings
1924
from aces.idt.generators import GENERATORS
20-
from aces.idt.generators.base_generator import IDTBaseGenerator
25+
26+
if typing.TYPE_CHECKING:
27+
from aces.idt.generators.base_generator import IDTBaseGenerator
2128

2229
__author__ = "Alex Forsythe, Joshua Pines, Thomas Mansencal, Nick Shaw, Adam Davis"
2330
__copyright__ = "Copyright 2022 Academy of Motion Picture Arts and Sciences"
@@ -84,15 +91,17 @@ def generator(self) -> IDTBaseGenerator:
8491
return self._generator
8592

8693
@generator.setter
87-
def generator(self, value: str):
94+
def generator(self, value: str) -> None:
8895
"""Setter for the **self.generator** property."""
8996

9097
if value not in self.generator_names:
91-
raise ValueError(
98+
exception = (
9299
f'"{value}" generator is invalid, must be one of '
93100
f'"{self.generator_names}"!'
94101
)
95102

103+
raise ValueError(exception)
104+
96105
self._generator = GENERATORS[value](self.project_settings)
97106

98107
@property
@@ -113,7 +122,7 @@ def project_settings(self) -> IDTProjectSettings:
113122
return self._project_settings
114123

115124
@project_settings.setter
116-
def project_settings(self, value: IDTProjectSettings):
125+
def project_settings(self, value: IDTProjectSettings) -> None:
117126
"""Setter for the **self.project_settings** property."""
118127

119128
self._project_settings.update(value)
@@ -239,19 +248,18 @@ def _verify_file_type(self) -> None:
239248
"""
240249

241250
file_types = set()
242-
for _, value in self.project_settings.data[
251+
for value in self.project_settings.data[
243252
DirectoryStructure.COLOUR_CHECKER
244-
].items():
253+
].values():
245254
for item in value:
246255
file_types.add(item.suffix)
247256

248257
for item in self.project_settings.data[DirectoryStructure.GREY_CARD]:
249258
file_types.add(item.suffix)
250259

251260
if len(file_types) > 1:
252-
raise ValueError(
253-
f'Multiple file types found in the project settings: "{file_types}"'
254-
)
261+
msg = f'Multiple file types found in the project settings: "{file_types}"'
262+
raise ValueError(msg)
255263

256264
self.project_settings.file_type = next(iter(file_types))
257265

@@ -279,8 +287,9 @@ def extract(self, archive: str, directory: str | None = None) -> str:
279287
json_files = list(root_directory.glob("*.json"))
280288

281289
if len(json_files) > 1:
282-
raise ValueError('Multiple "JSON" files found in the root directory!')
283-
elif len(json_files) == 1:
290+
msg = 'Multiple "JSON" files found in the root directory!'
291+
raise ValueError(msg)
292+
if len(json_files) == 1:
284293
json_file = next(iter(json_files))
285294
LOGGER.info('Found explicit "%s" "IDT" project settings file.', json_file)
286295
self.project_settings = IDTProjectSettings.from_file(json_file)
@@ -315,7 +324,9 @@ def process_archive(self, archive: str | None) -> IDTBaseGenerator:
315324
"""
316325

317326
if self.generator is None:
318-
raise ValueError('No "IDT" generator was selected!')
327+
exception = 'No "IDT" generator was set!'
328+
329+
raise ValueError(exception)
319330

320331
if archive is not None:
321332
self.project_settings.working_directory = self.extract(archive)
@@ -324,7 +335,7 @@ def process_archive(self, archive: str | None) -> IDTBaseGenerator:
324335
for exposure in list(
325336
self.project_settings.data[DirectoryStructure.COLOUR_CHECKER].keys()
326337
):
327-
images = [ # noqa: C416
338+
images = [
328339
image
329340
for image in self.project_settings.data[
330341
DirectoryStructure.COLOUR_CHECKER
@@ -338,27 +349,29 @@ def process_archive(self, archive: str | None) -> IDTBaseGenerator:
338349
return self.process()
339350

340351
def process(self) -> IDTBaseGenerator:
341-
"""Run the *IDT* generator application process maintaining the execution steps
352+
"""
353+
Run the *IDT* generator application process maintaining the execution steps.
342354
343355
Returns
344356
-------
345357
:class:`IDTBaseGenerator`
346358
Instantiated *IDT* generator. after the process has been run
347-
348359
"""
360+
349361
self.validate_project_settings()
350362
self.generator.sample()
351363
self.generator.sort()
352-
self.generator.remove_clipping()
364+
self.generator.remove_clipped_samples()
353365
self.generator.generate_LUT()
354366
self.generator.filter_LUT()
355367
self.generator.decode()
356368
self.generator.optimise()
369+
357370
return self.generator
358371

359372
def zip(
360373
self, output_directory: Path | str, archive_serialised_generator: bool = False
361-
) -> str:
374+
) -> Path:
362375
"""
363376
Create a *zip* file with the output of the *IDT* application process.
364377
@@ -371,12 +384,14 @@ def zip(
371384
372385
Returns
373386
-------
374-
:class:`str`
387+
:class:`pathlib.Path`
375388
*Zip* file path.
376389
"""
377390

378391
if not self.generator:
379-
raise ValueError("No Idt Generator Set")
392+
exception = 'No "IDT" generator was set!'
393+
394+
raise ValueError(exception)
380395

381396
return self.generator.zip(
382397
output_directory, archive_serialised_generator=archive_serialised_generator
@@ -390,8 +405,9 @@ def validate_project_settings(self) -> None:
390405
ValueError
391406
If any of the validations fail
392407
"""
408+
393409
# Check the aces_transform_id is a valid idt_urn
394-
if not is_valid_idt_urn(self.project_settings.aces_transform_id):
410+
if not is_valid_csc_urn(self.project_settings.aces_transform_id):
395411
# If the aces_transform_id is not valid, generate a new one
396412
new_name = generate_idt_urn(
397413
self.project_settings.aces_user_name,

aces/idt/core/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
SD_ILLUMINANT_ACES,
66
SDS_COLORCHECKER_CLASSIC,
77
SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC,
8-
calculate_clipped_exposures,
98
clf_processing_elements,
109
error_delta_E,
1110
extract_archive,
12-
find_close_indices,
11+
find_clipped_exposures,
12+
find_similar_rows,
1313
format_exposure_key,
1414
generate_reference_colour_checker,
1515
get_sds_colour_checker,
@@ -26,7 +26,7 @@
2626
)
2727
from .constants import (
2828
CAT,
29-
CLIPPING_THRESHOLD,
29+
EXPOSURE_CLIPPING_THRESHOLD,
3030
DecodingMethods,
3131
DirectoryStructure,
3232
Interpolators,
@@ -69,12 +69,12 @@
6969
"slugify",
7070
"sort_exposure_keys",
7171
"working_directory",
72-
"find_close_indices",
73-
"calculate_clipped_exposures",
72+
"find_similar_rows",
73+
"find_clipped_exposures",
7474
]
7575

7676
__all__ += [
77-
"CLIPPING_THRESHOLD",
77+
"EXPOSURE_CLIPPING_THRESHOLD",
7878
"CAT",
7979
"DirectoryStructure",
8080
"DecodingMethods",

0 commit comments

Comments
 (0)