# Imperial/Metric conversion: Where do you put your single source of truth?

**URL:** <https://forum.inductiveautomation.com/t/imperial-metric-conversion-where-do-you-put-your-single-source-of-truth/113313>\
**Category:** Ignition\
**Created:** [January 15, 2026, 12:49pm UTC](https://forum.inductiveautomation.com/t/imperial-metric-conversion-where-do-you-put-your-single-source-of-truth/113313 "2026-01-15T12:49:17Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![Brian\_Stilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brian_stilson/32/73410_2.png) [@Brian\_Stilson](https://forum.inductiveautomation.com/u/Brian_Stilson)\
**Post date:** [January 16, 2026, 7:12pm UTC](https://forum.inductiveautomation.com/t/imperial-metric-conversion-where-do-you-put-your-single-source-of-truth/113313/21 "2026-01-16T19:12:52Z")

</div>

I tried to do this. Declared a variable in the top level of my script module: Here’s that and my function that runs on gateway startup:

```python
import json
import system

_logger = system.util.getLogger("UnitConversion")

CONVERSIONS = {}

def load():
    """
    Runs at GATEWAY STARTUP in Linux container.
    Loads JSON and computes inverse coefficients.
    """
    global CONVERSIONS

    try:
        # Absolute path inside the container
        path = "/unitConversion.json"
        raw = system.file.readFileAsString(path)
        data = json.loads(raw)

        for src, targets in data.iteritems():
            for dst, coeffs in targets.iteritems():
                a = float(coeffs[0])
                b = float(coeffs[1])

                inv_a = 1.0 / a
                inv_b = -b

                if len(coeffs) < 4: # avoid duplicate appends
                    coeffs.append(inv_a)
                    coeffs.append(inv_b)

        CONVERSIONS = data
        _logger.info("Unit conversions loaded successfully from {}. Contents: {}".format(path, CONVERSIONS))

    except Exception as e:
        _logger.error("Failed to load unit conversions from {}: {}".format(path, e))

```

What I found was that when I try to run my conversion scripts, they’d fail because CONVERSIONS would be an empty dictionary. If I went into the script console and just did a print on that variable, it’d be populated. But running it in the designer, I set my logger to report the value of that same variable as it ran the script, and it would report back “{}” as the value.

I guess I’m not understanding how this variable is supposed to work in the library script module. Alternatively, I can just write the contents of the JSON file to a memory document tag. That’s my stop-gap to getting it to work now. Is storing it in a tag versus the library script module an alright solution? Or am I not implementing it correctly?

---

_[View the full topic](https://forum.inductiveautomation.com/t/imperial-metric-conversion-where-do-you-put-your-single-source-of-truth/113313)._
