Script Development / Built-in Variables
To facilitate scripts in obtaining information about their runtime status, DataFlux Func directly embeds some variables in the script context that can be used directly.
| Built-in Variable | Type | Applicable Scope | Description | Example Value |
|---|---|---|---|---|
_DFF_IMAGE_INFO |
dict | All | Current image information | See below |
_DFF_TRACE_ID |
str | All | Trace ID Internal Trace within Func |
"TRACE-14E6D8D6-1F1A-4A5A-8280-854F6DD8CDB0" |
_DFF_TASK_ID |
str | All | Task ID | "task-2UHeFYPdb6Q7" |
_DFF_ROOT_TASK_ID |
str | All | Main Task ID For the main task itself, fixed as "ROOT |
"task-2UHeFYPdb6Q7" |
_DFF_SCRIPT_SET_ID |
str | All | Script Set ID | "demo" |
_DFF_SCRIPT_SET_NAME |
str | All | Script Set Name Same as _DFF_SCRIPT_SET_ID |
"demo" |
_DFF_SCRIPT_SET_TITLE |
str | All | Script Set Title | "Example" |
_DFF_SCRIPT_ID |
str | All | Script ID | "demo__basic" |
_DFF_SCRIPT_NAME |
str | All | Script Name The part without the Script Set ID |
"basic" |
_DFF_SCRIPT_TITLE |
str | All | Script Title | "Basics" |
_DFF_FUNC_ID |
str | All | Function ID | "demo__basic.hello_world" |
_DFF_FUNC_NAME |
str | All | Function Name The part without the Script ID |
"hello_world" |
_DFF_FUNC_TITLE |
str | All | Function Title | "My Function" |
_DFF_FUNC_CHAIN |
list | All | Function Call Chain | [ "demo__basic.run", "demo__basic.hello_world" ] |
_DFF_FUNC_CALL_KWARGS |
dict | All | Function Call Arguments | {"x": 1, "y": 2} |
_DFF_ORIGIN |
str | All | Task Source | "funcAPI" |
_DFF_ORIGIN_ID |
str | All | Source ID | "fapi-tDGC12Gdc5H6" |
_DFF_TRIGGER_TIME |
int | All | Scheduled Start Time (seconds) | 1625651909 |
_DFF_TRIGGER_TIME_MS |
int | All | Scheduled Start Time (milliseconds) | 1625651909582 |
_DFF_START_TIME |
int | All | Actual Start Time (seconds) | 1625651910 |
_DFF_START_TIME_MS |
int | All | Actual Start Time (milliseconds) | 1625651910630 |
_DFF_QUEUE |
int | All | Execution Queue | 2 |
_DFF_CRON_EXPR |
str | Scheduled Tasks | Crontab Expression | * * * * * |
_DFF_HTTP_REQUEST |
dict | Function API Function Page |
Request body when the interface is called | See below |
Difference Between _DFF_TRIGGER_TIME and _DFF_START_TIME
_DFF_START_TIME refers to the actual start time of the function, equivalent to int(time.time()) executed at the function entry point, which may be delayed due to factors like queue congestion.
_DFF_TRIGGER_TIME, on the other hand, refers to the function trigger time, which does not change due to queue congestion and can be considered as the "scheduled start time". Its value is determined as follows:
| Function Call Method | Value |
|---|---|
| UI Execution | The time when the backend API service receives the HTTP request |
| Function API | The time when the backend API service receives the HTTP request |
| Scheduled Tasks | The exact time corresponding to the Crontab expression |
When using 'Scheduled Tasks' to obtain time series data at fixed intervals, you should use _DFF_TRIGGER_TIME and _DFF_TRIGGER_TIME_MS as the benchmark, do not use time.time() in your code to get the current time
_DFF_IMAGE_INFO Data Structure
_DFF_IMAGE_INFO contains DataFlux Func image information, including version number, etc.
| Field | Description |
|---|---|
EDITION |
Edition, values are "original", "GSE", "TSE" |
VERSION |
Version number, e.g., "1.2.3" |
ARCHITECTURE |
Architecture, values are "x86_64", "aarch64" |
RELEASE_TIMESTAMP |
Release time (UNIX timestamp, seconds) |
| _DFF_IMAGE_INFO Example Content | |
|---|---|
1 2 3 4 5 6 | |
_DFF_HTTP_REQUEST Data Structure
_DFF_HTTP_REQUEST contains the request body details.
Given the following request:
| Request Example | |
|---|---|
1 2 3 4 5 | |
Then, the value of _DFF_HTTP_REQUEST is as follows:
| _DFF_HTTP_REQUEST Example Content | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
The fields included in _DFF_HTTP_REQUEST may vary slightly across different versions of DataFlux Func. Please refer to the actual content
The headers field is of type IgnoreCaseDict. IgnoreCaseDict inherits from dict and is used similarly but is case-insensitive for key names. For example, the following lines of code will all retrieve the same value
| Python | |
|---|---|
1 2 3 | |