diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 4f4afa2c..560d33ce 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,5 @@ # Reformat code to standardize double quoted strings 92c1ec85ab680851055c16f022ab9ce80c600e3c + +# Format yaml files +8846ba15625de7bfb68d40c4eb224c2c2d59dda2 diff --git a/.github/dependabot.yml b/.github/dependabot.yaml similarity index 100% rename from .github/dependabot.yml rename to .github/dependabot.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yaml similarity index 99% rename from .github/workflows/ci.yml rename to .github/workflows/ci.yaml index 7a7ce029..b0abb9ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yaml @@ -1,3 +1,4 @@ +--- name: ci on: pull_request: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yaml similarity index 96% rename from .github/workflows/release.yml rename to .github/workflows/release.yaml index 9daeeff7..960ee9df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yaml @@ -1,7 +1,9 @@ +--- name: release on: release: - types: [published] + types: + - published jobs: publish: runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index 78a452d3..0705067a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Image redaction is determined by a set of rules. By default, the base set of rul ## Rule Application All runs of `imagedephi` use the provided base set of rules as a foundation. End users can use the ruleset framework to build custom rulesets that handle additional or custom metadata not covered by the base rules, or override the behavior of the base rule set. -Override rule sets can be specified by using the `-r my_ruleset.yml` or `--override-rules my_ruleset.yml` option. This option is available for both the `imagedephi run` and `imagedephi plan` commands. Override rules sets are not provided by `imagedephi`, and must de defined by the end user. +Override rule sets can be specified by using the `-r my_ruleset.yaml` or `--override-rules my_ruleset.yaml` option. This option is available for both the `imagedephi run` and `imagedephi plan` commands. Override rules sets are not provided by `imagedephi`, and must de defined by the end user. When `imagedephi` determines the steps to redact a file, it checks each piece of metadata in the file. For each piece of metadata found this way, it will first consult the override rule set, if present, for an applicable rule. If the override rule set does not contain a rule for that piece of metadata, the program will check the base ruleset. @@ -34,7 +34,7 @@ For whole slide image formats based on the tiff standard, `imagedephi` allows a ## Ruleset Format Overview -In order to read the base rules and build your own custom rule sets, it is important to understand the format in which rulesets are specified. Rulesets are defined by `.yml` files (one ruleset per file), and are a dictionary with the following top-level tags: `name`, `description`, `output_file_name`, `tiff`, and `svs`. +In order to read the base rules and build your own custom rule sets, it is important to understand the format in which rulesets are specified. Rulesets are defined by `.yaml` files (one ruleset per file), and are a dictionary with the following top-level tags: `name`, `description`, `output_file_name`, `tiff`, and `svs`. ### Generic Properties The following three properties belong to the rulesets themselves, and don't influence redaction behavior. diff --git a/imagedephi/base_rules.yaml b/imagedephi/base_rules.yaml index 71c6f985..21559a44 100644 --- a/imagedephi/base_rules.yaml +++ b/imagedephi/base_rules.yaml @@ -1,7 +1,6 @@ +--- name: Base rules -description: These are the default rules for each potential piece of redactable material - (metadata, image) to be used as a fallback if there are no user defined rules for - a piece of redactable material. +description: These are the default rules for each potential piece of redactable material (metadata, image) to be used as a fallback if there are no user defined rules for a piece of redactable material. output_file_name: study_slide tiff: associated_images: diff --git a/imagedephi/minimum_rules.yaml b/imagedephi/minimum_rules.yaml index b5b88c29..dd5f9d14 100644 --- a/imagedephi/minimum_rules.yaml +++ b/imagedephi/minimum_rules.yaml @@ -1,6 +1,6 @@ +--- name: Minimum Rules -description: A set of rules that defines a minimum amount of metadata for images - to be read. Metadata not specified by a rule is deleted (controlled by the metadata_fallback_action). +description: A set of rules that defines a minimum amount of metadata for images to be read. Metadata not specified by a rule is deleted (controlled by the metadata_fallback_action). output_file_name: study_slide tiff: metadata_fallback_action: delete diff --git a/pyproject.toml b/pyproject.toml index f48e6ee5..0b78d7ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,3 +74,8 @@ testpaths = ["tests"] [tool.pyright] stubPath = "stubs" + +[tool.yamlfix] +line_length = 200 +preserve_quotes = true +sequence_style = "block_style" diff --git a/tests/override_rule_sets/example_user_rules.yml b/tests/override_rule_sets/example_user_rules.yaml similarity index 99% rename from tests/override_rule_sets/example_user_rules.yml rename to tests/override_rule_sets/example_user_rules.yaml index d97b70f4..24cebed6 100644 --- a/tests/override_rule_sets/example_user_rules.yml +++ b/tests/override_rule_sets/example_user_rules.yaml @@ -12,7 +12,6 @@ tiff: action: check_type expected_type: number expected_count: 2 - svs: associated_images: {} metadata: diff --git a/tests/test_e2e.py b/tests/test_e2e.py index 02ad9047..baa4c08a 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -23,7 +23,7 @@ def test_e2e_run( main.imagedephi, [ "--override-rules", - str(rules_dir / "example_user_rules.yml"), + str(rules_dir / "example_user_rules.yaml"), "run", str(data_dir / "input" / "tiff"), "--output-dir", @@ -66,7 +66,7 @@ def test_e2e_plan( main.imagedephi, [ "--override-rules", - str(rules_dir / "example_user_rules.yml"), + str(rules_dir / "example_user_rules.yaml"), "plan", str(data_dir / "input" / "tiff" / "test_image.tif"), ], diff --git a/tests/test_redact.py b/tests/test_redact.py index dc835ff7..5a89e246 100644 --- a/tests/test_redact.py +++ b/tests/test_redact.py @@ -22,7 +22,7 @@ def base_rule_set(): @pytest.fixture def override_rule_set(rules_dir: Path): - rule_file = rules_dir / "example_user_rules.yml" + rule_file = rules_dir / "example_user_rules.yaml" with rule_file.open() as rule_stream: return Ruleset.parse_obj(yaml.safe_load(rule_stream)) diff --git a/tox.ini b/tox.ini index 19522a9b..98402b87 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ minversion = 4 env_list = lint, type, - test + test, [testenv] base_python = python3.11 @@ -20,17 +20,21 @@ deps = flake8-docstrings flake8-isort pep8-naming + yamlfix commands = flake8 {posargs:.} + yamlfix -c pyproject.toml --exclude ./build/**/* --exclude ./client/node_modules/**/* . --check [testenv:format] package = skip deps = black isort + yamlfix commands = isort {posargs:.} black {posargs:.} + yamlfix -c pyproject.toml --exclude ./build/**/* --exclude ./client/node_modules/**/* . [testenv:type] # Editable ensures dependencies are installed, but full packaging isn't necessary @@ -92,3 +96,8 @@ ignore = D10, # Multiple statements on one line (https://github.com/psf/black/issues/3887) E704, + +[yamlfix] +line_length = 200 +preserve_quotes = True +sequence_style = YamlNodeStyle.BLOCK_STYLE