fjuniorr / flowmapper-ci

Bot for running flowmapper
0 stars 1 forks source link

Run matching rules in `simapro-flows.json` and `ElementaryExchanges-3.7.xml` #1

Closed fjuniorr closed 11 months ago

fjuniorr commented 11 months ago

I still did not run a mapping in a simapro flow list don't have and uuid and I think the current field mapping format could present challenges.

I can't leave it out. Should I do:

[fields]

uuid = ["", "@id"]

The returned object from flowmapper.format_match_result will likely have an uuid key with a value of "". This is probably not what we want.

fjuniorr commented 11 months ago

The above is fixed in https://github.com/fjuniorr/flowmapper/commit/9bd77f08759adc7e30e6a835596a0c24d0e870f0 but now there is another problem.

Because in the field mapping the context key could be a list such as ['categories.0', 'categories.1'] this can't be used as a dict key in format_match_result which means I can't generate any of the formats discussed in https://github.com/fjuniorr/flowmapper/issues/1.

Need to think about the best way forward.

fjuniorr commented 11 months ago

Something like:

["compartment.compartment.#text", "compartment.subcompartment.#text"][0].split('.')[0]

would work when all levels of the context share the same initial key. However it would not work for example in this flow schema (which is fictitious):

flow = {
        "name": "Carbon dioxide, in air",
        "categories": "emission/air",
        "subcategories": ["troposphere", "high"],
        "unit": "kg",
        "CAS": "000124-38-9",
    }
    context_mapping = ["categories", "subcategories"]
fjuniorr commented 11 months ago

The example mapping between simapro-flows.json and ElementaryExchanges-3.7.xml is in mapping.json.

This is the first example in which the simapro flowlist has the full context and no uuid.