Skip to content

Expose compartment, location and unit on method factors - #216

Merged
ccomb merged 3 commits into
mainfrom
method-flow-duplicates
Jul 15, 2026
Merged

Expose compartment, location and unit on method factors#216
ccomb merged 3 commits into
mainfrom
method-flow-duplicates

Conversation

@ccomb

@ccomb ccomb commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Why

GET /method/{id}/factors returned only the flow name, direction and CF value. A characterization method routinely holds several factors for one substance name — the same substance emitted to air vs. water vs. soil, a long-term variant, or one regionalized factor per location — so consumers listing a method's factors saw rows that looked like exact duplicates, with no field to tell them apart.

Final state

Each factor now carries the axes that distinguish it:

  • compartment — the compartment path with every non-empty axis kept ("air/urban air", "water/unspecified/long-term"), null when the source method has none;
  • location — the consumer location for regionalized factors, null for universal ones;
  • unit — the CF reference unit ("kg", "kBq", "m3").

On the test method fixture, the three Carbon dioxide, fossil factors that previously rendered as duplicates now read air, air/indoor and soil.

The change is additive (no wire-version bump). The bundled Python client's MethodFactor model gains the same three optional fields and tolerates older engines that omit them; its generated API reference is regenerated.

ccomb added 3 commits July 15, 2026 06:05
GET /method/{id}/factors returned only flow name, direction and value,
so a method's several CFs for one substance - emitted to air vs. water,
or one regionalized CF per location - listed as indistinguishable
duplicate rows. Each factor now carries its compartment path, consumer
location and CF unit; the bundled Python client model follows.
The fields added to GET /method/{id}/factors can be absent from the source
data, and two paths turned that absence into an empty string on the wire.
The SimaPro method parser built a compartment even when the compartment
column was empty — which also wrongly constrained flow matching — so it now
yields no compartment at all. And a factor whose source states no unit
(openLCA JSON-LD allows omitting it) rendered as unit "", so the field is
now nullable and empty units are dropped at the API boundary.

The Python client's field docs now say each axis is None when the source
method does not carry it.
@ccomb
ccomb merged commit b333867 into main Jul 15, 2026
11 checks passed
@ccomb
ccomb deleted the method-flow-duplicates branch July 15, 2026 21:26
@ccomb ccomb mentioned this pull request Jul 15, 2026
ccomb added a commit that referenced this pull request Jul 15, 2026
## What

Dates the changelog, bumps the version. Covers two gaps found while
consolidating: `MethodFactor` gained `compartment`/`location`/`unit`
(#216) and `aggregate` gained the `consumption` scope (#224) — both
touched the pyvolca client without a changelog entry.

## Verification

Full suite (259 passed, 7 skipped — live-engine tests), pyright clean,
README API reference regenerated and drift-checked.

## After merge

Tag `pyvolca-v0.8.2` on the squashed commit — PyPI trusted publishing
fires on that tag.
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