YAML first discovery for connection form metadata#60410
YAML first discovery for connection form metadata#60410amoghrajesh merged 24 commits intoapache:mainfrom
Conversation
|
Not quite there, but this is the direction I am heading in |
cb2041f to
dc320b6
Compare
e8326cc to
e5b4b0f
Compare
potiuk
left a comment
There was a problem hiding this comment.
This is pretty much how I imagined it to be.
|
Copied from slack: One thing that we might consider to do, maybe is to create a very simple tool that produces necessary yaml / dictionary/json configuration output based on what we discover by running "get_providers_info" of specified provider. That would be rather easy to do (reversing what we currently do when generating mock classes - we could make it a sub-command of the airflow connections command. Having such tool implemented now - we could also give it to the contributors to use it to convert all the remaining providers, they would test the tool then - and see if we missed anything, and we could give it as an easy-to-use tool for authors of 3rd-party providers and add it to the instruction on how to convert your providers - linked to deprecation warnings raised when we detect non-converted provider. |
|
Copied from Slack: +1 - we can also leverage the existing code that "mocks" the classes and just "dump" the form defintion from the ParamsDict into YAML... |
jscheffl
left a comment
There was a problem hiding this comment.
Some comments. And thanks for the UI screenshot posted as well. I assume the UI has some fixes required (not needed in this PR though) as it seems the long labels destroy the alignment between label and input box... all looks very mis-aligned.
The list also today on API server is lazy loaded - so first time you open the connection UI it will be loaded on API server. This "lazy long loading" will be optimized in future. API server start time might be improved if we do not install all providers in the API server except plugins. But this is a larger/different work |
jscheffl
left a comment
There was a problem hiding this comment.
Re-approval - overall LGTM - just a few nits.
Thanks for the clarification, very helpful. I think a better thing to say would be that it would help with the "dependency surface" over time when provider's needn't be installed on the API server. |
Yea agreed. This is a little bit of a follow up that I plan to handle on this one. |
|
CC: @potiuk would you want to take a look on this one? I know you were interested :) |
|
Thanks for your thoughtful reviews, @jscheffl @jason810496 @kaxil @potiuk @pierrejeambrun! Merging this one now. I will follow up with a couple of things:
|
|
Started to get these failures in the CI when running For example: FAILED airflow-core/tests/unit/always/test_providers_manager.py::TestWithoutCheckProviderManager::test_executors_without_check_property_should_not_called_import_string - AssertionError: assert equals failed
set() set([
(
'airflow.providers.amazon.aws.auth_manager.aws_auth_manager.AwsAuthManager',
'apache-airflow-providers-amazon',
),
(
'airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager',
'apache-airflow-providers-fab',
),
(
'airflow.providers.keycloak.auth_manager.keycloak_auth_manager.KeycloakAuthManager',
'apache-airflow-providers-keycloak',
),
])
================================================================== 1 failed, 213 passed, 1512 skipped, 1 xfailed, 5 warnings in 59.03s =================================================================== |
|
Let me take a look |
|
Besides the potential glitch ^^^ - cool! Looking forward for follow-ups! One thing that came into my mind: Do you have an idea for a version merker that once we drop support in providers for Airflow <3.2 that we can clean the legacy field definition any leave only YAML behind? Something like #protm |
Add declarative UI metadata for connection forms in provider.yaml Load conn-fields and ui-field-behaviour from provider info instead of importing hook classes.
Thanks @jscheffl you mean clean up the |
I wanted to say:
|
Add declarative UI metadata for connection forms in provider.yaml Load conn-fields and ui-field-behaviour from provider info instead of importing hook classes.
closes: #60404
Problem
Currently, connection form contains various fields which involve custom fields, dropdowns, validation which requires providers to define python methods (
get_connection_form_widgets(),get_ui_field_behaviour()) in hook classes to be rendered properly on the Airflow UI in the connection form. This approach has a few issues like this:wtforms,flask_appbuilder, andflask_babelin the API server for simple metadataGoals
provider.yamlinstead of hooksApproach
conn-fieldssection to provider.yaml inconnection-typesui-field-behaviourfor customizing standard connection fields (host, port, etc.)Why this approach was chosen
We adopted standard json schema instead of a custom validation format for several reasons:
jsonschemaPython package for validationadditionalProperties: trueallows future JSON Schema features without breaking changesStructure
Examples
Simple example
Example with enum
Example with int field with range validator
Example with boolean field
Testing
Tried to play around with couple of connections changing provider hook names and it all loaded fine, example of google cloud platform:
Backward Compatibility
get_connection_form_widgets(),get_ui_field_behaviour()) continue to workProvidersManagertries yaml first, falls back to python methods if yaml keys not foundMigration Path
ui-field-behaviourandconn-fieldsto provider.yaml for a providerWas generative AI tooling used to co-author this PR?
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.