load
load(
url_or_udf: Union[str, Path],
/,
*,
cache_key: Any = None,
import_globals: bool = True,
) -> AnyBaseUdf
Loads a UDF from various sources including GitHub URLs and a Fused platform-specific identifier.
This function supports loading UDFs from a GitHub repository URL, or a Fused platform-specific identifier composed of an email and UDF name. It intelligently determines the source type based on the format of the input and retrieves the UDF accordingly.
Parameters
- url_or_udf (
Union[str, Path]) – A string representing the location of the UDF, or the raw code of the UDF. The location can be a GitHub URL starting with "https://github.com", a Fused platform-specific identifier in the format "email/udf_name", or a local file path pointing to a Python file. - cache_key (
Any) – An optional key used for caching the loaded UDF. If provided, the function will attempt to load the UDF from cache using this key before attempting to load it from the specified source. Defaults to None, indicating no caching. - import_globals (
bool) – Expose the globals defined in the UDF's context as attributes on the UDF object (default True). This requires executing the code of the UDF. To globally configure this behavior, usefused.options.never_import.
Returns
- AnyBaseUdf – An instance of the loaded UDF.
Raises
ValueError– If the URL or Fused platform-specific identifier format is incorrect or cannot be parsed.Exception– For errors related to network issues, file access permissions, or other unforeseen errors during the loading process.
Examples
Load a UDF from a GitHub URL:
udf = fused.load("https://github.com/fusedio/udfs/tree/main/public/REM_with_HyRiver/")
Load a UDF using a Fused platform-specific identifier:
udf = fused.load("username@fused.io/REM_with_HyRiver")