Skip to content

Hotfix for v2.4.2 #222

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

Merged
merged 6 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ jupyternotebook/visualpython
colab/visualpython
test/
.gitignore
visualpython/js/com/com_Config.js
Binary file modified jupyterlab/.jupyterlite.doit.db
Binary file not shown.
24 changes: 22 additions & 2 deletions visualpython/js/com/com_Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ define([
* - automatically restart on jupyter kernel restart (loadVisualpython.js)
*/
readKernelFunction() {
let that = this;
// CHROME: change method to load py files ($.get -> require)
return new Promise(function(resolve, reject) {
var libraryList = [
Expand All @@ -314,7 +315,26 @@ define([
libraryList.forEach(libCode => {
promiseList.push(vpKernel.execute(libCode, true));
});


if (that.extensionType === 'lite') {
let preInstallCode = '';
let preInstallPackList = [
'seaborn',
'plotly',
'scikit-learn',
'scipy',
'statsmodels'
];
preInstallPackList.forEach((packName, idx) => {
preInstallCode += '%pip install ' + packName
if (idx < preInstallPackList.length - 1) {
preInstallCode += '\n';
}
});
// pre-install packages
promiseList.push(vpKernel.execute(preInstallCode, true));
}

// run all promises
let failed = false;
Promise.all(promiseList).then(function(resultObj) {
Expand Down Expand Up @@ -918,7 +938,7 @@ define([
'- Save VP Note before refreshing the page.'
];
com_interface.insertCell('markdown', info.join('\n'));
com_interface.insertCell('code', "import piplite\npiplite.install('jupyterlab-visualpython==" + latestVersion + "')");
com_interface.insertCell('code', "%pip install jupyterlab-visualpython==" + latestVersion);
}

// update version_timestamp
Expand Down
30 changes: 26 additions & 4 deletions visualpython/js/com/component/PackageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ define([
'PyMuPDF': { pipName: 'PyMuPDF' },
'sweetviz': { pipName: 'sweetviz' },
}

if (vpConfig.extensionType === 'lite') {
this.packageLibTemplate = {
'numpy': { pipName: 'numpy' },
'pandas': { pipName: 'pandas' },
'matplotlib': { pipName: 'matplotlib' },
'seaborn': { pipName: 'seaborn' },
'plotly': { pipName: 'plotly' },
'sklearn': { pipName: 'scikit-learn' },
'scikit-posthocs': { pipName: 'scikit-posthocs' },
'scipy': { pipName: 'scipy' },
'statsmodels': { pipName: 'statsmodels' },
'factor-analyzer': { pipName: 'factor-analyzer' },
'category_encoders': { pipName: 'category_encoders' },
'imblearn': { pipName: 'imblearn' },
'xgboost': { pipName: 'xgboost' },
'lightgbm': { pipName: 'lightgbm' },
'catboost': { pipName: 'catboost' },
'auto-sklearn': { pipName: 'auto-sklearn' },
'sweetviz': { pipName: 'sweetviz' },
}
}
}

_bindEvent() {
Expand Down Expand Up @@ -148,7 +170,7 @@ define([
var pipName = that.packageLib[key].pipName;
var code = com_util.formatString("!pip uninstall -y {0}", pipName);
if (vpConfig.extensionType === 'lite') {
code = com_util.formatString("import piplite\npiplite.uninstall('{0}')", pipName);
code = com_util.formatString("%pip uninstall {0}", pipName);
}
// create block and run it
$('#vp_wrapper').trigger({
Expand All @@ -162,7 +184,7 @@ define([
var pipName = that.packageLib[key].pipName;
var code = com_util.formatString("!pip install --upgrade {0}", pipName);
if (vpConfig.extensionType === 'lite') {
code = com_util.formatString("%pip install --upgrade {0}", pipName);
code = com_util.formatString("%pip install {0}", pipName);
}
// create block and run it
$('#vp_wrapper').trigger({
Expand Down Expand Up @@ -269,15 +291,15 @@ define([
var pipName = this.packageLib[this.state.selected].pipName;
var code = com_util.formatString("!pip install {0}", pipName);
if (vpConfig.extensionType === 'lite') {
code = com_util.formatString("import piplite\npiplite.install('{0}')", pipName);
code = com_util.formatString("%pip install {0}", pipName);
}
if (versionType === 'specified') {
// specified version
let version = $(this.wrapSelector('.vp-inner-popup-version')).val();
if (version && version !== '') {
code = com_util.formatString("!pip install {0}=={1}", pipName, version);
if (vpConfig.extensionType === 'lite') {
code = com_util.formatString("import piplite\npiplite.install('{0}=={1}')", pipName, version);
code = com_util.formatString("%pip install {0}=={1}", pipName, version);
}
} else {
$(this.wrapSelector('.vp-inner-popup-version')).focus();
Expand Down
12 changes: 9 additions & 3 deletions visualpython/js/m_apps/PDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ define([
'vp_base/js/com/component/FileNavigation'
], function(pdfHtml, pdfCss, com_String, com_interface, PopupComponent, FileNavigation) {

const PDF_SHOW = '!pip show PyMuPDF nltk'
const PDF_INSTALL1 = '!pip install PyMuPDF'
const PDF_INSTALL2 = '!pip install nltk'
var PDF_SHOW = '!pip show PyMuPDF nltk'
var PDF_INSTALL1 = '!pip install PyMuPDF'
var PDF_INSTALL2 = '!pip install nltk'

const PDF_IMPORT = `import pandas as pd
import fitz
Expand Down Expand Up @@ -80,6 +80,12 @@ nltk.download('punkt')`;
vp_pdfReturn: '',
...this.state
}

if (vpConfig.extensionType === 'lite') {
PDF_SHOW = PDF_SHOW.replace('!', '%');
PDF_INSTALL1 = PDF_INSTALL1.replace('!', '%');
PDF_INSTALL2 = PDF_INSTALL2.replace('!', '%');
}
}

_bindEvent() {
Expand Down
18 changes: 15 additions & 3 deletions visualpython/js/m_stats/Anova.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ define([
}

if (tukey === true || scheffe === true || duncan === true) {
codeList.push("!pip install scikit-posthocs");
if (vpConfig.extensionType === 'lite') {
codeList.push("%pip install scikit-posthocs");
} else {
codeList.push("!pip install scikit-posthocs");
}

// Post hoc analysis - Tukey
if (tukey === true) {
Expand Down Expand Up @@ -379,7 +383,11 @@ define([
}
if (tukey === true || scheffe === true || duncan === true) {
// Add installation code
codeList.push("!pip install scikit-posthocs");
if (vpConfig.extensionType === 'lite') {
codeList.push("%pip install scikit-posthocs");
} else {
codeList.push("!pip install scikit-posthocs");
}

// Post hoc analysis - Tukey
if (tukey === true) {
Expand Down Expand Up @@ -445,7 +453,11 @@ define([
}

// Add installation code : # pip install pingouin
codeList.push("!pip install pingouin");
if (vpConfig.extensionType === 'lite') {
codeList.push("%pip install pingouin");
} else {
codeList.push("!pip install pingouin");
}

code.appendLine();
code.appendLine();
Expand Down
7 changes: 7 additions & 0 deletions visualpython/js/m_stats/FactorAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ define([
let codeList = [];
let code = new com_String();

// Add installation code FIXME:
if (vpConfig.extensionType === 'lite') {
codeList.push(that.generateInstallCode().replace('!', '%'));
} else {
codeList.push(that.generateInstallCode());
}

// data declaration
code.appendFormat("vp_df = {0}", data);
if (this.columnSelector) {
Expand Down