Skip to main content

Code Editor

The Code Editor is where developers write UDFs using standard Python libraries and installed dependencies. The Editor, Module, Visualize, and Settings tabs contain functionality to organize code, create HTTP endpoints, and configure the UDF.

File

Editor

The editor contains the UDF's function declaration. Whenever code is updated, Fused automatically runs the function named udf that is decorated with @fused.udf and returns the output. Other UDFs declared in the editor are ignored unless referenced by the main udf function.

Debug

The code editor highlights errors in the code and shows error logs to help debug.

Module

A Fused UDF can import Python objects from its accompanying utils Module, defined in the Module's code editor. The module's default name is utils and can be changed to avoid naming collisions. In this example, UDF imports the function arr_to_plasma from its utils Module.

@fused.udf
def udf(bbox):
from utils import arr_to_plasma
return arr_to_plasma(arr.values, min_max=(0, .8))
File

Visualize

Valid vector tables or raster objects returned by UDFs can be rendered on the map. The "Visualize" tab is where the output's visual style can be configured. See the layer styling page for more details on syntax and internals.

Settings

The Settings tab contains functionality to toggle the cache, configure metadata, and share a UDF.

Cache

When a UDF that has caching enabled is called, Fused executes the UDF and stores its output the first time it sees the code and parameters. Subsequent calls to the UDF with the same code and parameters skip execution and return the cached output.

The cache is stored by default in the user's S3 bucket, managed by Fused. Get in touch to configure something different.

File

Metadata

Default parameter values

UDFs by default run with the parameters specified in their function declaration. Predefined default parameter values take precedence and appear in the layer's dropdown in the navigation bar.

File

Default view state

Clicking the "Zoom to layer" button on the UDF layer zooms the viewport to the preconfigured view, or the extent of the output object if no default view is set.

The default view state can be set automatically to the present map view, or manually.

File

Image preview

UDFs in the UDF Catalog show a preview thumbnail. The image can be set in the "Image preview" field with a URL.

File

Tags

UDF tags can be set to help with discoverability in the UDF Catalog.

File

Description

UDFs can be documented using Markdown with a brief description of their purpose, code, and associated datasets. The description appears in the UDF profile and README.md file.

Share snippets

UDFs saved in the UDF Builder can be called with HTTP endpoints using shared and private tokens.

The "Share" section shows snippets to run the UDF from different tools without authentication, using a publicly shareable token. These include cURL calls, fused.run, Lonboard, Leaflet, Mapbox, Google Sheets, DuckDB, and the Fused App Builder.

File

Private snippets

The "Snippets" section shows snippets that can only be called by services authenticated with a private token. These include Python, cURL, and fused.load.

File

Toolbar

The toolbar at the top of the code editor includes buttons to configure, duplicate, download, and delete a UDF, as well as view its history and push it to GitHub.

GitHub

Organizations with the GitHub Integration enabled can push UDFs to a GitHub repository as a Pull Request or restore a prior version of a UDF from the commit history.

Download

Clicking "Download" saves the UDF and downloads a .zip file with the UDF code, module, and configuration.

File

Auto, Tile, and File

On UDF Builder, UDFs can explicitly be set to run as Tile or File - or autoselect between the two if the bbox object is typed.

File