Skip to content

Commit bf817c4

Browse files
committed
Explain Tensor is disabled by default
1 parent 63a062c commit bf817c4

8 files changed

Lines changed: 34 additions & 32 deletions

File tree

web/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@
10581058
# When False, all Explain Tensor features are disabled and cannot be enabled
10591059
# by users through preferences. When True, users can configure Explain Tensor
10601060
# settings in preferences.
1061-
EXPLAIN_TENSOR_ENABLED = True
1061+
EXPLAIN_TENSOR_ENABLED = False
10621062

10631063
#############################################################################
10641064
# Patch the default config with custom config and other manipulations

web/pgadmin/messages.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PROJECT VERSION\n"
1010
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
11-
"POT-Creation-Date: 2026-04-09 14:13+0300\n"
11+
"POT-Creation-Date: 2026-04-09 15:08+0300\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12637,7 +12637,7 @@ msgstr ""
1263712637
#: pgadmin/static/js/SchemaView/SchemaState/SchemaState.js:158
1263812638
#: pgadmin/static/js/components/ReactCodeMirror/index.jsx:234
1263912639
#: pgadmin/static/js/tree/ObjectExplorer/ObjectExplorerFilter.jsx:58
12640-
#: pgadmin/tools/expl_tensor/static/js/index.jsx:89
12640+
#: pgadmin/tools/expl_tensor/static/js/index.jsx:93
1264112641
#: pgadmin/tools/user_management/static/js/Users.jsx:261
1264212642
msgid "Loading..."
1264312643
msgstr ""

web/pgadmin/tools/expl_tensor/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def formatSQL():
149149
errormsg=str(data),
150150
info=gettext('Failed to post data to the Explain Tensor API'),
151151
data={
152-
'code': data.code,
152+
'code': getattr(data, 'code', None),
153153
'url': api_url,
154154
}
155155
)
@@ -205,7 +205,7 @@ def explain():
205205
errormsg=str(response_data),
206206
info=gettext('Failed to post data to the Explain Tensor API'),
207207
data={
208-
'code': response_data.code,
208+
'code': getattr(response_data, 'code', None),
209209
'url': api_url,
210210
}
211211
)

web/pgadmin/tools/expl_tensor/static/js/index.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default function ExplainTensor({
3636

3737
useEffect(() => {
3838
if (_.isEmpty(plans)) return;
39+
setIsLoading(true);
3940
const api = getApiInstance();
4041
const postData = {
4142
plan: JSON.stringify(plans),
@@ -48,6 +49,7 @@ export default function ExplainTensor({
4849
.then((res) => {
4950
if (res.data?.success) {
5051
setData(res.data?.data);
52+
setIsLoading(false);
5153
} else if (res.data?.data?.code == 401) {
5254
fetch(res.data?.data?.url, {
5355
method: 'POST',
@@ -66,15 +68,17 @@ export default function ExplainTensor({
6668
})
6769
.catch((err) => {
6870
setError(err?.message);
71+
})
72+
.finally(() => {
73+
setIsLoading(false);
6974
});
7075
} else {
7176
setError(`${res.data?.info} : ${res.data?.errormsg}`);
77+
setIsLoading(false);
7278
}
7379
})
7480
.catch((err) => {
7581
setError(err?.message);
76-
})
77-
.finally(() => {
7882
setIsLoading(false);
7983
});
8084
}, [plans]);

web/pgadmin/tools/expl_tensor/tests/test_format_sql.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ def runTest(self):
4545
'btf_query_text': 'SELECT\\n\\t*\\nFROM\\n\\ttest_table\\nWHERE\\n\\tid = 1;'
4646
}))
4747

48-
if self.expected_success:
49-
response = self.tester.post(
50-
self.url,
51-
data=json.dumps(self.data),
52-
content_type='application/json'
53-
)
54-
self.assertEqual(response.status_code, 200)
55-
response_data = json.loads(response.data.decode('utf-8'))
56-
self.assertTrue(response_data['success'])
57-
else:
58-
response = self.tester.post(
59-
self.url,
60-
data=self.data,
61-
content_type='application/json'
62-
)
63-
self.assertEqual(response.status_code, 200)
64-
response_data = json.loads(response.data.decode('utf-8'))
65-
self.assertFalse(response_data['success'])
48+
if self.expected_success:
49+
response = self.tester.post(
50+
self.url,
51+
data=json.dumps(self.data),
52+
content_type='application/json'
53+
)
54+
self.assertEqual(response.status_code, 200)
55+
response_data = json.loads(response.data.decode('utf-8'))
56+
self.assertTrue(response_data['success'])
57+
else:
58+
response = self.tester.post(
59+
self.url,
60+
data=self.data,
61+
content_type='application/json'
62+
)
63+
self.assertEqual(response.status_code, 200)
64+
response_data = json.loads(response.data.decode('utf-8'))
65+
self.assertFalse(response_data['success'])

web/pgadmin/tools/expl_tensor/tests/test_preferences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ def runTest(self):
5252
mock_prefs.module.return_value = mock_module
5353

5454
from pgadmin.tools.expl_tensor import get_preference_value
55-
result = get_preference_value('explain_tensor_api')
55+
result = get_preference_value('expl_tensor', 'explain_tensor_api')
5656
self.assertEqual(result, self.expected_result)
-5 Bytes
Binary file not shown.

web/pgadmin/translations/ru/LC_MESSAGES/messages.po

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: pgAdmin 4\n"
1010
"Report-Msgid-Bugs-To: degit22@gmail.com\n"
11-
"POT-Creation-Date: 2026-04-09 14:13+0300\n"
11+
"POT-Creation-Date: 2026-04-09 15:08+0300\n"
1212
"PO-Revision-Date: 2026-01-02 00:05+0700\n"
1313
"Last-Translator: Degit22 <degit22@gmail.com>\n"
1414
"Language: ru\n"
@@ -12905,7 +12905,7 @@ msgstr ""
1290512905
#: pgadmin/static/js/SchemaView/SchemaState/SchemaState.js:158
1290612906
#: pgadmin/static/js/components/ReactCodeMirror/index.jsx:234
1290712907
#: pgadmin/static/js/tree/ObjectExplorer/ObjectExplorerFilter.jsx:58
12908-
#: pgadmin/tools/expl_tensor/static/js/index.jsx:89
12908+
#: pgadmin/tools/expl_tensor/static/js/index.jsx:93
1290912909
#: pgadmin/tools/user_management/static/js/Users.jsx:261
1291012910
msgid "Loading..."
1291112911
msgstr "Загружается..."
@@ -16378,17 +16378,15 @@ msgstr "Анализ планов"
1637816378

1637916379
#: pgadmin/tools/expl_tensor/__init__.py:44
1638016380
msgid "Analyze query plan via Explain Tensor API"
16381-
msgstr "Анализ планов запроса с помощью API Explain expl_tensor"
16381+
msgstr "Анализ планов запроса с помощью API Explain Tensor"
1638216382

1638316383
#: pgadmin/tools/expl_tensor/__init__.py:49
1638416384
msgid "Explain Tensor API"
1638516385
msgstr "Адрес API Explain Tensor"
1638616386

1638716387
#: pgadmin/tools/expl_tensor/__init__.py:53
1638816388
msgid "Explain Tensor API endpoint (e.g. https://explain.tensor.ru)"
16389-
msgstr ""
16390-
"Точка доступа к API Explain Tensor (например, "
16391-
"https://explain.tensor.ru)"
16389+
msgstr "Точка доступа к API Explain Tensor (например, https://explain.tensor.ru)"
1639216390

1639316391
#: pgadmin/tools/expl_tensor/__init__.py:61
1639416392
msgid "Private Plans"

0 commit comments

Comments
 (0)