Skip to content

98 allow for processing of all available variables - #105

Merged
maxnutz merged 3 commits into
mainfrom
98-allow-for-processing-of-all-available-variables
Aug 27, 2026
Merged

98 allow for processing of all available variables#105
maxnutz merged 3 commits into
mainfrom
98-allow-for-processing-of-all-available-variables

Conversation

@maxnutz

@maxnutz maxnutz commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Short description of this pull request

Allow False as value for definitions_path to call all evaluations for all available variables in the respective mapping-value (mapping.default.yaml as default)


Checklist

Before asking for review, please make shure, the following steps are completed (whenever possible):

  • Changes are tested locally and behave as expected.
  • Code is documented using numpy-styled function docstrings
  • All tests succeed
  • All Sourcery-bot review suggestions have been implemented or rejected with an explanation.

Sourcery-Bot starts to review your pull request, whenever it is created. This may take some time. After having finished these steps, please request for review in the Pull Request.

Summary by Sourcery

Allow processing all mapping-defined variables without requiring a definitions directory or performing unit conversion.

New Features:

  • Support disabling variable definitions with definitions_path: False to evaluate every variable in the mapping file without unit conversion.

Bug Fixes:

  • Reject unset or empty definitions paths with a clear configuration error while preserving support for explicit definition disabling.

Enhancements:

  • Skip definition loading and unit-conversion setup when definitions are disabled.

Documentation:

  • Document the definitions_path: False configuration option and its evaluation behavior.

Tests:

  • Add coverage for boolean and string forms of disabled definitions, unit-conversion behavior, and mapping-variable evaluation.

@maxnutz maxnutz linked an issue Aug 27, 2026 that may be closed by this pull request
3 tasks
@sourcery-ai

sourcery-ai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces an opt-out configuration for definitions_path that lets processing evaluate all variables in the mapping file while bypassing definition loading and unit conversion, with updated documentation and tests covering configuration, initialization, workflow, and iteration behavior.

Flow diagram for definitions-disabled variable processing

flowchart TD
    A["Read definitions_path"] --> B{"definitions_path is False?"}
    B -->|No| C["Load definitions and optional unit conversion"]
    B -->|Yes| D["Skip definitions and unit conversion"]
    C --> E["Iterate over dsd variables"]
    D --> F["Iterate over mapping variables"]
    E --> G["_execute_function_for_variable"]
    F --> G
    G --> H["calculate_variables_values"]
Loading

File-Level Changes

Change Details Files
Add a definitions-disabled mode that evaluates every variable declared in the mapping file without loading definitions or converting units.
  • Accept YAML false and case-insensitive string forms of false for definitions_path.
  • Track definitions availability and conditionally initialize definition data structures.
  • Iterate mapping keys instead of definition variables when definitions are disabled.
  • Prevent workflow-level definition loading in disabled mode.
pypsa_validation_processing/class_definitions.py
pypsa_validation_processing/workflow.py
Document the new configuration behavior and its implications for unit conversion.
  • Explain that setting definitions_path to False evaluates all mapping-file variables and skips unit conversion.
  • Clarify validation errors for missing or empty definitions_path values.
README.md
pypsa_validation_processing/class_definitions.py
Add coverage for disabled definitions, conditional unit conversion, and mapping-variable iteration.
  • Test boolean and string false configuration values.
  • Test empty-path validation and definition object initialization behavior.
  • Verify convert_units behavior and execution of all mapping variables without definitions.
tests/test_network_processor.py
tests/test_unit_conversion.py

Assessment against linked issues

Issue Objective Addressed Explanation
#98 Preserve the existing behavior when definitions_path is set to a valid definitions directory, including definition-based variable selection and optional unit conversion.
#98 Support definitions_path set to False, causing all variables from the configured mapping file to be evaluated with the existing output processing while leaving evaluated units unchanged.
#98 Raise a comprehensive error when definitions_path is missing or empty.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the mapping-file iteration or skipped unit conversion is wrong, the processor can write incorrect variable values to the output workbook. Reverting does not remove an already generated workbook, but the bounded output can be regenerated correctly by rerunning the workflow.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@maxnutz
maxnutz merged commit 2b575a9 into main Aug 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for processing of all available variables

1 participant