class ZoeWorkFlow: def __init__(self, workspace_base_path, identity, name): self.identity = identity self.name = name self.workspace = ZoeWorkspace(workspace_base_path, identity, name) self.exec_api = ZoeExecutionsAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) self.cont_api = ZoeServiceAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) info_api = ZoeInfoAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) zoe_info = info_api.info() self.hostname_prefix = zoe_info['name_prefix'] self.exec_counter = 0 def generate_hostname(self, process_name: str) -> str: return self.hostname_prefix + '-' + process_name + '-' + self.identity[ 'username'] def start_workflow(self): self.workspace.create() def end_workflow(self): self.workspace.destroy() def execution_start(self, app): self.exec_counter += 1 return self.exec_api.execution_start( self.name + '{}'.format(self.exec_counter), app) def wait_termination(self, exec_id): execution = self.exec_api.execution_get(exec_id) while execution['status'] == 'submitted' or execution[ 'status'] == 'running': time.sleep(1) execution = self.exec_api.execution_get(exec_id) def __enter__(self): self.start_workflow() return self def __exit__(self, exc_type, exc_val, exc_tb): self.end_workflow()
def __init__(self, workspace_base_path, identity, name): self.identity = identity self.name = name self.workspace = ZoeWorkspace(workspace_base_path, identity, name) self.exec_api = ZoeExecutionsAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) self.cont_api = ZoeServiceAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) info_api = ZoeInfoAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) zoe_info = info_api.info() self.hostname_prefix = zoe_info['name_prefix'] self.exec_counter = 0
class ZoeWorkFlow: def __init__(self, workspace_base_path, identity, name): self.identity = identity self.name = name self.workspace = ZoeWorkspace(workspace_base_path, identity, name) self.exec_api = ZoeExecutionsAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) self.cont_api = ZoeServiceAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) info_api = ZoeInfoAPI(self.identity['zoe_url'], self.identity['username'], self.identity['password']) zoe_info = info_api.info() self.hostname_prefix = zoe_info['name_prefix'] self.exec_counter = 0 def generate_hostname(self, process_name: str) -> str: return self.hostname_prefix + '-' + process_name + '-' + self.identity['username'] def start_workflow(self): self.workspace.create() def end_workflow(self): self.workspace.destroy() def execution_start(self, app): self.exec_counter += 1 return self.exec_api.execution_start(self.name + '{}'.format(self.exec_counter), app) def wait_termination(self, exec_id): execution = self.exec_api.execution_get(exec_id) while execution['status'] == 'submitted' or execution['status'] == 'running': time.sleep(1) execution = self.exec_api.execution_get(exec_id) def __enter__(self): self.start_workflow() return self def __exit__(self, exc_type, exc_val, exc_tb): self.end_workflow()