Downloading streams flow code in a code archive package

Sometimes it’s useful to examine the code that gets generated from the streams flow that is designed on the streams flow canvas. Download the flow code in the following situations:

  • The streams flow has compile or runtime errors.

  • Version compatibility problems exist.

  • The streams flow has performance problems.

  • You need operators that are not available in the streams flow canvas. You can use the initial code that is generated for the streams flow, and then continue developing in IBM Streams Studio.

The code archive is a package that the streams flow generates and sends to the Streaming Analytics service to build and run the streams flow.

The code archive package contains the following components:

  • Uncompiled SPL code that generated the streams flow.

  • Toolkits, Python libraries, and scripts that are required to compile and run the streams flow.

You can download the code archive package from the Metrics or the Canvas page to your local disk. Then, you can compile the code, import it into your Streaming Analytics instance, and submit the job to the Streams Console in IBM Cloud.

   

Prerequisite

Download and install the following software on your local disk:

   

To download the code archive log, follow these steps:

  1. Download the code either in the Metrics page of the streams flow or in the Canvas toolbar. Note that the flow must be valid to perform a download.

    a. To download the code in the Metrics page, click the Notifications icon Notification icon to open the Notification taskbar. In the Notification taskbar, click the Download code archive icon Download code archive icon.

    b. To download the code in the Canvas page, click the Download code archive icon Download code archive icon.

    With either of of these actions, a compressed file is downloaded to your local disk. For example, the compressed file migt be
    CodeArchive_78718fb7-90c1-442a-b21e-8652f4a5d63b.tar.gz.

  2. Click the *.tar.gz file, and then extract its contents to a *.tar file. In our example, the extacted file might be
    CodeArchive_78718fb7-90c1-442a-b21e-8652f4a5d63b.tar.

  3. Click the *.tar file to open it and extract its files to a local directory. In our example, the directory contains the following files:

    Contents of code archive file

    You can see the SPL code in the file WDPCodeGen\codegen\Main.spl.

  4. Open a command prompt window in the environment where you installed Streaming Analytics, and then perform the following steps.

    a. Go to the directory where the extracted *.tar files are.

    b. Type the command make. This command compiles the SPL code file, and then generates a *.sab (Streams Application Bundle) file in /WDPCodegen/output.


What’s next?

Check the SPL code and make any needed changes. Then, run the make command again to recompile the updated SPL file and create a new *.sab file.

You can deploy the *.sab file to the Streams Console in IBM Cloud, and then monitor your application.

Note: Neither the SPL code, nor the new *.sab file can be converted back into a streams flow.