Automation API - High Level Analyzer

I have built my high-level analyzer which works great with the UI. I have also created an automation script from which I trigger a capture and record data into a file.

Now I want my automation script to call my high level analyzer, but when I run it says it cant load the extension.

This is how im trying to do this:

hla = capture.add_high_level_analyzer(extension_directory='SPI_ADC_HLA',
                                              name='SPI_ADC_HLA', input_analyzer=spi_analyzer)

            analyzers=[spi_analyzer, hla] #analyzers=[spi_analyzer]

My error:

Traceback (most recent call last):
  File "C:\energy_system_modeling\Projects\6_PVI\Saleae_SPI_sniffing_demo\logic_automation\", line 60, in <module>
    hla = capture.add_high_level_analyzer(extension_directory='C:\energy_system_modeling\Projects\6_PVI\Saleae_SPI_sniffing_demo\logic_automation\SPI_ADC_HLA',
  File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\saleae\automation\", line 149, in add_high_level_analyzer
    with _error_handler():
  File "C:\Program Files\Python311\Lib\", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\saleae\automation\", line 121, in _error_handler
    raise grpc_error_to_exception(exc) from None
saleae.automation.errors.InvalidRequestError: Failed to load extension at SPI_ADC_HLA\extension.json

Any ideas? I tried providing a full path too but nothing works.
Also the extension loads perfectly with the UI

Took me a long time and it was the silliest thing. My solution:

hla = capture.add_high_level_analyzer(extension_directory=os.path.join(os.getcwd(), f'SPI_ADC_HLA'),
                                              name='SPI_ADC_HLA', input_analyzer=spi_analyzer, settings=None)

It would be really helpful if Saleae team could provide examples for their automation API. Could have saved some time.

@ddominguezmoises Sorry for the trouble with that! We really should make our example scripts easier to find. I’ll work on getting that up somewhere obvious.

For reference, here is an example usage for adding HLAs that could have been helpful: