-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] POC: openbb-store
OBBject Extension For Data/Python Object Interchange
#6509
base: develop
Are you sure you want to change the base?
Conversation
Hey First of all this might be the best feature PR description in the history of this repo. Thank you for that. After reading this description I would like to clarify a few things:
|
It can come from memory or file. Only files that have been exported can be loaded back in. When an OBBject is stored, the entire class is pickled, it is restored by validating against the original signature and then
A major differentiation between aggregating The ability to 'bundle' various objects together as a single export, and maintain the state of an OBBject - with chart and methods etc - is another difference. LLMs could be fed context through curated stores, which can support function calling. It is not an equivalent to saving the results into an excel workbook, but with Python in Excel, you could unpack the compressed store and access all the original Python objects. Additionally, schemas for non-OBBject objects will be generated, with a map of {field:type} and dimensions. The essence is to be a gateway between deployed applications and the Platform. |
Can you show a command sequence starting with launching python to loading a store I understood your rationale for 2. In a nutshell it's storing binary data vs text |
Yes, in the screenshot below, I have 2 environments. One is my regular OpenBB dev environment, the other is a brand new one with only On the left, I have assembled the three financial statements as a single archive, and then exported it to my OpenBBUserData folder. On the right, I have loaded the file using the Store class directly - which also makes it operate as a local variable instead of global - and then unpacked the balance sheet item and applied the from openbb import obb
balance_data = obb.equity.fundamental.balance("NVDA", provider="fmp", period="quarter")
# Assign it to make less keystrokes.
store = balance_data.store
store.add_store(data=balance_data, name="balance", description="NVDA Quarterly Balance Sheet Statements")
cash_data = obb.equity.fundamental.cash("NVDA", provider="fmp", period="quarter")
store.add_store(data=cash_data, name="cash", description="NVDA Quarterly Cash Flow Statements")
income_data = obb.equity.fundamental.income("NVDA", provider="fmp", period="quarter")
store.add_store(data=income_data, name="income", description="NVDA Quarterly Income Statements")
store.save_store_to_file("nvda_financials") Then on the importing side: from openbb_store.store import Store
store = Store()
# Use the full path to the file in standalone mode.
store.load_store_from_file("/Users/danglewood/NewOpenBBUserData/stores/nvda_financials")
balance_data = store.get_store("balance", element='OBBject') |
This is very helpful, thank you. Please consider allowing creation of a store without the need to pre-initialize an empty instance. Like using either |
…minal into feature/openbb-store
…minal into feature/openbb-store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this should live under the Platform repo (vs another repo like openbb-forecast
vs personal repo); but if we agree it's the right place, everything here looks good to me.
I think that this PR should be under its separate repo and as its package. CC: @piiq |
I have a couple more design considerations before I'd call it "ready". I can move it to another repo when I cross that milestone, will leave open for reference in the meantime. |
…to feature/openbb-store
…to feature/openbb-store
This is a WIP and POC, feedback is welcome.
The goal is to facilitate data and Python object interchange, particularly over networks, within the OpenBB Platform ecosystem.
Example Use-Case:
Simple Use-Case:
Below is pasted from the README.md file.
OBBject Store Extension
openbb-store
is an OBBject extension for storing and retrieving OBBjects, Data, DataFrames, dictionaries, lists, and strings.Each entry is stored as a compressed pickle, with SHA1 signature, using the LZMA module with the "xz" algorithm set to maximum compression.
Installation
Install this extension by navigating into the directory and entering:
pip install -e .
Then, rebuild the Python interface:
python -c "import openbb;openbb.build()"
Store Class
Within the OpenBB Platform, the extension acts as a Global class with methods to add, retrieve, and save groups of data objects to memory or file in a transportable and compressed format.
When used as standalone, the
user_data_directory
property (preference) should be set to the desired read/write directoryupon initialization. Alternatively, specify the complete path to the file when using the IO methods'
filename
parameter.Usage
Every output from the OpenBB Platform Python interface will have the
store
attribute.Supported Data Types
The following is a list of supported data objects:
The contents of any object being added must be serializable.
Add Data
A confirmation will display unless the "verbose" property is set to
False
."Data store 'nvda2023' added successfully."
Additonal data can be added to the collection, and then exported as a single package.
"Data store 'nvdaMetrics' added successfully."
Directory Of Objects
An inventory of stored objects is displayed with the 'directory' property.
Schemas
Metadata related to the schema are stored independent of the actual data store.
Schemas are retrieved with the
get_schema
method, using the assigned 'name' as the key.Example DataFrame schema:
Example Pydantic model schema:
Restore Data
Restore data from the Store extension by using the
get_store
method. The archive is validated against a signature before opening.When the stored object is an instance of
OBBject
, the element to retrieve can be isolated with theelement
parameter.By default, it is "dataframe". When set as "OBBject", the object is restored in its original form.
Exporting/Importing
Any item(s) loaded into the extension can be exported to file as a ".xz" archive.
A list of "names" isolates specific objects for writing to disk. Without supplying names,
all entries are exported.
Importing works the same way, and a list of "names" can also be included to load only the desired elements.
The default path can be overridden by including the complete path, beginning with "/", in the filename.
Do not include the file extension with the name.