Pylavi

Pylavi is a really simple tool to add to your CI/CD toolbox.

Pylavi

Jim Kring recently introduced me to a tool called pylavi. It is a tool written in Python that allows you to inspect LabVIEW files. It doesn't actually open the files in LabVIEW. It just inspects the binary content of the files. That makes it very fast. It also outputs an error code if any checks fail, which makes it a perfect CI/CD tool to complement your existing pipeline.

If you look on the GitHub page, you'll see a list of things it can check. Some of the more useful checks are ensure that:

  • source code is separated
  • auto error handling is disabled
  • no breakpoints were left in the code
  • no VIs are set to suspend on run

Running it locally

You can easily run pylavi locally. You simply need Python installed. Then you can pip install pylavi Once installed, then use the command vi_validate from your favorite shell. As an example the code below will run Pylavi on the source folder and run all the checks listed above. You'll see it runs quite fast.

vi_validate --path source --no-code --breakpoints \
--no-suspend-on-run --autoerror

Running it as a GitLab CI job

This can be a really useful thing to run as part of your CI system. I set it up to run in a stage called inspect that runs before anything else. That way if something isn't right I find out as quickly as possible.

The code below will run the same pylavi command as above on the latest Python3 Docker image. The fact that it runs in a Docker image, it means you don't have to do anything other than drop this snippet in your .gitlab-ci.yml file.

pylavi:
  stage: inspect
  image: python:3
  script:
    - pip install pylavi
    - vi_validate 
        --path source 
        --no-code 
        --breakpoints 
        --no-suspend-on-run 
        --autoerror

.

LabVIEW versions

One place I could see this being very useful is for managing LabVIEW versions. As you, the reader, may know starting with LabVIEW 2024Q3, the editor has the ability to maintain code in older versions. If there is an open-source project written in LabVIEW 2020 (for maximum backward compatibility) that you want to contribute to, you no longer have to set up a machine with LabVIEW 2020. You can use 2024Q3 and tell it to keep the code in 2020. That's great! However, as a maintainer, you have to trust contributors to have that set up correctly. You can preemptively detect that using pylavi. I can see that being a powerful use case.

Want Help Setting up CI/CD?

As always if you need help setting CI/CD for your organization, I am happy to help. Just reach out using the button below and we can talk about the various options.