Skip to content

feat: add TimexLCASettings and TimexLCA.run() for streamlined full-pipeline execution - #221

Closed
TimoDiepers wants to merge 2 commits into
mainfrom
feat/timex-run-settings
Closed

feat: add TimexLCASettings and TimexLCA.run() for streamlined full-pipeline execution#221
TimoDiepers wants to merge 2 commits into
mainfrom
feat/timex-run-settings

Conversation

@TimoDiepers

Copy link
Copy Markdown
Member

Summary

Adds TimexLCASettings configuration dataclass and TimexLCA.run() method to streamline full-pipeline execution of time-explicit LCA calculations.

The settings class encapsulates all configuration options for timeline building, LCI calculation, and LCIA (both static and dynamic), enabling cleaner, more maintainable code for complex analyses.

Test plan

  • 6 new tests covering various configurations:
    • Settings creation with defaults and custom values
    • Static-only run
    • Full pipeline with all steps
    • LCI without technosphere expansion
    • Expanded technosphere with datapackage
  • All existing tests continue to pass

Changes

New Classes

  • TimexLCASettings: Dataclass containing all pipeline configuration parameters
    • Core: demand, method, database_dates, use_global_lci_cache
    • Timeline: starting_datetime, temporal_grouping, interpolation_type, edge_filter_function, cutoff, max_calc, graph_traversal, traverse_background
    • LCI: build_dynamic_biosphere, expand_technosphere, keep_activity_dimension
    • LCIA: static_lcia_enabled, dynamic_lcia_enabled, metric, time_horizon, fixed_time_horizon, time_horizon_start, characterization_functions, characterization_function_co2, use_disaggregated_lci

New Methods

  • TimexLCA.run(settings): Executes full pipeline in sequence

    1. build_timeline()
    2. lci()
    3. static_lcia() (if enabled)
    4. dynamic_lcia() (if enabled)

    Returns self for method chaining and includes detailed logging of each step.

Exports

  • TimexLCASettings is exported from bw_timex.__init__ for convenient access

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jog2Qz6f56dUM437aK7xUq

…peline execution

Adds TimexLCASettings dataclass to encapsulate all configuration options for a complete TimexLCA calculation:
- Core parameters: demand, method, database_dates, use_global_lci_cache
- Timeline parameters: starting_datetime, temporal_grouping, interpolation_type, edge_filter_function, cutoff, max_calc, graph_traversal, traverse_background
- LCI parameters: build_dynamic_biosphere, expand_technosphere, keep_activity_dimension
- LCIA parameters: static_lcia_enabled, dynamic_lcia_enabled, metric, time_horizon, fixed_time_horizon, time_horizon_start, characterization_functions, characterization_function_co2, use_disaggregated_lci

Adds TimexLCA.run(settings) method that executes the full pipeline:
1. build_timeline() with all specified parameters
2. lci() with specified LCI options
3. static_lcia() (if enabled)
4. dynamic_lcia() (if enabled) with all dynamic characterization options

Enables method chaining for convenience. Includes comprehensive test coverage for various configurations and parameter combinations.
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.12346% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.87%. Comparing base (f67e3ef) to head (3755854).

Files with missing lines Patch % Lines
bw_timex/timex_lca.py 90.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #221      +/-   ##
==========================================
+ Coverage   78.51%   78.87%   +0.35%     
==========================================
  Files          10       10              
  Lines        2472     2552      +80     
==========================================
+ Hits         1941     2013      +72     
- Misses        531      539       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…rent settings

Adds _reset_run_state() method that clears timeline, LCI, and LCIA results between runs while preserving the expensive base_lca calculation. This enables efficient parameter sweeps and sensitivity analyses by:
- Reusing base LCA across multiple runs (no recalculation overhead)
- Clearing instance state for fresh timeline/LCI/LCIA calculations
- Supporting different settings (temporal_grouping, starting_datetime, LCIA metrics) per run

Includes 3 new tests:
- test_run_multiple_times_with_different_settings: verifies different results for different datetime parameters
- test_run_multiple_times_reuses_base_lca: confirms base_lca object identity preserved
- All existing tests continue to pass
@TimoDiepers

Copy link
Copy Markdown
Member Author

Superseded by #223, which reworks this into a settings object that no longer duplicates the constructor arguments, and adds TimexLCA.compare() for scenario comparison. That branch is cut from #219, since scenario selection is central to the comparison API.

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.

1 participant