utkarsharma2 commented on code in PR #31854:
URL: https://github.com/apache/airflow/pull/31854#discussion_r1228848575
##########
airflow/cli/commands/variable_command.py:
##########
@@ -76,7 +77,24 @@ def variables_import(args):
def variables_export(args):
"""Exports all the variables to the file."""
- _variable_export_helper(args.file)
+ var_dict = {}
+ with create_session() as session:
+ query = session.query(Variable).all()
+
+ data = json.JSONDecoder()
+ for variable in query:
+ try:
+ value = data.decode(variable.val)
+ except json.decoder.JSONDecodeError:
+ value = variable.val
+ var_dict[variable.key] = value
+
+ with args.file as f:
+ f.write(json.dumps(var_dict, sort_keys=True, indent=4))
+ if args.file.name == "<stdout>":
Review Comment:
Also, would it make more sense to use the absence of `args.file` to indicate
that we can print data to stdout?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]