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

Accessing one expression library functions from another expression lib

ayush_vipul
New Contributor III

Hi

I have a use case where I am looking forward to access methods of one library(expression file) from another library (expression file 2).

Is their a way to achieve this?

1 ACCEPTED SOLUTION

ayush_vipul
New Contributor III

Thanks @tstack

This helped me a lot.
๐Ÿ˜€

View solution in original post

17 REPLIES 17

tstack
Former Employee

You should be able to reference the other library through the lib variable. Is that not working?

For example, if you this as the library helper.expr:

{
    chefify: x => x + ' bork! bork! bork!'
}

You should be able to reference it from another library, like so:

{
    msg: () => lib.helper.chefify('Hello, World!')
}

Note that if the references are not in functions, but directly in the top-level expression, youโ€™ll need to ensure the libraries are listed in the right order in the pipeline properties.

ayush_vipul
New Contributor III

I found a better way to achieve what i was look for.

But thanks for highlighting this.@tstack

ayush_vipul
New Contributor III

I have a use case where a child pipeline has multiple expr files.

I want to pass a value to the child pipeline using which my chiled pipeline would choose one of the expression library.
is there a way to do it ?

In the child pipeline properties, add a parameter that youโ€™ll use to specify the library to load. Then, in the โ€œExpression Librariesโ€ section, add a path that uses the parameter you just created. Youโ€™ll probably also want to set the name of the imported library using the โ€œAsโ€ column. In the screenshot below, the parameter is config and defaults to the library file dev.expr and the library can be referenced via lib.conf in expressions:

image

In the parent pipeline, youโ€™ll pass the config parameter with the library paths that you want. In the screenshot below, there are two documents entering the PipeExec with โ€œdev.exprโ€ and โ€œprod.exprโ€ as the paths. So, the child will execute first with the โ€œdevโ€ library and then with the โ€œprodโ€ library.

image