Script Development / Built-in Variables
To help Scripts obtain relevant runtime status information during execution, DataFlux Func provides some directly usable built-in variables in the Script context.
| Built-in Variable | Type | Scope | Description | Example Value |
|---|---|---|---|---|
_DFF_IMAGE_INFO |
dict | All | Current image info | See below |
_DFF_TRACE_ID |
str | All | Trace ID Trace inside Func |
"TRACE-14E6D8D6-1F1A-4A5A-8280-854F6DD8CDB0" |
_DFF_TASK_ID |
str | All | Task ID | "task-2UHeFYPdb6Q7" |
_DFF_ROOT_TASK_ID |
str | All | Root task ID For the root task itself, fixed to "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 i.e., the part excluding the Script Set ID |
"basic" |
_DFF_SCRIPT_TITLE |
str | All | Script title | "Basic" |
_DFF_FUNC_ID |
str | All | Function ID | "demo__basic.hello_world" |
_DFF_FUNC_NAME |
str | All | Function name i.e., the part excluding 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 parameters | {"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 | Cron Job | Crontab expression | * * * * * |
_DFF_HTTP_REQUEST |
dict | Func API Function Page |
Request body when the API is invoked | 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 executing int(time.time()) at the function entry, and may be delayed by factors such as queue congestion.
_DFF_TRIGGER_TIME, on the other hand, refers to the time when the function is triggered. It does not change due to queue congestion and can be considered the "scheduled start time". The values are as follows:
| Function invocation method | Value |
|---|---|
| Execute function from UI | Time when the backend API service receives the HTTP request |
| Func API | Time when the backend API service receives the HTTP request |
| Cron Job | The exact time point corresponding to the Crontab expression |
When using Cron Job to fetch time-series data at fixed intervals, use _DFF_TRIGGER_TIME and _DFF_TRIGGER_TIME_MS as the baseline, and do not use time.time() in your own code to get the current time
_DFF_IMAGE_INFO Data Structure
_DFF_IMAGE_INFO contains DataFlux Func image information, including the version number and other details.
| Field | Description |
|---|---|
EDITION |
Edition; possible values are "original", "GSE", "TSE" |
VERSION |
Version number, e.g., "1.2.3" |
ARCHITECTURE |
Architecture; possible values are "x86_64", "aarch64" |
RELEASE_TIMESTAMP |
Release time (UNIX timestamp in seconds) |
| _DFF_IMAGE_INFO Content Example | |
|---|---|
1 2 3 4 5 6 | |
_DFF_HTTP_REQUEST Data Structure
_DFF_HTTP_REQUEST contains the request body details.
For example, given the following request:
| Example Request | |
|---|---|
1 2 3 4 5 | |
Then, the value of _DFF_HTTP_REQUEST is as follows:
| _DFF_HTTP_REQUEST Content Example | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
In different versions of DataFlux Func, the fields contained in _DFF_HTTP_REQUEST may differ slightly; please refer to the actual version.
The headers field type is IgnoreCaseDict. IgnoreCaseDict inherits dict, so it is used basically the same way, except that key names are case-insensitive. For example, all the following lines of code can obtain the same value
| Python | |
|---|---|
1 2 3 | |