Using custom Plugins/QPUs with Qaptiva Access

Any Qaptiva Access stack should be composed of remote services (i.e. Generators, Plugins or QPUs imported with the module qlmaas or with a QLMaaSConnection object). One cannot use a stack composed of local services (i.e. Generators, Plugins or QPUs imported with module qat) with a remote service (i.e. imported with module qlmaas)

Local Generators, Plugins and QPUs can be uploaded to the server: any Generator, Plugin and QPU available on the server is accessible remotly, through Qaptiva Access.

Using a Generator/Plugin/QPU available on the server side

The server must be configured to find custom Generators / Plugins / QPUs present on the server side. This configuration can be performed remotly, using the myQLM client prompt tool (this tool can be opened by calling a function). Prompt command config allows you to configure your account to access custom Plugins / QPUs:

An example

If you uploaded a module qpu under the folder ~/upload, you can configure Qaptiva Access to crawl module qpu located under ~/upload:

config update --paths ~/upload --modules qpu

Folder ~/upload will be included in the PythonPath and module qpu will be crawled. Any Plugin or QPU present in this module will become accessible

# Qaptiva Access import
from qlmaas.qpus import MyQPU  # Works if qpu.MyQPU works on the server

The configuration can be displayed:

config list
# Display the remote configuration
> config list

# Update the remote configuration file
> config update [--modules MODULE ...] [--paths PATH ...] [--override]

Uploading a Generator/Plugin/QPU

AbstractGenerator, AbstractPlugin and QPUHandler can’t be uploaded to the server, nevertheless, Qaptiva Access provides MetaLocalGenerator, MetaLocalPlugin and MetaLocalQPU to define uploadable Generator, Plugin or QPU.

Note

Objects defined with MetaLocalGenerator, MetaLocalPlugin or MetaLocalQPU, once uploaded to the server, are treated on the server side. Please do not rely on global variable defined in the client scope (which won’t be defined in the server scope) when defining your methods. Don’t hesitate to import objects directly inside your methods. For instance:

from qat.qlmaas.upload import MetaLocalPlugin

class MyPlugin(metaclass=MetaLocalPlugin):
    def compile(self, batch, specs):
        # Import logging module (not imported on the server side)
        import logging
        logging.info("Message treated on the server")

        # Return compiled batch
        return batch

The Generator, Plugin or QPU can then be uploaded using a UploadedGenerator, UploadedPlugin or UploadedQPU. For instance:

from qat.qlmaas.upload import MetaLocalPlugin
from qlmaas.plugins import UploadedPlugin
from qlmaas.qpus import LinAlg

class MyPlugin(metaclass=MetaLocalPlugin):
    def compile(self, batch, specs):
        # Double number of jobs
        batch.jobs = batch.jobs + batch.jobs

        # Return batch
        return bacth

# Define a stack available on the server side
stack = UploadedPlugin(plugin=MyPlugin()) | LinAlg()