def simulate_airfoil(model_params, compute_params, encrypted_swift_config, container): """ :param model.ModelParameters.ModelParameters model_params: ModelParameters :param model.ComputeParameters.ComputeParameters compute_params: ComputeParameters :param dict swift_config: dict """ #check if results are already in the objectstore swift_config = json.loads(crypt_obj.decrypt(encrypted_swift_config)) swift = SwiftStorage(swift_config, container) if swift.has_result(model_params, compute_params): return swift.get_result(model_params, compute_params) #create a working directory for each task, this is to #avoid collisions between workers when they execute the airfoil binary root_dir = os.getcwd() working_dir = root_dir + "/workdir/" + str(model_params.job) + "/a" + str(model_params.angle) if not os.path.exists(working_dir): os.makedirs(working_dir) os.chdir(working_dir) msh_file = creator.create_model(model_params) xml_file = converter.convert(msh_file) result = computation.perform_computation(compute_params, xml_file) result['angle'] = model_params.angle #reset working directory os.chdir(root_dir) #put result into object store, with the results hash_key as name swift.save_result(model_params, compute_params, result) return json.dumps(result)
def __init__(self, worker_manager, storage, config): super(DefaultComputeManager, self).__init__(storage) self._worker_manager = worker_manager self._config = config self._jobs = {} swift = SwiftStorage(config.swift_config, config.container) for objectName in swift.get_entries(): objectData = swift.get_result_hash(objectName) storage.save_result_hash(objectName, objectData)
def simulate_airfoil(model_params, compute_params, encrypted_swift_config, container): """ :param model.ModelParameters.ModelParameters model_params: ModelParameters :param model.ComputeParameters.ComputeParameters compute_params: ComputeParameters :param dict swift_config: dict """ #check if results are already in the objectstore swift_config = json.loads(crypt_obj.decrypt(encrypted_swift_config)) swift = SwiftStorage(swift_config, container) if swift.has_result(model_params, compute_params): return swift.get_result(model_params, compute_params) #create a working directory for each task, this is to #avoid collisions between workers when they execute the airfoil binary root_dir = os.getcwd() working_dir = root_dir + "/workdir/" + str(model_params.job) + "/a" + str( model_params.angle) if not os.path.exists(working_dir): os.makedirs(working_dir) os.chdir(working_dir) msh_file = creator.create_model(model_params) xml_file = converter.convert(msh_file) result = computation.perform_computation(compute_params, xml_file) result['angle'] = model_params.angle #reset working directory os.chdir(root_dir) #put result into object store, with the results hash_key as name swift.save_result(model_params, compute_params, result) return json.dumps(result)