cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Expressions with pipelines

ryagnik
New Contributor

we have a need here in which we want to upload expressions to pipeline dynamically.

Is there any API out there which can upload expressions file dynamically on pipelines ?

Can expressions files be loaded from file system ? currently, it cant support expression while we upload expression files.

Answers will be much appreciated hereโ€ฆ

Thanksโ€ฆ
Rishi

8 REPLIES 8

Do you have any example on it ? would be much more helpful here.

I can also try from my end and let you all know how that works.

Help much appreciated here

Thanks for your helpโ€ฆ

tstack
Former Employee

The Expression Libraries feature might be useful in this case. Libraries are files that are loaded into a pipeline at startup and made available to all expression properties through the โ€˜libโ€™ variable. So, you can create an object with a bunch of arrow functions containing the expressions you need access to. For example, if you created a file named โ€˜demo.exprโ€™, with the following content and imported it into a pipeline. You could square numbers by calling โ€˜lib.demo.square(2)โ€™ in an expression property.

{
    square: x => x * x
}

If that doesnโ€™t quite work for you, there is also the eval function, which you can use to evaluate an expression string that was created dynamically. You could imagine using it in a similar fashion where the content was loaded into a string, evalโ€™d, and then the resulting functions would be available for use. The downside being that the functions would not be available in every expression property.

ryagnik
New Contributor

I am well verse with expression library features,please refer to my use case mentioned in previous answer.

tstack
Former Employee

Sorry, I guess Iโ€™m not clear on what the flow is in your scenario.

Is this the gap you are referring to? Are you wanting to dynamically determine the set of expression libraries to import? More specifically, are you wanting to change the number of libraries you want to import or dynamically determine the library to import? The former is not supported at the moment, the platform can only import a fixed number of libraries, you canโ€™t import N extra libraries at invocation. The latter is supported, you can make the library path an expression and use pipeline parameters to choose which library to import. You can also โ€œoverlayโ€ libraries, so you could have a library with a default set of expressions and then overlay a second library with more specific values for a particular business.

I was thinking you would have one library file and updating the expressions in that as the rules were changing.

Also, how are you invoking the pipeline? With a scheduled task?