Package: hkube-python-wrapper
HKube Python WrapperHkube python wrapper provides a simple interface for integrating algorithm in HKubeFor general information on HKube seehkube.ioInstallationpipinstallhkube-python-wrapperDownloadhkubectllatest version.curl-Lohkubectlhttps://github.com/kube-HPC/hkubectl/releases/download/$(curl-shttps://api.github.com/repos/kube-HPC/hkubectl/releases/latest|grep-oP'"tag_name": "\K(.*)(?=")')/hkubectl-linux\&&chmod+xhkubectl\&&sudomvhkubectl/usr/local/bin/For mac replace with hkubectl-macosFor Windows download hkubectl-win.exeConfighkubectlwith your running Kubernetes.hkubectlconfig# and follow the promptsBasic Usage (using hkube build feature)create a file for the algorithm entry-points (alg.py)fromtypingimportDictfromhkube_python_wrapperimportAlgorunner,HKubeApidefstart(args:Dict,hkubeApi:HKubeApi):return1build the algorithm withhkubectlhkubectlalgorithmapplyalgorithm-name--codePath./folder_of_alg_py--codeEntryPointalg.py--envpython--setCurrentBasic Usage (manual build)fromtypingimportDictfromhkube_python_wrapperimportAlgorunner,HKubeApidefstart(args:Dict,hkubeApi:HKubeApi):return1if__name__=="__main__":Algorunner.Run(start=start)Thestartmethod accepts two arguments:args: dict of invocation inputkeytypedescriptioninputArrayalgorithm input as defined in the pipeline descriptorjobIdstringThe job ID of the pipeline runtaskIdstringThe task ID of the algorithm invocationnodeNamestringThe name of the node in the pipeline descriptorpipelineNamestringThe name of the pipelinebatchIndexintFor batch instance, the index in the batch arrayparentNodeNamestringFor child (code-api) algorithm. The name of the invoking nodeinfo.rootJobIdstringfor sub-pipeline, the jobId of the invoking pipelinehkubeApi: instance of HKubeApi for code-api operationsClass HKubeApiMethodstart_algorithmdef start_algorithm(
    self,
    algorithmName,
    input=[],
    includeResult=True,
    blocking=False
)Starts an invocation of algorithm with input, and optionally waits for resultsArgsalgorithmName:string:   The name of the algorithm to start.input:array:   Optional input for the algorithm.includeResult:bool:   if True, returns the result of the algorithm execution.default: Trueblocking:bool:   if True, blocks until the algorithm finishes, and returns the results.
If False, returns an awaiter object, that can be awaited (blocking) at a later timedefault: FalseReturnsif blocking==False, returns an awaiter. If true, returns the result of the algorithmExample:hkubeApi.start_algorithm('some_algorithm',input=[3],blocking=True)Methodstart_stored_subpipelinedef start_stored_subpipeline(
    self,
    name,
    flowInput={},
    includeResult=True,
    blocking=False
)Starts an invocation of a sub-pipeline with input, and optionally waits for resultsArgsname:string:   The name of the pipeline to start.flowInput:dict:   Optional flowInput for the pipeline.includeResult:bool:   if True, returns the result of the pipeline execution.default: Trueblocking:bool:   if True, blocks until the pipeline finishes, and returns the results.
If False, returns an awaiter object, that can be awaited (blocking) at a later timedefault: FalseReturnsif blocking==False, returns an awaiter. If true, returns the result of the pipelineExample:hkubeApi.start_stored_subpipeline('simple',flowInput={'foo':3},blocking=True)Methodstart_raw_subpipelinedef start_raw_subpipeline(
    self,
    name,
    nodes,
    flowInput,
    options={},
    webhooks={},
    includeResult=True,
    blocking=False
)Starts an invocation of a sub-pipeline with input, nodes, options, and optionally waits for resultsArgsname:string:   The name of the pipeline to start.nodes:string:   Array of nodes. See example below.flowInput:dict:   FlowInput for the pipeline.options:dict:   pipeline options (like in the pipeline descriptor).webhooks:dict:   webhook options (like in the pipeline descriptor).includeResult:bool:   if True, returns the result of the pipeline execution.default: Trueblocking:bool:   if True, blocks until the pipeline finishes, and returns the results.
If False, returns an awaiter object, that can be awaited (blocking) at a later timedefault: FalseReturnsif blocking==False, returns an awaiter. If true, returns the result of the pipelineExample:nodes=[{'nodeName':'d1','algorithmName':'green-alg','input':['@flowInput.foo']}]flowInput={'foo':3}hkubeApi.start_raw_subpipeline('ddd',nodes,flowInput,webhooks={},options={},blocking=True)