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

[Feature] Delay/Optimize Imports #6532

Open
wants to merge 73 commits into
base: develop
Choose a base branch
from
Open

Conversation

deeleeramone
Copy link
Contributor

@deeleeramone deeleeramone commented Jun 22, 2024

  1. Why?:

    • This PR cleans up imports to not run on load, improving load and build time.
  2. What?:

    • Remove imports of whole modules, only import the items required.
    • Moves non-definition imports to within functions that prevent the import from happening until the code is run.
    • Modifies Package Builder to accept a ForwardRef in "DataProcessingSupportedTypes", and replace with the actual import. The same way it was already done, just replacing "ForwardRef('DataFrame')" with 'DataFrame'
  3. Impact:

    • Faster import times.

    • There should be no change, from a user's perspective, in operation.

    • Fundamentally changes the code style to incorporate this pattern.

  4. Testing Done:

    • Lots of files manually changed, so there is potential for error.
    • WIP

Before:

image

After:

Screenshot 2024-06-26 at 1 58 58 PM

  1. Additional Info:

    • The CI tests are being held up by, Security updates #6531, which is because finvizfinance dropped Python 3.8 support and the OpenBB lock files have not been updated in this PR to reflect our dropping of 3.8
    • Test cassettes have been recaptured. I have found one failure, historical_dividends from yFinance; this is broken both in the yFinance package and also directly on the Yahoo Finance website.

@deeleeramone deeleeramone added enhancement Enhancement do not merge Label to prevent pull request merge platform OpenBB Platform labels Jun 22, 2024
Comment on lines -39 to -44
@field_validator("asset", mode="before", check_fields=False)
@classmethod
def to_lower(cls, v: Optional[str]) -> Optional[str]:
"""Convert field to lowercase."""
return v.lower() if v else v

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this?

Copy link
Contributor Author

@deeleeramone deeleeramone Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are defined choices for this, and it's better to avoid computed fields in the standard models unless they are really necessary. Honestly, could remove the endpoint entirely as Nasdaq Data Link has seemingly stopped updating the free data sets.

Copy link
Contributor

@montezdesousa montezdesousa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@deeleeramone deeleeramone changed the base branch from develop to bugfix/security-updates June 28, 2024 15:37
@deeleeramone deeleeramone changed the base branch from bugfix/security-updates to develop June 28, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change enhancement Enhancement platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants