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

Use cached_property for hook in SparkKubernetesSensor #34106

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

josh-fell
Copy link
Contributor

@josh-fell josh-fell commented Sep 5, 2023

Best practice to is make constructors of operators/sensors as simple as possible. Currently this sensor directly builds a KubernetesHook object in its construction. Yes, there are db or external calls when building the hook object itself, but:

  1. if this hook changes for any reason, these types calls might sneak in; and
  2. doesn't allow for templating of kubernetes_conn_id as brought up in Airflow Slack

Best practice to is make constructors of operators/sensors as simple as possible. Currently this sensor directly builds a KubernetesHook object in its construction. Yes, there are db or external calls when building the hook object itself, but:
1. if this hook changes for any reason, these types calls might sneak in
2. doesn't allow for templating of `kubernetes_conn_id` as brought up in [Airflow Slack](https://apache-airflow.slack.com/archives/CCQ7EGB1P/p1693904864661079)
@josh-fell josh-fell force-pushed the sparkkubernetes-sensor branch from 4cf264e to b50c4cf Compare September 5, 2023 14:35
@@ -552,13 +552,6 @@
class TestSparkKubernetesSensor:
def setup_method(self):
db.merge_conn(Connection(conn_id="kubernetes_default", conn_type="kubernetes", extra=json.dumps({})))
db.merge_conn(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Completely duplicated line so I removed it.

hussein-awala
hussein-awala approved these changes Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:cncf-kubernetes Kubernetes provider related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants