Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing airflow variables in a json file using the command line

I have file called properties.json which looks like

{
  "FOO": {
    "var1": "apple",
    "settings": {
      "more_settings": {
        "var2": "pear",
        "var3": 123
      }
    }
  },
  "BAR": "FOO"
}

and I'm trying to import into Airflow via the command line interface like so

gcloud composer environments run <composer-name> \
        --location <location> --project <project> variables -- \
        --import /path/to/properties.json

in order to get the following variables into Airflow:

FOO: { "var1": "apple", "settings": { "more_settings": { "var2": "pear", "var3": 123 } } }

BAR: FOO

However, when I run the gcloud command, I get the error Missing variables file. When I import properties.json in Airflow's UI, it is imported without issues. What am I doing wrong by using the CLI?

like image 372
PBartlett Avatar asked Sep 23 '19 19:09

PBartlett


2 Answers

I have done this:

airflow variables import properties.json

According to: https://airflow.apache.org/docs/apache-airflow/stable/cli-and-env-variables-ref.html#import_repeat2

like image 57
luisvenezian Avatar answered Oct 22 '22 12:10

luisvenezian


For older versions 1.10.x of Airflow, using CLI, the syntax is:

airflow variables -i <file.json>
like image 20
Alex W Avatar answered Oct 22 '22 11:10

Alex W