System Library: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
* ML | * ML | ||
** [[Create Predicted Eventlog|GeneratePredictionModel]] | ** [[Create Predicted Eventlog|GeneratePredictionModel]] | ||
** [[Create Simulated Eventlog|ApplyTransformations]] | ** [[Create Simulated Eventlog|ApplyTransformations]] | ||
* Parallel | * Parallel | ||
** | ** Run | ||
* RootCauses | * RootCauses | ||
** FindRootCausesDataFrame | ** FindRootCausesDataFrame | ||
Line 14: | Line 15: | ||
** ModifyColumnTypes | ** ModifyColumnTypes | ||
** RunFunctionWithParallelLogging | ** RunFunctionWithParallelLogging | ||
== Parallel.Run == | |||
Runs given functions in parallel. | |||
====== Parameters ====== | |||
* '''functions''': | |||
** An array of functions to run in parallel. | |||
====== Example ====== | |||
The following script uses _system.Parallel.Run to run three functions: | |||
* SAP-extraction from VBAK-table in SAP | |||
* Transform the extracted data by adding a new column. | |||
* Load the data into data table identified by dataTableId. | |||
<syntaxhighlight lang="typescript"> | |||
function ExtractTransformAndLoad(extractFunc, transformFunc, loadFunc) | |||
{ | |||
let rawDataFlow = extractFunc(); | |||
let transformedDataFlow = ToDataFlow(); | |||
_system.Parallel.Run([ | |||
() => Catch({ | |||
let df; | |||
while (!IsNullTop(df = rawDataFlow.Collect(#{"CollectChunk": true}))) { | |||
transformedDataFlow.Append(transformFunc(df)); | |||
WriteLog(`A chunk having ${df.NRows} rows has been transformed.`); | |||
} | |||
if (rawDataFlow.HasError) { | |||
transformedDataFlow.Fail("Error occurred during data extraction."); | |||
} | |||
else { | |||
transformedDataFlow.Complete(); | |||
} | |||
}, { | |||
transformedDataFlow.Fail("Error occurred during transformation calculation."); | |||
}), | |||
() => { | |||
loadFunc(transformedDataFlow); | |||
} | |||
]); | |||
} | |||
ExtractTransformAndLoad( | |||
() => ExtractSap(GetSapConnectionJson().Extend( | |||
[ | |||
"FieldNames": "VBELN,ERDAT,ERZET,ERNAM,NETWR,WAERK", | |||
"QueryTable": "VBAK", | |||
"Options": ["VBELN BETWEEN '0000017448'" ,"AND '0060000042'"], | |||
"UseGateway": true | |||
]) | |||
), | |||
df => df.SetColumns(["Test": () => `${Column("NETWR")} ${Column("WAERK")}`]), | |||
dataFlow => { | |||
DataTableById({dataTable.Id}).Import(dataFlow, ["Append": 0]); | |||
} | |||
); | |||
DataTableById({dataTable.Id}).SqlDataFrame.OrderByColumns(["VBELN"], [true]).Collect() | |||
</syntaxhighlight> | |||
== RootCauses.FindRootCausesDataFrame == | |||
foo | |||
== Utils.GetSampledEvents == | |||
foo | |||
== Utils.RunFunctionWithParallelLogging == | |||
foo |
Revision as of 10:23, 19 November 2024
System library is a collection of Expression Language functions and properties that provide additional tools for scripting Process Analyzer functionalities. System library is referenced in scripts via _system-property, which provides additional properties dedicated for different areas of interests for scripting.
The following hierarchy shows the properties and functions available in System Library:
- Parallel
- Run
- RootCauses
- FindRootCausesDataFrame
- Utils
- GetSampledEvents
- ModifyColumnTypes
- RunFunctionWithParallelLogging
Parallel.Run
Runs given functions in parallel.
Parameters
- functions:
- An array of functions to run in parallel.
Example
The following script uses _system.Parallel.Run to run three functions:
- SAP-extraction from VBAK-table in SAP
- Transform the extracted data by adding a new column.
- Load the data into data table identified by dataTableId.
function ExtractTransformAndLoad(extractFunc, transformFunc, loadFunc)
{
let rawDataFlow = extractFunc();
let transformedDataFlow = ToDataFlow();
_system.Parallel.Run([
() => Catch({
let df;
while (!IsNullTop(df = rawDataFlow.Collect(#{"CollectChunk": true}))) {
transformedDataFlow.Append(transformFunc(df));
WriteLog(`A chunk having ${df.NRows} rows has been transformed.`);
}
if (rawDataFlow.HasError) {
transformedDataFlow.Fail("Error occurred during data extraction.");
}
else {
transformedDataFlow.Complete();
}
}, {
transformedDataFlow.Fail("Error occurred during transformation calculation.");
}),
() => {
loadFunc(transformedDataFlow);
}
]);
}
ExtractTransformAndLoad(
() => ExtractSap(GetSapConnectionJson().Extend(
[
"FieldNames": "VBELN,ERDAT,ERZET,ERNAM,NETWR,WAERK",
"QueryTable": "VBAK",
"Options": ["VBELN BETWEEN '0000017448'" ,"AND '0060000042'"],
"UseGateway": true
])
),
df => df.SetColumns(["Test": () => `${Column("NETWR")} ${Column("WAERK")}`]),
dataFlow => {
DataTableById({dataTable.Id}).Import(dataFlow, ["Append": 0]);
}
);
DataTableById({dataTable.Id}).SqlDataFrame.OrderByColumns(["VBELN"], [true]).Collect()
RootCauses.FindRootCausesDataFrame
foo
Utils.GetSampledEvents
foo
Utils.RunFunctionWithParallelLogging
foo