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

Merged
merged 97 commits into from
Jul 9, 2024
Merged

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
@deeleeramone
Copy link
Contributor Author

how much does the decrease in import time affect our execution time? If there is a trade-off, is it one we're willing to make?

It only increases time for execution when the imports have not been done yet. Differences should be negligible.

@montezdesousa montezdesousa added this pull request to the merge queue Jul 9, 2024
Merged via the queue into develop with commit 78445ce Jul 9, 2024
10 checks passed
@montezdesousa montezdesousa deleted the feature/delay-import branch July 9, 2024 16:30
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.

4 participants