Skip to main content
Version: 12.1.0

viktor.external.generic

GenericAnalysis

class viktor.external.generic.GenericAnalysis(files=None, executable_key=None, output_filenames=None)

Bases: viktor.external.external_program.ExternalProgram

GenericAnalysis can be used to evaluate an executable on third-party infrastructure. The executable is expected to be blocking, i.e. if the executable is invoked from command prompt, it should wait until the executable is finished. For security purposes the executable that should be called has to be defined in the configuration file of the worker.

Usage:

files = [
    ('input1.txt', BytesIO(b'filecontent1')),
    ('input2.txt', BytesIO(b'filecontent2'))
]
generic_analysis = GenericAnalysis(files=files, executable_key="someexecutable", output_filenames=["output.txt"])
generic_analysis.execute(timeout=60)
output_file = generic_analysis.get_output_file("output.txt")

Exceptions which can be raised during calculation:

Parameters
  • files (Optional[List[Tuple[str, BytesIO]]]) – Files that are transferred to the working directory on the server. each file is a tuple containing the content and the filename which is used to save on the infrastructure.

  • executable_key (Optional[str]) – The key of the executable that needs to be evaluated. This key should be present in the configuration file of the worker.

  • output_filenames (Optional[List[str]]) – A list of filenames (including extension) that are to be transferred back to the SDK. This filename is relative to the working directory.

At least one of the attributes above should be included in the call.

Raises

ValueError – when no attribute is included in call.

get_output_file(filename)

Method can be used to retrieve the results generated by running an external analysis. Call method execute() first and get_output_file() afterwards.

Parameters

filename (str) – The name of the file (including extension) that you want to get.

Return type

Optional[BytesIO]