Skip to content

Commit 5d9fe54

Browse files
authored
Merge pull request #222 from minjk-bl/devops
Hotfix for v2.4.2
2 parents 356b68c + a8fb13b commit 5d9fe54

File tree

7 files changed

+80
-12
lines changed

7 files changed

+80
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ jupyternotebook/visualpython
66
colab/visualpython
77
test/
88
.gitignore
9+
visualpython/js/com/com_Config.js

jupyterlab/.jupyterlite.doit.db

0 Bytes
Binary file not shown.

visualpython/js/com/com_Config.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ define([
296296
* - automatically restart on jupyter kernel restart (loadVisualpython.js)
297297
*/
298298
readKernelFunction() {
299+
let that = this;
299300
// CHROME: change method to load py files ($.get -> require)
300301
return new Promise(function(resolve, reject) {
301302
var libraryList = [
@@ -314,7 +315,26 @@ define([
314315
libraryList.forEach(libCode => {
315316
promiseList.push(vpKernel.execute(libCode, true));
316317
});
317-
318+
319+
if (that.extensionType === 'lite') {
320+
let preInstallCode = '';
321+
let preInstallPackList = [
322+
'seaborn',
323+
'plotly',
324+
'scikit-learn',
325+
'scipy',
326+
'statsmodels'
327+
];
328+
preInstallPackList.forEach((packName, idx) => {
329+
preInstallCode += '%pip install ' + packName
330+
if (idx < preInstallPackList.length - 1) {
331+
preInstallCode += '\n';
332+
}
333+
});
334+
// pre-install packages
335+
promiseList.push(vpKernel.execute(preInstallCode, true));
336+
}
337+
318338
// run all promises
319339
let failed = false;
320340
Promise.all(promiseList).then(function(resultObj) {
@@ -918,7 +938,7 @@ define([
918938
'- Save VP Note before refreshing the page.'
919939
];
920940
com_interface.insertCell('markdown', info.join('\n'));
921-
com_interface.insertCell('code', "import piplite\npiplite.install('jupyterlab-visualpython==" + latestVersion + "')");
941+
com_interface.insertCell('code', "%pip install jupyterlab-visualpython==" + latestVersion);
922942
}
923943

924944
// update version_timestamp

visualpython/js/com/component/PackageManager.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ define([
6464
'PyMuPDF': { pipName: 'PyMuPDF' },
6565
'sweetviz': { pipName: 'sweetviz' },
6666
}
67+
68+
if (vpConfig.extensionType === 'lite') {
69+
this.packageLibTemplate = {
70+
'numpy': { pipName: 'numpy' },
71+
'pandas': { pipName: 'pandas' },
72+
'matplotlib': { pipName: 'matplotlib' },
73+
'seaborn': { pipName: 'seaborn' },
74+
'plotly': { pipName: 'plotly' },
75+
'sklearn': { pipName: 'scikit-learn' },
76+
'scikit-posthocs': { pipName: 'scikit-posthocs' },
77+
'scipy': { pipName: 'scipy' },
78+
'statsmodels': { pipName: 'statsmodels' },
79+
'factor-analyzer': { pipName: 'factor-analyzer' },
80+
'category_encoders': { pipName: 'category_encoders' },
81+
'imblearn': { pipName: 'imblearn' },
82+
'xgboost': { pipName: 'xgboost' },
83+
'lightgbm': { pipName: 'lightgbm' },
84+
'catboost': { pipName: 'catboost' },
85+
'auto-sklearn': { pipName: 'auto-sklearn' },
86+
'sweetviz': { pipName: 'sweetviz' },
87+
}
88+
}
6789
}
6890

6991
_bindEvent() {
@@ -148,7 +170,7 @@ define([
148170
var pipName = that.packageLib[key].pipName;
149171
var code = com_util.formatString("!pip uninstall -y {0}", pipName);
150172
if (vpConfig.extensionType === 'lite') {
151-
code = com_util.formatString("import piplite\npiplite.uninstall('{0}')", pipName);
173+
code = com_util.formatString("%pip uninstall {0}", pipName);
152174
}
153175
// create block and run it
154176
$('#vp_wrapper').trigger({
@@ -162,7 +184,7 @@ define([
162184
var pipName = that.packageLib[key].pipName;
163185
var code = com_util.formatString("!pip install --upgrade {0}", pipName);
164186
if (vpConfig.extensionType === 'lite') {
165-
code = com_util.formatString("%pip install --upgrade {0}", pipName);
187+
code = com_util.formatString("%pip install {0}", pipName);
166188
}
167189
// create block and run it
168190
$('#vp_wrapper').trigger({
@@ -269,15 +291,15 @@ define([
269291
var pipName = this.packageLib[this.state.selected].pipName;
270292
var code = com_util.formatString("!pip install {0}", pipName);
271293
if (vpConfig.extensionType === 'lite') {
272-
code = com_util.formatString("import piplite\npiplite.install('{0}')", pipName);
294+
code = com_util.formatString("%pip install {0}", pipName);
273295
}
274296
if (versionType === 'specified') {
275297
// specified version
276298
let version = $(this.wrapSelector('.vp-inner-popup-version')).val();
277299
if (version && version !== '') {
278300
code = com_util.formatString("!pip install {0}=={1}", pipName, version);
279301
if (vpConfig.extensionType === 'lite') {
280-
code = com_util.formatString("import piplite\npiplite.install('{0}=={1}')", pipName, version);
302+
code = com_util.formatString("%pip install {0}=={1}", pipName, version);
281303
}
282304
} else {
283305
$(this.wrapSelector('.vp-inner-popup-version')).focus();

visualpython/js/m_apps/PDF.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ define([
2121
'vp_base/js/com/component/FileNavigation'
2222
], function(pdfHtml, pdfCss, com_String, com_interface, PopupComponent, FileNavigation) {
2323

24-
const PDF_SHOW = '!pip show PyMuPDF nltk'
25-
const PDF_INSTALL1 = '!pip install PyMuPDF'
26-
const PDF_INSTALL2 = '!pip install nltk'
24+
var PDF_SHOW = '!pip show PyMuPDF nltk'
25+
var PDF_INSTALL1 = '!pip install PyMuPDF'
26+
var PDF_INSTALL2 = '!pip install nltk'
2727

2828
const PDF_IMPORT = `import pandas as pd
2929
import fitz
@@ -80,6 +80,12 @@ nltk.download('punkt')`;
8080
vp_pdfReturn: '',
8181
...this.state
8282
}
83+
84+
if (vpConfig.extensionType === 'lite') {
85+
PDF_SHOW = PDF_SHOW.replace('!', '%');
86+
PDF_INSTALL1 = PDF_INSTALL1.replace('!', '%');
87+
PDF_INSTALL2 = PDF_INSTALL2.replace('!', '%');
88+
}
8389
}
8490

8591
_bindEvent() {

visualpython/js/m_stats/Anova.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ define([
252252
}
253253

254254
if (tukey === true || scheffe === true || duncan === true) {
255-
codeList.push("!pip install scikit-posthocs");
255+
if (vpConfig.extensionType === 'lite') {
256+
codeList.push("%pip install scikit-posthocs");
257+
} else {
258+
codeList.push("!pip install scikit-posthocs");
259+
}
256260

257261
// Post hoc analysis - Tukey
258262
if (tukey === true) {
@@ -379,7 +383,11 @@ define([
379383
}
380384
if (tukey === true || scheffe === true || duncan === true) {
381385
// Add installation code
382-
codeList.push("!pip install scikit-posthocs");
386+
if (vpConfig.extensionType === 'lite') {
387+
codeList.push("%pip install scikit-posthocs");
388+
} else {
389+
codeList.push("!pip install scikit-posthocs");
390+
}
383391

384392
// Post hoc analysis - Tukey
385393
if (tukey === true) {
@@ -445,7 +453,11 @@ define([
445453
}
446454

447455
// Add installation code : # pip install pingouin
448-
codeList.push("!pip install pingouin");
456+
if (vpConfig.extensionType === 'lite') {
457+
codeList.push("%pip install pingouin");
458+
} else {
459+
codeList.push("!pip install pingouin");
460+
}
449461

450462
code.appendLine();
451463
code.appendLine();

visualpython/js/m_stats/FactorAnalysis.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ define([
167167
let codeList = [];
168168
let code = new com_String();
169169

170+
// Add installation code FIXME:
171+
if (vpConfig.extensionType === 'lite') {
172+
codeList.push(that.generateInstallCode().replace('!', '%'));
173+
} else {
174+
codeList.push(that.generateInstallCode());
175+
}
176+
170177
// data declaration
171178
code.appendFormat("vp_df = {0}", data);
172179
if (this.columnSelector) {

0 commit comments

Comments
 (0)