Skip to content
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

[BUG]: Clarify the provider object name #8

Closed
jjfantini opened this issue Feb 15, 2024 · 5 comments
Closed

[BUG]: Clarify the provider object name #8

jjfantini opened this issue Feb 15, 2024 · 5 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@jjfantini
Copy link

jjfantini commented Feb 15, 2024

I am building an openbb extension with the openbb-cookiecutter template.

When I run:

> from openbb_orats import obb

I get the error:

module 'openbb_orats.provider' has no attribute 'provider'

The CONTRIBUTING GUIDELINES explain that I should put the provider in the __init__.py file, but the cookiecutter template adds a whole modules for this.

Should I put the provider in the __init__.py file or should I keep the provider module?

EXTRA INFO:

[tool.poetry.plugins."openbb_provider_extension"]
openbb_orats = "openbb_orats.provider:orats_provider"
#provider.py module

orats_provider = Provider()

When I run:

> from openbb_orats.provider import orats_provider

This executes without issue. Any help would be appreciated!

@jjfantini jjfantini changed the title [HELP]: OpenBB Extension Not Building Properly [BUG]: Clarify the provider object name Feb 15, 2024
@jjfantini
Copy link
Author

I changed the provider name^^ in the provider module to reference the name of the provider, like provider modules have done in the openbb_platform module.

i.e
For Nasdaq:

nasdaq_provider = Provider()

You should think about clarifying that you don't need to change the provider object and it can just be:

provider = Provider()

@IgorWounds
Copy link
Contributor

Hi,

Thanks for raising this. I'd suggest following the cookiecutter template and examples as is. The cookiecutter, although it leverages the openbb-core, isn't an 1:1 mapping to the OpenBB Platform. In the case of the cookiecutter we want to keep it lean and to avoid issues the provider gained its own module.

To answer your question, keep it in the provider module.

As for the second part, you can name your variables in any way you prefer. The most important thing is that the entry point is correctly declared in the toml.

@jjfantini
Copy link
Author

Thanks for the quick response :). I will keep it in the cookie-cutter template form.

To get back to the initial issue at hand:

I have fixed the error by leaving the object's variable name as provider. Even if I correctly reference the entry point in the pyproject.toml file, I still get the error. I think the __init__.py file that builds the extension app is not correctly looking for provider, it seems to only look for provider variable name.

Wouldn't

[tool.poetry.plugins."openbb_provider_extension"]
openbb_orats = "openbb_orats.provider:orats_provider"

be the correct entry point to the provider module and the object variable

orats_provider = Provider()

,as stated above?

@IgorWounds
Copy link
Contributor

IgorWounds commented Feb 15, 2024

That should be the case and should work. Make sure to pip install again so it picks up the changes in the pyproject.toml. You are likely facing an environment issue.

@IgorWounds
Copy link
Contributor

@jjfantini heads up that I pushed a uvicorn fix that slightly changes the import statement. Now it is from my_ext.openbb import obb

@IgorWounds IgorWounds self-assigned this Feb 16, 2024
@IgorWounds IgorWounds added the invalid This doesn't seem right label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants