kube-HPC / hkube

🐟 High Performance Computing over Kubernetes - Core Repo 🎣
http://hkube.io
MIT License
305 stars 20 forks source link

Stateless block , Algorunner init/start method #1726

Closed lersam closed 6 months ago

lersam commented 1 year ago

HKube micro-service To which micro-service the bug related to, Algorunner.

Describe the bug statles module , with three functions: init, start, stop as i understood init called before start. i made object initialization on 'init' and made module function call. i received exception that module is undefined

Expected behavior after call object on init, it should be live in start

To Reproduce

from hkube_python_wrapper import Algorunner

class Handler:
    def __init__(self):
        pass

    def on_input(self, msg):
        print(msg)

global my_handler:Handler = None

def init(args):
    global my_handler
    my_handler = Handler()

def start(args, hkube_api):
    global my_handler
    stream = args.get('streamInput')
    my_handler.on_input(stream.get('message'))

if __name__ == '__main__':
    Algorunner.Run(start=start, init=init)

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

golanha commented 6 months ago

Change: global my_handler:Handler = None to global my_handler my_handler = None

And will work