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

[BugFix] - Provider is added to every response item #6305

Merged
merged 21 commits into from
Apr 12, 2024

Conversation

montezdesousa
Copy link
Contributor

@montezdesousa montezdesousa commented Apr 11, 2024

  1. Why?

    • Before [BugFix] - Serialise response before FastAPI #6279 the symbol was dropped from multiple items responses, to fix that the response is dumped to a dict so that FastAPI validation doesn't drop symbol
    • We also needed provider field in the dumped response so that the discriminated union of outputs can be performed (provider could not be excluded from model_dump)
    • By doing this, provider is added to every response item, but we don't need/want it there
  2. What?

    • Refactor discriminated union logic: use callable discriminator instead of field based discriminator. Details https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions
    • This way we don't need the provider field to discriminated the union, so it's not even a field
    • Centralize discriminator logic inside ProviderInterface::_generate_return_annotations and remove it from SignatureInspector::inject_return_type
    • Some dark magic occurred and the symbol stop being dropped from the response now
    • Removed some methods from OBBject that were used to create docstrings. Added same functionality (refactored) in DocstringGenerator
    • Rebuild the package, it updates the docstrings with new pydocstyle changes
  3. Impact:

    • No provider field added to every response results
  4. Testing Done:

    • Confirmed balance sheet fields respect provider order

image

image

@github-actions github-actions bot added bug Fix bug platform OpenBB Platform v4 PRs for v4 labels Apr 11, 2024
@montezdesousa montezdesousa changed the title Bugfix/provider symbol [Bugfix] - Provider is added to every response item Apr 11, 2024
@montezdesousa montezdesousa changed the title [Bugfix] - Provider is added to every response item [BugFix] - Provider is added to every response item Apr 11, 2024
@montezdesousa montezdesousa changed the title [BugFix] - Provider is added to every response item [BugFix] Provider is added to every response item Apr 11, 2024
@montezdesousa montezdesousa changed the title [BugFix] Provider is added to every response item [BugFix] - Provider is added to every response item Apr 11, 2024
@montezdesousa montezdesousa marked this pull request as ready for review April 11, 2024 14:34
@IgorWounds IgorWounds added this pull request to the merge queue Apr 12, 2024
Merged via the queue into develop with commit b8d1846 Apr 12, 2024
20 checks passed
@montezdesousa montezdesousa deleted the bugfix/provider_symbol branch April 12, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fix bug platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants