ExcelAddin
Represents an Excel add-in deployment on Datatailr.
An Excel add-in exposes Python functions as Excel worksheet functions, allowing users to call server-side computations directly from Excel spreadsheets.
At construction time, type annotations on @addin.expose(...) functions
in the entrypoint source file are validated. Only plain int, float,
list, bool, and str are allowed (plus Queue on a parameter
named queue for streaming functions). Invalid annotations raise
ValueError before the job definition is built.
Example
from datatailr import ExcelAddin
from datatailr.excel import Addin
addin_def = Addin("Options Pricer", "Option pricing functions")
@addin_def.expose(description="Black-Scholes price")
def price_option(spot, strike, vol, rate, expiry):
...
def __excel_main__(port=8080, ws_port=8000):
addin_def.run(port, ws_port)
addin = ExcelAddin(
name="Options Pricer",
entrypoint=__excel_main__,
python_requirements=["numpy", "scipy"],
)
addin.run()
Parameters:
-
(namestr) –Display name for the add-in.
-
(entrypointCallable) –The callable (function) that starts the add-in server. Its source file is scanned for
@*.expose(...)functions; parameter and return annotations must use onlyint,float,list,bool,str, orQueue(on a parameter namedqueue). -
(environmentEnvironment | None, default:DEV) –Target environment for the deployment.
-
(imageImage | None, default:None) –Pre-configured container Image.
-
(run_asstr | User | None, default:None) –User or username to run the add-in as.
-
(resourcesResources | None, default:None) –CPU, memory, and optional GPU memory for the container. Defaults to
Resources()(128 MB, 0.25 CPU, no GPU request). Set GPU memory withvram, using the same size strings as memory. Ifvramis omitted, the job JSON omitsvram. -
(aclACL | None, default:None) –Access control list.
-
(python_versionstr, default:'3.12') –Python version for the container image.
-
(python_requirementsstr | list[str], default:'') –Python dependencies (see
Image). -
(build_script_prestr, default:'') –Dockerfile commands to run before installing requirements.
-
(build_script_poststr, default:'') –Dockerfile commands to run after installing requirements.
-
(env_varsdict[str, str | int | float | bool] | None, default:None) –Environment variables passed to the running container.
-
(get_existingbool, default:False) –If
True, update an existing job definition. -
(versionstr | int | None, default:None) –The version of the job to get.
-
(app_sectionstr, default:'') –The section to which the app belongs. If not provided, the app will be assigned to the default section. This affects the app launcher page.
-
(budgetBudget | str | None, default:None) –Optional spend budget as
Budget("name")or a namestr. Will be set to the 'default' budget if not provided.