Skip to content
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

Update window size and fix datastack bug #14

Open
wants to merge 2 commits into
base: plugin/schisto
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/natcap/invest/ui_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions workbench/src/main/setupJupyter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions workbench/src/renderer/components/SetupTab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions workbench/src/renderer/server_requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
Loading