top of page
  • Akmod

Don't Mess with hub.OPT!!!!

Updated: Sep 8, 2023


In the Plugin Oriented Programming (POP) paradigm, hub.OPT stands as an immutable configuration mapping. Once populated through `hub.pop.config.load()`, it should never be altered. The philosophy behind this immutability is to ensure universal predictability across all plugins and programs interacting with the hub.

The Immutable Nature of hub.OPT

`hub.OPT` is not just a configuration dictionary; it is a constant that fosters reliable inter-plugin and inter-program interactions. Once populated, its values are set in stone to prevent unintended behaviors and hard-to-diagnose bugs that may arise from modification.

Incorrect Approach

Here is how you should not handle hub.OPT:

# Parse config into hub.OPT
hub.pop.config.load(["my_app"], cli="my_app")

# Make a mutable copy of hub.OPT
mutable_opts = dict()
for key in hub.OPT:
    mutable_opts[key] = hub.OPT[key]

# Override hub.OPT with this mutable monstrosity
hub.OPT = mutable_opts

Engaging in this practice is a faux pas in the world of POP; it is an invitation to unforeseen issues and is strongly discouraged.

The Correct Approach

If you think you need to modify hub.OPT, you are wrong. Instead, you should initialize a variable on the hub in your __init__ function and move what you need from hub.OPT to that mutable location. Or at the very least, modify a *copy* of hub.OPT that you store safely somewhere else without tampering with the original. Here's the correct way:

def __init__(hub):
    hub.my_app.VAR = None

def cli(hub):
    hub.pop.config.load(["my_app"], cli="my_app")
    # Copy a specific value that you need from hub.OPT to a mutable location
    hub.my_app.VAR = hub.OPT.my_app.var

By employing this approach, you can manipulate hub.my_app.VAR as much as you wish, without jeopardizing the sanctity of hub.OPT. You can have the flexibility you need and do some private logic to mess with that variable without risking unforseen bugs within the distributed ecosystem accessing the same configuration on hub.OPT.


Maintaining the immutability of hub.OPT is not just a good practice; it's a cornerstone of POP's philosophical framework. It exemplifies the axiom that some components should remain constant to ensure reliable and consistent behavior across all aspects of a POP project.

Recent Posts

See All


bottom of page