Skip to content

Commit dc02b1b

Browse files
athithyaaselvamAthithyaa Selvam
and
Athithyaa Selvam
authored
[taskserver] Disable schedule tasks tab in job browser based on task_server_v2 configs (#3743)
Co-authored-by: Athithyaa Selvam <[email protected]>
1 parent 52c1bf5 commit dc02b1b

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

Diff for: desktop/core/src/desktop/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
HUE_IMAGE_VERSION,
5353
IS_MULTICLUSTER_ONLY,
5454
RAZ,
55-
TASK_SERVER_V2,
55+
TASK_SERVER,
5656
get_clusters,
5757
has_connectors,
5858
)
@@ -2200,7 +2200,7 @@ def _get_scheduler(self):
22002200
}
22012201
])
22022202

2203-
if TASK_SERVER_V2.BEAT_ENABLED.get():
2203+
if TASK_SERVER.BEAT_ENABLED.get():
22042204
interpreters.append({
22052205
'type': 'celery-beat',
22062206
'displayName': _('Scheduled Tasks'),

Diff for: desktop/libs/notebook/src/notebook/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from django.views.decorators.http import require_GET, require_POST
2727

2828
from azure.abfs.__init__ import abfspath
29-
from desktop.conf import ENABLE_CONNECTORS, TASK_SERVER_V2
29+
from desktop.conf import ENABLE_CONNECTORS
3030
from desktop.lib.django_util import JsonResponse
3131
from desktop.lib.exceptions_renderable import PopupException
3232
from desktop.lib.i18n import smart_str

Diff for: desktop/libs/notebook/src/notebook/connectors/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from beeswax.common import find_compute, is_compute
2929
from desktop.auth.backend import is_admin
30-
from desktop.conf import TASK_SERVER_V2, has_connectors
30+
from desktop.conf import TASK_SERVER, has_connectors
3131
from desktop.lib import export_csvxls
3232
from desktop.lib.exceptions_renderable import PopupException
3333
from desktop.lib.i18n import smart_unicode
@@ -425,7 +425,7 @@ def patch_snippet_for_connector(snippet, user=None):
425425
def get_api(request, snippet):
426426
from notebook.connectors.oozie_batch import OozieApi
427427

428-
if snippet.get('wasBatchExecuted') and not TASK_SERVER_V2.ENABLED.get():
428+
if snippet.get('wasBatchExecuted') and not TASK_SERVER.ENABLED.get():
429429
return OozieApi(user=request.user, request=request)
430430

431431
if snippet.get('type') == 'report':

Diff for: desktop/libs/notebook/src/notebook/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from django.db.models.functions import Trunc
3131
from django.utils.html import escape
3232

33-
from desktop.conf import TASK_SERVER_V2, has_connectors
33+
from desktop.conf import has_connectors
3434
from desktop.lib.connectors.models import _get_installed_connectors
3535
from desktop.lib.i18n import smart_unicode
3636
from desktop.lib.paths import SAFE_CHARACTERS_URI

Diff for: desktop/libs/notebook/src/notebook/tasks.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from beeswax.data_export import DataAdapter
3737
from desktop.auth.backend import rewrite_user
3838
from desktop.celery import app
39-
from desktop.conf import ENABLE_HUE_5, TASK_SERVER_V2
39+
from desktop.conf import ENABLE_HUE_5, TASK_SERVER
4040
from desktop.lib import export_csvxls, fsmanager
4141
from desktop.models import Document2
4242
from desktop.settings import CACHES_CELERY_KEY, CACHES_CELERY_QUERY_RESULT_KEY
@@ -68,7 +68,7 @@
6868
states.REJECTED: 'rejected',
6969
states.IGNORED: 'ignored'
7070
}
71-
storage_info = json.loads(TASK_SERVER_V2.RESULT_STORAGE.get())
71+
storage_info = json.loads(TASK_SERVER.RESULT_STORAGE.get())
7272
storage = get_storage_class(storage_info.get('backend'))(**storage_info.get('properties', {}))
7373

7474

@@ -130,7 +130,7 @@ def download_to_file(notebook, snippet, file_format='csv', max_rows=-1, **kwargs
130130
for chunk in response:
131131
f.write(chunk.encode('utf-8'))
132132

133-
if TASK_SERVER_V2.RESULT_CACHE.get():
133+
if TASK_SERVER.RESULT_CACHE.get():
134134
with storage.open(result_key, 'rb') as store:
135135
with codecs.getreader('utf-8')(store) as text_file:
136136
delimiter = ',' if sys.version_info[0] > 2 else ','.encode('utf-8')
@@ -234,7 +234,7 @@ def _patch_status(notebook):
234234
def execute(*args, **kwargs):
235235
notebook = args[0]
236236
snippet = args[1]
237-
kwargs['max_rows'] = TASK_SERVER_V2.FETCH_RESULT_LIMIT.get()
237+
kwargs['max_rows'] = TASK_SERVER.FETCH_RESULT_LIMIT.get()
238238
_patch_status(notebook)
239239

240240
task = download_to_file.apply_async(args=args, kwargs=kwargs, task_id=notebook['uuid'])
@@ -283,7 +283,7 @@ def get_log(notebook, snippet, startFrom=None, size=None, postdict=None, user_id
283283
elif state in states.EXCEPTION_STATES:
284284
return ''
285285

286-
if TASK_SERVER_V2.RESULT_CACHE.get():
286+
if TASK_SERVER.RESULT_CACHE.get():
287287
return ''
288288
else:
289289
if not startFrom:
@@ -395,7 +395,7 @@ def fetch_result(notebook, snippet, rows, start_over, **kwargs):
395395
def _get_data(task_id):
396396
result_key = _result_key(task_id)
397397

398-
if TASK_SERVER_V2.RESULT_CACHE.get():
398+
if TASK_SERVER.RESULT_CACHE.get():
399399
csv_reader = caches[CACHES_CELERY_QUERY_RESULT_KEY].get(result_key) # TODO check if expired
400400
if csv_reader is None:
401401
raise QueryError('Cached results %s not found.' % result_key)

0 commit comments

Comments
 (0)