sudoblockio / tackle

Tackle is a programmable configuration language for building modular utilities, code generators, and CLIs with schema validation baked in.
Apache License 2.0
51 stars 2 forks source link

Create context manager for new context creation logic #265

Open robcxyz opened 7 months ago

robcxyz commented 7 months ago

Right now we simply create new contexts, use them, and then return the public data. While this works when the models that being populated are contained within a single map, data pollution happens when the references from a particular context become impossible to manage. Instead it would be better to use a context manager for our contexts so that when it is being used, it is clear which data structures are active (ie if we move to a list of maps for data / hooks per #266, then the logic to add and remove items from these lists can be encapsulated within the context manager).

Would be something like:

with new_context_from_context(context) as new_context:
  do_something(new_context)

Where new_context_from_context would contain the logic to create the new context / add the required data / hooks items, yield, then pop off those items when done and returning the public data.

Getting this context manager done should be the first step before moving completely over to this new data structure