Skip to content

Commit

Permalink
Merge branch 'master' into dev/vsairam/hue-fixes-for-computes
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanAhlen authored Oct 12, 2023
2 parents 7d859ab + 12b6e09 commit 72e8738
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion desktop/libs/notebook/src/notebook/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from django.urls import reverse

from desktop import appmanager
from desktop.conf import is_oozie_enabled, has_connectors, is_cm_managed, ENABLE_UNIFIED_ANALYTICS
from desktop.conf import is_oozie_enabled, has_connectors, is_cm_managed, ENABLE_UNIFIED_ANALYTICS, get_clusters
from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection, coerce_json_dict, coerce_bool, coerce_csv

if sys.version_info[0] > 2:
Expand Down Expand Up @@ -89,6 +89,9 @@ def displayName(dialect, name):
def get_ordered_interpreters(user=None):
global INTERPRETERS_CACHE

clusters = get_clusters(user)
has_computes = clusters and [c for c in clusters.values() if c.get('type') == 'cdw']

if has_connectors():
from desktop.lib.connectors.api import _get_installed_connectors
interpreters = [
Expand All @@ -115,6 +118,8 @@ def get_ordered_interpreters(user=None):
for interpreter in INTERPRETERS_CACHE:
if check_has_missing_permission(user, interpreter, user_apps=user_apps):
pass # Not allowed
elif has_computes and interpreter in ('hive', 'impala') and not computes_for_dialect(interpreter, user):
pass # No available computes for the dialect so skip
else:
user_interpreters.append(interpreter)

Expand Down Expand Up @@ -152,6 +157,17 @@ def get_ordered_interpreters(user=None):
for i in interpreters
]

def computes_for_dialect(dialect, user):
# import here due to avoid cyclic dependency
from beeswax.models import Namespace

ns_with_computes = []
ns_objs = Namespace.objects.filter(dialect=dialect)
if ns_objs:
ns_with_computes = [ns for ns in ns_objs if ns.get_computes(user)]

return ns_with_computes

# cf. admin wizard too

INTERPRETERS = UnspecifiedConfigSection(
Expand Down

0 comments on commit 72e8738

Please sign in to comment.