spotfiresoftware / spotfire-python

Package for Building Python Extensions to Spotfire®
Other
18 stars 6 forks source link

Expose information about inputs to data function script #64

Closed bbassett-tibco closed 4 months ago

bbassett-tibco commented 7 months ago

Please expose information about the inputs (names and table/column/value) of a data function to the script at runtime. It is not reliable to pick through the globals passed to the data function's script at runtime (since all of Python's globals are mixed in).

Note: This is a request to me via internal chat from a non-engineering Spotfire staffer.

bbassett-tibco commented 4 months ago

Data functions now have information about their inputs exposed to the data function in their global namespace as __spotfire_inputs__ (which is typed as collections.abc.Sequence[spotfire.data_function.AnalyticInput]). Outputs are also exposed in the global namespace as __spotfire_outputs__ (typed as a Sequence of AnalyticOutput objects),

Unless you can guarantee that data functions using this functionality are limited to versions of Spotfire with this version of the spotfire package, I recommend using a try/except NameError block to handle running on earlier versions where the dunder-names are not available.