Skip to content

Commit

Permalink
Use "conda mode" instead of now-unsupported "compatibility mode"
Browse files Browse the repository at this point in the history
Connected to rstudio/connect#17604
  • Loading branch information
meatballhat committed Jun 24, 2020
1 parent 041e490 commit 4acd547
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
22 changes: 9 additions & 13 deletions rsconnect_jupyter/static/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1347,32 +1347,30 @@ define([
var generateNewConda = publishModal.find('#generate-new-conda');
var useExistingPip = publishModal.find('#use-existing-pip');
var useExistingConda = publishModal.find('#use-existing-conda');
var compatibilityMode = true;
var condaMode = false;
var forceGenerate = false;
if (generateNewPip && generateNewPip.is(':checked')) {
forceGenerate = true;
compatibilityMode = true;
environmentOptions = 'generate-new-pip';
}
if (generateNewConda && generateNewConda.is(':checked')) {
forceGenerate = true;
compatibilityMode = false;
condaMode = true;
environmentOptions = 'generate-new-conda';
}
if (useExistingPip && useExistingPip.is(':checked')) {
forceGenerate = false;
compatibilityMode = true;
environmentOptions = 'use-existing-pip';
}
if (useExistingConda && useExistingConda.is(':checked')) {
forceGenerate = false;
compatibilityMode = false;
condaMode = true;
environmentOptions = 'use-existing-conda';
}
if (!isCondaEnvironment) {
// TODO: This is needed to force `requirements.txt` to be generated
// TODO: until conda support is delivered
compatibilityMode = true;
condaMode = false;
}

var validTitle = txtTitle.val().length >= 3;
Expand Down Expand Up @@ -1453,7 +1451,7 @@ define([
txtTitle.val(),
appMode,
normalizedFiles,
compatibilityMode,
condaMode,
forceGenerate
)
.always(function () {
Expand Down Expand Up @@ -1838,7 +1836,7 @@ define([

open: function() {
// TODO: Use this in the conda support branch
var compatibilityMode = true;
var condaMode = false;
var forceGenerate = false;
var hasRequirementsTxt = false;
var hasEnvironmentYml = false;
Expand Down Expand Up @@ -1955,22 +1953,20 @@ define([
// The next four if blocks are made explicit for clarity.
if (generateNewPip && generateNewPip.is(':checked')) {
forceGenerate = true;
compatibilityMode = true;
}
if (generateNewConda && generateNewConda.is(':checked')) {
forceGenerate = true;
compatibilityMode = false;
condaMode = true;
}
if (useExistingPip && useExistingPip.is(':checked')) {
forceGenerate = false;
compatibilityMode = true;
}
if (useExistingConda && useExistingConda.is(':checked')) {
forceGenerate = false;
compatibilityMode = false;
condaMode = true;
}

config.inspectEnvironment(compatibilityMode, forceGenerate).then(function(environment) {
config.inspectEnvironment(condaMode, forceGenerate).then(function(environment) {
return config.writeManifest(Jupyter.notebook.get_notebook_name(), environment).then(function(response) {
var createdLinks = response.created.map(makeEditLink);
$status.empty();
Expand Down
12 changes: 6 additions & 6 deletions rsconnect_jupyter/static/rsconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ define([
return result;
},

inspectEnvironment: function (compatibilityMode, forceGenerate) {
inspectEnvironment: function (condaMode, forceGenerate) {
return this.getRunningPythonPath().then(function(pythonPath) {
try {
var flags = '';
if (compatibilityMode || forceGenerate) {
flags = '-' + (compatibilityMode ? 'c' : '') + (forceGenerate ? 'f' : '');
if (condaMode || forceGenerate) {
flags = '-' + (condaMode ? 'c' : '') + (forceGenerate ? 'f' : '');
}
var cmd = [
'!"',
Expand Down Expand Up @@ -349,11 +349,11 @@ define([
* @param notebookTitle {string} Title of the notebook to be passed as name/title
* @param appMode {'static'|'jupyter-static'} App mode to deploy. 'static' is not rendered.
* @param files {Array<String>} paths to files to deploy.
* @param compatibilityMode {boolean} whether or not to force `requirements.txt` usage even if in a conda environment
* @param condaMode {boolean} whether or not to use conda to build an `environment.yml`.
* @param forceGenerate {boolean} whether to force `requirements.txt` to be generated even if one exists.
* @returns {PromiseLike<T>|*|PromiseLike<any>|Promise<T>}
*/
publishContent: function (serverId, appId, notebookTitle, appMode, files, compatibilityMode, forceGenerate) {
publishContent: function (serverId, appId, notebookTitle, appMode, files, condaMode, forceGenerate) {
var self = this;
var notebookPath = Utils.encode_uri_components(
Jupyter.notebook.notebook_path
Expand Down Expand Up @@ -476,7 +476,7 @@ define([
}

if (appMode === 'jupyter-static') {
return this.inspectEnvironment(compatibilityMode, forceGenerate).then(deploy);
return this.inspectEnvironment(condaMode, forceGenerate).then(deploy);
} else {
return deploy(null);
}
Expand Down

0 comments on commit 4acd547

Please sign in to comment.