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

Control permissibility of driver config in extra from airflow.cfg #31754

Merged

Conversation

dstandish
Copy link
Contributor

I removed the hook param driver_in_extra i figured having it only in airflow settings was good enough but lemme know if you think we need both.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

LGTM. Though. Yeah @uranusjr was right that likely __ instead of _ is better.

@dstandish
Copy link
Contributor Author

if you guys both feel that way after the following argument then i'll change it

  • i agree that double under is better from readability perspective
  • however, i think it's much worse from user discoverability perspective and i think that's most important
  • i think as a user, when you are dealing with an invalid character, most intuitive would be that you replace it with a valid one -- not that you replace it with two valid ones.

what say you @potiuk @uranusjr

@potiuk
Copy link
Member

potiuk commented Jun 7, 2023

I think two is more consistent with the idea behind. We don't really replace the character, we account for the fact that our config has no hierarchy of configurations. So one could argue that . represents subsection, not . in the section name. In ideal world we would have:

[providers]
    [odbc]
      config = value

And then __ would make perfect sense. But we can't because we are using the old ini format that does not have it.

But it has hit people back in the past even for regular sections. That's why in https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#elasticsearch-configs the env variables are explicitly spelled exactly as they should be, This is the "discoverabilty" that we are missing currently that I mentioned in the slack thread. And since then I can't recall single issue with using __ as separator between section and config.

I think if we care for users not making mistakes we should be very precise and add examples in the docs that they will be able to copy&paste - both for config and variable. And once we do it, decision whether to use __ or _ makes little difference.

(BTW. That does recall some of the discussions we had years ago when we wanted to add google provider specific config).

@jedcunningham
Copy link
Member

jedcunningham commented Jun 7, 2023

Bad rebase here? nah, github problems.

I can see arguments for both _ and __. I think the strongest case for single is it keeps the section more clearly delimited. AIRFLOW__{section}__{config}. I lean single, but its not a strongly help opinion.

@dstandish dstandish force-pushed the odbc-hook-configure-through-config branch from d0eedf8 to 444077d Compare June 7, 2023 18:07
@dstandish
Copy link
Contributor Author

Bad rebase here?

yeah apparently some github issue

I can see arguments for both _ and __. I think the strongest case for single is it keeps the section more clearly delimited. AIRFLOW__{section}__{config}. I lean single, but its not a strongly help opinion

nice so that makes two of us -- we're a deadlock

now if we can just cajole @ephraimbuddy to our side ...

@dstandish
Copy link
Contributor Author

added a note in core howto/set-config to set env vars when dot present

@potiuk
Copy link
Member

potiuk commented Jun 7, 2023

I am actually not super strong on that one (once the example is there - it does not matter). If anyone feels strong - go for whatever option you choose.

Comment on lines 41 to 53
Note that when the section name has a dot in it, you must replace it with an underscore when setting the env var.
For example consider section ``providers.odbc``:

.. code-block:: ini

[providers.odbc]
allow_driver_in_extra = true

.. code-block:: bash

export AIRFLOW__PROVIDERS_ODBC__ALLOW_DRIVER_IN_EXTRA=true


Copy link
Contributor

Choose a reason for hiding this comment

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

i am not sure if we should have providers settings in Airflow core docs..
this may create issues if for some reason in future the provider will remove this.
This also goes against our goal of eventually extracting the provider code base out of airflow core (at least I think we want to be ready for a day where we might want to do it)

If we must do this I think it's preferred to add a note with a link to the relevant information in the provider docs (external link!) thus treating the providers doc as external resource like any other package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So... this is meant to be an example. If you like i can make it not refer to specific case. i thought about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok have a look please @eladkal

@dstandish dstandish merged commit 438ba41 into apache:main Jun 7, 2023
@dstandish dstandish deleted the odbc-hook-configure-through-config branch June 7, 2023 22:12
@eladkal eladkal added this to the Airflow 2.6.2 milestone Jun 8, 2023
@eladkal eladkal added the type:bug-fix Changelog: Bug Fixes label Jun 8, 2023
eladkal pushed a commit that referenced this pull request Jun 8, 2023
…1754)

Refines #31713, which disabled (by default) setting driver through extra.  Here we make it so that the flag to enable is located in airflow config instead of hook param.

(cherry picked from commit 438ba41)
potiuk pushed a commit that referenced this pull request Jun 9, 2023
…1754)

Refines #31713, which disabled (by default) setting driver through extra.  Here we make it so that the flag to enable is located in airflow config instead of hook param.

(cherry picked from commit 438ba41)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants