question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Config value interpolation not working when set as environment variable

See original GitHub issue

Apache Airflow version: 1.10.10

Kubernetes version (if you are using kubernetes) (use kubectl version):

Environment:

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:

What happened: I set store_serialized_dags as an environment variable: export AIRFLOW__CORE__STORE_SERIALIZED_DAGS=True.

The default value of store_dag_code is %(store_serialized_dags)s, so I expect it to now also be True. However, it’s not (it’s False).

What you expected to happen: I expect store_dag_code to have the same value as store_serialized_dags.

It’s because the interpolation is applied to the value set in .cfg, but not when it’s set via an env var.

How to reproduce it:

Was able to reproduce it in a test (add this to test_configuration.py):

    def test_interpolation_from_env_var(self):
        """Test if interpolation works when the substituted value is set by an environment variable."""
        test_config = '''[test]
key1 = testme
key2 = %(key1)s
'''
        with mock.patch.dict('os.environ', AIRFLOW__TEST__KEY1="something_else"):
            test_conf = AirflowConfigParser(default_config=test_config)
            key2 = test_conf.get("test", "key2")
            self.assertEqual(key2, "something_else")

So far I haven’t been able to make any sense of airflow/configuration.py, to fix it.

Anything else we need to know:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
BasPHcommented, Jun 10, 2020

@ashb WDYT about rewriting the entire module? To me the whole module reads like hack on hack on hack. Putting some thought into it and rewriting it completely seems like the better alternative than to add another hack to get this interpolation issue to work.

The coming month I’m completely full so I’m not able to spend any time on it soon though.

1reaction
kaxilcommented, Jun 10, 2020

+1 to rewriting for 2.0. However, for 1.10.11, I think I will try to fix or add another hack for store_dag_code - let’see

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variable interpolation not working
I'm trying to interpolate an environment variable within another one as it's stated in the project configuration UI (Environment variables ...
Read more >
python - ConfigParser and String interpolation with env variable
It seems in the last version 3.5.0 , ConfigParser was not reading the env variables, so I end up providing a custom Interpolation...
Read more >
Environment Variables | Buildkite Documentation
The value can be set using the --experiment flag on the buildkite-agent start command or in your agent configuration file. Example: experiment1,experiment2.
Read more >
Installation — OmegaConf 2.0.6 documentation - Read the Docs
The interpolated variable can be the dot-path to another node in the configuration, and in that case the value will be the value...
Read more >
Interpolation syntax • Terragrunt
get_env(NAME, DEFAULT) returns the value of the environment variable named NAME or DEFAULT if that environment variable is not set. Example:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found