Share your WarpScript macros

How to configure and use WarpFleet resolver to share macros internally or globally with WarpScript developers.

share your WarpScript macros

This a short article to remind everyone how simple macro sharing is between WarpScript developers!

No package, no publication process!

Remember that a macro is a succession of WarpScript statements enclosed with the marks <% and %>. It is the equivalent of a function in another language.

WarpScript resolver

This feature appeared in Warp 10 release 2.0.3.

Discover the latest version of Warp 10.

Open your /etc/conf.d/20-warpfleet.conf:

// Comma separated list of default WarpFleet™ repositories
warpfleet.macros.repos = https://warpfleet.senx.io/macros

By default, the only public macro repo is the SenX one. The list of all available macros on this repo is not disclosed, but we do communicate on interesting ones. You can already access them from any up-to-date Warp 10 instance in the world.

For example, you can generate random numbers with a Gaussian distribution with this macro:

An example

Today, I want to share with you a very simple dataviz macro: juxtaposeGTS. Imagine you want to focus on very short and scarce events. For example, on thousands of race car acquisitions, you only want to view >7200rpm sequences. 65 points selected in 26 million…

Not really readable

There are very few events that last a few seconds, on several years. That's really a pain to zoom on each one. I want to shift every GTS close to the previous one, to juxtapose them. The solution is a simple WarpScript that will take the GTS list on the top of the stack:

Readable davaviz, no need to zoom in anymore

Share it!

First, wrap your code in a typical macro, with documentation inside. This is not mandatory, but will be convenient for online help later. To get an empty documented macro skeleton, just type "macro" in VSCode.

Then, upload your macro to a GitHub repo, or anything that could be used as a static web server. I uploaded my macro here: https://github.com/pi-r-p/warpscript. The path is viz/juxtaposeGTS.mc2. So, for the master branch, the raw path is: https://raw.githubusercontent.com/pi-r-p/warpscript/master/viz/juxtaposeGTS.mc2

Learn more about how to use variables in macros

Import macros (first method)

You manage your Warp 10 instance, or the sysadmin is your friend… Just edit your configuration /etc/conf.d/20-warpfleet.conf, and add your master branch to the repo:

// Comma separated list of default WarpFleet™ repositories
warpfleet.macros.repos = https://warpfleet.senx.io/macros, https://raw.githubusercontent.com/pi-r-p/warpscript/master

You're done. Check with WF.GETREPOS that you have now two repositories. You can now call @viz/juxtaposeGTS in any WarpScript on your instance.

Import macros (second method)

You do not manage the Warp 10 instance, you already asked 10 times your sysadmin to add 10 repositories… You can import repositories from within WarpScript with the WF.ADDREPO function. But this is forbidden by default in Warp 10 configuration (always remember that Warp 10 is secure BY DEFAULT)

First, you need to define a local macro in your macro to allow some URL or some URL patterns. If you want to allow anything, create a new macro (for example /macros/admin/allowRemoteRepos.mc2) with this content:

// combined with other wildcard settings,
// that is a security risk…
<% DROP true %>

If you didn't explicitly allow WEBCALL or REXEC to any domain, there are a few security risks, the main one being that your Warp 10 instance could be used for a DoS attack. If you allow WEBCALL or REXEC to any domain, beware that some external macros could try to steal secrets from your script and export them somewhere.

Then, kindly ask your sysadmin for one last change… Edit your configuration /etc/conf.d/20-warpfleet.conf, and set warpfleet.macros.validator with your local macro name.

# Name of WarpFleet repository macro. This macro consumes a URL and emits a boolean.
warpfleet.macros.validator = admin/allowRemoteRepos

Restart your Warp 10, and try to import a new repo:

Import macros (third method)

You work in a big company. You don't even know the sysadmin. You checked with WF.GETREPOS, WarpFleet SenX repository is here…

Your company has a support contract with SenX… Make sure you didn't put any secrets into the macro, and just ask us to host your macros.

Import macros (winner method)

Gif Captain Picard

You work in a big company. You don't even know the sysadmin. You checked with WF.GETREPOS, WarpFleet SenX repository is here…

Your company hasn't any support contract with SenX… BUT YOUR MACRO IS GREAT. Really great. Just ask us to host it on WarpFleet. It will be reviewed by the greatest WarpScript experts… We will publish it and send you goodies if really exceptional.

Discover tips for ensuring safe and smooth executions to your macros.

Conclusion

Sharing a WarpScript macro is easy. Since Warp10 2.0.3, importing it from any Warp 10 instance is easy too!