natcap.invest.ui_server

A Flask app with HTTP endpoints used by the InVEST Workbench.

natcap.invest.ui_server.build_datastack_archive()

Writes a compressed archive of invest model input data.

Body (JSON string):

filepath: string - the target path to save the archive moduleName: string (e.g. natcap.invest.carbon) the python module name args: JSON string of InVEST model args keys and values

Returns:

A string.

natcap.invest.ui_server.get_invest_getspec()

Gets the MODEL_SPEC dict from an InVEST model.

Body (JSON string): “carbon” Accepts a language query parameter which should be an ISO 639-1 language code. Spec ‘about’ and ‘name’ values will be translated to the requested language if translations are available, or fall back to English otherwise.

Returns:

A JSON string.

natcap.invest.ui_server.get_invest_models()

Gets a list of available InVEST models.

Accepts a language query parameter which should be an ISO 639-1 language code. Model names will be translated to the requested language if translations are available, or fall back to English otherwise.

Returns:

A JSON string

natcap.invest.ui_server.get_invest_validate()

Gets the return value of an InVEST model’s validate function.

Body (JSON string):

model_module: string (e.g. natcap.invest.carbon) args: JSON string of InVEST model args keys and values

Accepts a language query parameter which should be an ISO 639-1 language code. Validation messages will be translated to the requested language if translations are available, or fall back to English otherwise.

Returns:

A JSON string.

natcap.invest.ui_server.get_is_ready()

Returns something simple to confirm the server is open.

natcap.invest.ui_server.get_supported_languages()

Return a mapping of supported languages to their display names.

natcap.invest.ui_server.get_vector_colnames()

Get a list of column names from a vector. This is used to fill in dropdown menu options in a couple models.

Body (JSON string):

vector_path (string): path to a vector file

Returns:

a JSON string.

natcap.invest.ui_server.log_model_exit()
natcap.invest.ui_server.log_model_start()
natcap.invest.ui_server.post_datastack_file()

Extracts InVEST model args from json, logfiles, or datastacks.

Body (JSON string): path to file

Returns:

A JSON string.

natcap.invest.ui_server.save_to_python()

Writes a python script with a call to an InVEST model execute function.

Body (JSON string):

filepath: string modelname: string (a key in natcap.invest.MODEL_METADATA) args_dict: JSON string of InVEST model args keys and values

Returns:

A string.

natcap.invest.ui_server.write_parameter_set_file()

Writes InVEST model args keys and values to a datastack JSON file.

Body (JSON string):

filepath: string moduleName: string(e.g. natcap.invest.carbon) args: JSON string of InVEST model args keys and values relativePaths: boolean

Returns:

A string.