diff --git a/src/natcap/invest/ui_server.py b/src/natcap/invest/ui_server.py index b73191c08..cf8370ac2 100644 --- a/src/natcap/invest/ui_server.py +++ b/src/natcap/invest/ui_server.py @@ -157,7 +157,8 @@ def get_args_enabled(): def post_datastack_file(): """Extracts InVEST model args from json, logfiles, or datastacks. - Body (JSON string): path to file + Body (JSON string): + filepath: string, path to file Returns: A JSON string. diff --git a/workbench/src/main/setupJupyter.js b/workbench/src/main/setupJupyter.js index 8070cb359..5398e8b79 100644 --- a/workbench/src/main/setupJupyter.js +++ b/workbench/src/main/setupJupyter.js @@ -19,8 +19,8 @@ function createWindow(parentWindow, isDevMode) { const devModeArg = isDevMode ? '--devMode' : ''; const win = new BrowserWindow({ parent: parentWindow, - width: 700, - height: 800, + width: 1200, + height: 900, frame: true, webPreferences: { minimumFontSize: 12, diff --git a/workbench/src/renderer/components/SetupTab/index.jsx b/workbench/src/renderer/components/SetupTab/index.jsx index a68149c14..b4ea10f93 100644 --- a/workbench/src/renderer/components/SetupTab/index.jsx +++ b/workbench/src/renderer/components/SetupTab/index.jsx @@ -228,11 +228,13 @@ class SetupTab extends React.Component { async saveDatastack(datastackPath) { const { pyModuleName, + modelId, } = this.props; const args = argsDictFromObject(this.state.argsValues); const payload = { filepath: datastackPath, moduleName: pyModuleName, + modelId: modelId, args: JSON.stringify(args), }; const key = window.crypto.getRandomValues(new Uint16Array(1))[0].toString(); @@ -282,7 +284,7 @@ class SetupTab extends React.Component { } async loadParametersFromFile(filepath) { - const { pyModuleName, switchTabs, t } = this.props; + const { pyModuleName, modelId, switchTabs, t } = this.props; let datastack; try { if (filepath.endsWith('gz')) { // .tar.gz, .tgz @@ -292,13 +294,16 @@ class SetupTab extends React.Component { ); if (extractLocation.filePath) { datastack = await fetchDatastackFromFile({ + modelId: modelId, filepath: filepath, extractPath: extractLocation.filePath}); } else { return; } } else { - datastack = await fetchDatastackFromFile({ filepath: filepath }); + datastack = await fetchDatastackFromFile({ + modelId: modelId, + filepath: filepath }); } } catch (error) { logger.error(error); diff --git a/workbench/src/renderer/server_requests.js b/workbench/src/renderer/server_requests.js index 61e6e3f06..fcc811abc 100644 --- a/workbench/src/renderer/server_requests.js +++ b/workbench/src/renderer/server_requests.js @@ -120,6 +120,7 @@ export async function fetchArgsEnabled(payload) { * * @param {object} payload { * model_module: string (e.g. natcap.invest.carbon) + * modelId: string (e.g. carbon) * args: JSON string of InVEST model args keys and values * } * @returns {Promise} resolves array @@ -146,11 +147,14 @@ export async function fetchValidation(payload) { /** * Load invest arguments from a datastack-compliant file. * - * @param {string} payload - path to file + * @param {object} payload { + * filepath: string, path to file + * modelId: string (e.g. carbon) + * } * @returns {Promise} resolves undefined */ export async function fetchDatastackFromFile(payload) { - const port = await getCorePort(); + const port = await getPort(payload.modelId); return ( window.fetch(`${HOSTNAME}:${port}/${PREFIX}/post_datastack_file`, { method: 'post', @@ -172,7 +176,7 @@ export async function fetchDatastackFromFile(payload) { * @returns {Promise} resolves undefined */ export async function saveToPython(payload) { - const port = await getCorePort(); + const port = await getPort(payload.modelname); return ( window.fetch(`${HOSTNAME}:${port}/${PREFIX}/save_to_python`, { method: 'post', @@ -194,12 +198,13 @@ export async function saveToPython(payload) { * @param {object} payload { * filepath: string * moduleName: string (e.g. natcap.invest.carbon) + * modelId: string (e.g. carbon) * args_dict: JSON string of InVEST model args keys and values * } * @returns {Promise} resolves undefined */ export async function archiveDatastack(payload) { - const port = await getCorePort(); + const port = await getPort(payload.modelId); return ( window.fetch(`${HOSTNAME}:${port}/${PREFIX}/build_datastack_archive`, { method: 'post',