Skip to content

Commit

Permalink
Airflow variables (#486)
Browse files Browse the repository at this point in the history
* Changed the way we invoke the connection uri
Changed the variable that setups the environment name

* Updated unit test
  • Loading branch information
ggsdc authored Oct 13, 2023
1 parent 17efc14 commit 7c4dc95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libs/client/cornflow_client/airflow/dag_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def connect_to_cornflow(secrets):
"""
# This secret comes from airflow configuration
print("Getting connection information from ENV VAR=CF_URI")
uri = secrets.get_conn_uri("CF_URI")
uri = secrets.get_conn_value("CF_URI")
conn = urlparse(uri)
scheme = conn.scheme
if scheme == "cornflow":
Expand Down Expand Up @@ -326,7 +326,7 @@ def callback_email(context):
notification_email = EnvironmentVariablesBackend().get_variable(
"NOTIFICATION_EMAIL"
)
environment_name = EnvironmentVariablesBackend().get_variable("ENVIRONMENT_NAME")
environment_name = os.getenv("AIRFLOW__WEBSERVER__INSTANCE_NAME", "CornflowEnv")

title = f"Airflow. {environment_name} ({environment}). DAG/task error: {context['dag'].dag_id}/{context['ti'].task_id} Failed"
body = f"""
Expand Down
4 changes: 2 additions & 2 deletions libs/client/cornflow_client/tests/unit/test_dag_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def test_env_connection_vars(self, CornFlow):
]
client_instance = CornFlow.return_value
client_instance.login.return_value = ""
for (conn_str, user_info, url) in conn_uris:
secrets.get_conn_uri.return_value = conn_str
for conn_str, user_info, url in conn_uris:
secrets.get_conn_value.return_value = conn_str
du.connect_to_cornflow(secrets)
client_instance.login.assert_called_with(
username=user_info[0], pwd=user_info[1]
Expand Down

0 comments on commit 7c4dc95

Please sign in to comment.