You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider this setup where I have some data sources (here just one: the pricing_url)
as well as some "stores" (mapping interfaces to various storage systems -- here just local folders)
and "keys" that tell me where a particular data can be found in some "store".
Then I have some code that looks like something like this kind of "if you have it,
load it and give it to the user,
and if you don't, get it (or make it, or compute it), store it, and give it to the user"
below:
fromoa._resourcesimportget_pricing_page_html# get html ifopenai_api_pricing_html_keynotintext_store:
print(f"Saving the pricing page HTML to {openai_api_pricing_html_key}...")
html=get_pricing_page_html()
text_store[openai_api_pricing_html_key] =htmlelse:
print(f"Loading the pricing page HTML from {openai_api_pricing_html_key}...")
html=text_store[openai_api_pricing_html_key]
# get infoifopenai_api_pricing_info_keynotinjson_store:
print(f"Extracting pricing data from the HTML and saving it to {openai_api_pricing_info_key}...")
pricing_data=extract_pricing_data(html)
json_store[openai_api_pricing_info_key] =pricing_dataelse:
print(f"Loading the pricing data from {openai_api_pricing_info_key}...")
pricing_data=json_store[openai_api_pricing_info_key]
I want to refactor this to having "cached" properties of some class that will give
a user access to these datas (as well as the computations that led to them via a chain
of computation originating from one or several sources).
The cache_this is a decorator that transforms a method into a cached property with
control over cache object and key. It's like functools.cached_properties, but
instead of storing things in RAM (in a dict), it uses a specific cache (here, json_store, and text_store)
and a specifiable key to store (and/or find) the required data.
Please read, and understand, how cache_this works, looking in your knowledge (i2mint/dol/tools.py).
The user will be giving you some code (could be modules, notebooks, markdown files containing code), and
you should figure out what the data relationships are -- that is, understand the computation flow;
how each variable gets it's value, via the values of other variables, and through which function calls, etc.
From this understanding, then, you should make a Dacc class that takes, as parameters,
any original data sources specifications and any other arguments that might parametrize the computation flow,
and that has cache_this-decorated methods to provide the "variables" that we had in the original code.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
To collect ideas and prompts for AI-enhanced assistance with
doltools.Beta Was this translation helpful? Give feedback.
All reactions