Repository navigation
Conversation
…atures The package builder only read `field.default` when it flattened a QueryParams model into the arguments of a generated `obb` method, so a field declared with `default_factory` became a required argument. `obb.technical.realized_volatility_compare(data=...)` and `obb.quantitative.attribution/factors/risk_decomposition(...)` failed with "Missing required argument" for `models` / `periods`, although the REST API and the docstrings treat them as optional. Resolve the default the same way the flattening branch for other QueryParams annotations already did, and use that helper in all three places.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request the OpenBB Platform
Description
Four commands fail from the Python interface when called the way their examples and docstrings show:
quantitative.factorsandquantitative.risk_decompositionfail the same way onperiods. The same calls work through the REST API (POST /api/v1/technical/realized_volatility_comparewith onlydatareturns 200).These four are the only command parameters in the repository declared with
default_factoryinstead ofdefault. When the package builder flattens aQueryParamsmodel into the arguments of the generated method, it only readsfield.default, which isPydanticUndefinedfor adefault_factoryfield, so the argument is generated without a default. The flattening branch for otherQueryParamsannotations (the "Case 3" block informat_params) already handlesdefault_factory; the plainQueryParamsbranch and the GET-model branch in_format_annotated_paramdon't.This moves that logic into
MethodDefinition.get_model_field_defaultand uses it in all three places. The generated signature now readsmodels: ... = ['std', 'parkinson', 'garman_klass', 'hodges_tompkins', 'rogers_satchell', 'yang_zhang'], andreference.jsonlistsperiodsas optional with its default instead of"optional": false, "default": null.Because
periodsis no longer required, it now comes after the other required arguments in the generatedattribution,factorsandrisk_decompositionsignatures.How has this been tested?
test_method_definition_helpers.py(a plainQueryParamsmodel and a GET pydantic model, each with adefault_factoryfield). Both fail ondevelop(assert <class 'inspect._empty'> == ['std', 'parkinson']) and pass with the change.extensions/technical/integration/test_technical_python.py::test_realized_volatility_compare(it calls the command withoutmodels) fails ondevelopwith the error above for both the daily and intraday fixture, and passes on this branch. The whole file: 136 passed.quantitative/integration/test_quantitative_python.py: 18 passed;test_quantitative_capmfails becausemba.tuck.dartmouth.eduanswered 404 for every page when I ran it, which this change doesn't touch.openbb.build()ondevelopand on this branch and ran the four calls above: all four raise "Missing required argument" ondevelopand return results on this branch (770 / 24 / 18 / 18 rows on generated sample data).openbb_platform/core/tests/app: 1293 passed, 49 skipped.test_credentials_helpers.py::test_load_picks_up_env_credentialsfails in a full local run on bothdevelopand this branch and passes when run alone.ruff format --checkandruff checkpass for the changed files;ty checkreports the same diagnostics as ondevelop.Checklist
feature/feature-nameorhotfix/hotfix-name.