-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[Enhancement] Get Field Descriptions from OBBject #6117
base: develop
Are you sure you want to change the base?
Conversation
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 would do the charting fix in another PR as it is not related to this one. Just to keep that in mind moving forward.
Aside from that, an idea might be to grab the descriptions from our maps like the ProviderInterface or the like which might make it easier than dumping the model and pulling things out from it? Just an idea as we already have done the work from which you can grab what you need.
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.
Agree with @hjoaquim, Having it as a method here is not reliable because we don't impose any restriction on the shape of If we really need it, it will be safer to inject the schema into OBBject itself, like in the o = obb.equity.price.historical("AAPL")
o.results[0].model_fields
o.results[0].model_json_schema() |
The purpose of this is to get them post-request, so you only get descriptions for what is returned and is specific to that particular object. |
Yes, that's too much work and setup. None of those outputs are a clean dictionary of key:value that are ready-to-go out of the box. |
If it is a model, then it will work. If it is not a model, then there are no descriptions. The advantage of doing a If you rely on the first item in results only it will not be an accurate representation of the shape cast by |
…B-finance/OpenBBTerminal into feature/field-descriptions
This would duplicate schemas, because they already exist under the results object, and add unnecessary bloat to the OBBject by serializing a whole bunch of text. We simply need a method for retrieving the information that already exists within the object. Please keep in mind that this is specifically for the Python interface, and not for the API. API users do not get the benefits of the OBBject methods. |
True, nvm that idea. Anyway the schema is easily accessible |
if you rely on the first entry in results only, you will not get an accurate representation of the shape cast by Wading through
The point is to very quickly and reliably extract information, not the entire schema. Only the returned field's descriptions - if they exist - as a dictionary. Nothing more, nothing less. Frontend components interacting with the Python interface will find this useful. Getting that same information (what's only relevant to the actual object returned) from |
Hi @deeleeramone , I think that this might be a custom OBBject extension and that we shouldn't have it there by default as we don't really see any use-case or need from users for this. There are coverage endpoints, maps, and documentation that all facilitate this. Also, @hjoaquim has shown how to easily get what is needed. "filter_by_provider doesn't seem to work. Even then, keying through that to get relevant information is not at all simple or intuitive." -> For me, this works without issues.
At this stage, we should prioritise more what the users need and our OKRs which means adding less features and focusing more at tasks at hand. |
I'm looking for the output, but even then it does not fulfill the purpose of this method. The "coverage" endpoints are not relevant to the actual returned object. This compiled description is not relevant to the actual returned object. The purpose is to get only relevant information, not all the extra noise and things that you have to wade through and filter out.
There is definitely a use-case, "tooltips", and @hjoaquim's solution cannot be applied universally. I'm struggling to understand what the harm of cleanly extracting field descriptions is. By this same logic, there is no purpose of "to_dict()" because you could just do, "data.model_dump().get("results")" |
The purpose is to have a way to easily extract the field descriptions (and their keys) from the Python interface. This method can be used to generate tool tips and read the metadata associated with each field returned within the results.
It's a dictionary where the keys are the fields returned, and the values are descriptions from the provider data model.
Fields automatically created by the alias generator will not have a description.
obb.some.function().get_field_descriptions()