### Install and Run Pre-commit Hooks Source: https://github.com/fusedio/udfs/blob/main/CONTRIBUTING.md Commands to install the pre-commit framework and run its hooks on your UDF files before submission. This ensures code quality and consistency. ```bash pre-commit install pre-commit run --files /*Your UDF Folder*/* ``` -------------------------------- ### Python Type Hinting Example Source: https://github.com/fusedio/udfs/blob/main/CONTRIBUTING.md Demonstrates the recommended use of type hinting in Python User Defined Functions (UDFs) for improved readability and maintainability. This practice helps define expected input and output types for function parameters and return values. ```python def udf(param1: int, param2: str) -> str: # Function implementation here ``` -------------------------------- ### Install Fused Python SDK and Dependencies Source: https://github.com/fusedio/udfs/blob/main/README.md Installs the Fused Python SDK using pip and then installs additional dependencies required for running UDFs locally. This ensures the environment is set up correctly for Fused operations. ```bash python3 -m venv .venv source .venv/bin/activate pip install fused ``` ```bash !pip install fused odc-stac duckdb numba xarray-spatial planetary-computer 'odc-stac[botocore]' py3dep stackstac pynhd boto3 ``` -------------------------------- ### Run Pre-commit Hooks for UDFs Source: https://github.com/fusedio/udfs/blob/main/README.md Installs pre-commit hooks and runs them on specific files within the UDF repository. This is part of the contribution guidelines to ensure code quality and consistency. ```bash pre-commit install pre-commit run --files public/PC_Sentinel2/* ``` -------------------------------- ### Load and Run a Fused UDF in Python Source: https://github.com/fusedio/udfs/blob/main/README.md Demonstrates how to load a UDF from a remote repository URL using `fused.load` and then execute it within a Python environment using `fused.run`. The output is stored in a GeoDataFrame. ```python import fused udf = fused.load("https://github.com/fusedio/udfs/tree/main/public/DuckDB_NYC_Example") gdf = fused.run(udf=udf) gdf ``` -------------------------------- ### Define and Save a Fused UDF Source: https://github.com/fusedio/udfs/blob/main/README.md Illustrates how to define a custom UDF using the `@fused.udf` decorator, run it locally, and then save it to a local directory or a remote Fused endpoint. It also shows how to save it as a zip file. ```python import fused import pandas as pd @fused.udf def my_udf(bounds: fused.types.Tile = None): return pd.DataFrame({'Hello': ['from Fused']}) # Run locally print(fused.run(my_udf)) # Save locally my_udf.to_directory('my_udf') # or for zip file: my_udf.to_file('my_udf.zip') # Save remotely to Fused my_udf.to_fused('my_udf') ``` -------------------------------- ### Run Fused UDF as Bash Oneliner Source: https://github.com/fusedio/udfs/blob/main/README.md Shows how to execute a Fused UDF directly from the command line using `python -c`. This is a convenient way to run a UDF without a full Python script. ```bash python -c "import fused; udf = fused.load('https://github.com/fusedio/udfs/tree/main/public/DuckDB_NYC_Example'); print(fused.run(udf=udf));" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.