def compile_custom_op(path): """Runs the make command to build the custom op objects""" files_to_generate = ["custom_codelet.gp", "libcustom_op.so"] if check_data_exists(path, files_to_generate): print("Objects already present, cleaning...") subprocess.run(["make", "clean"], cwd=path) completed = subprocess.run("make", cwd=path) if completed.returncode != 0 or not check_data_exists( path, files_to_generate): raise Exception("Custom op compilation failed") print("Successfully compiled custom op")
def _check_file_exists_helper(self, report_path, filename): """Helper function to check whether report_generation.md exists in location report_path and raises an assertion error if it doesn't exist.""" if not check_data_exists(report_path, [filename]): raise AssertionError("{} does not exist in location {}".format( filename, report_path))
def check_all_data_present(file_path): """Checks the data exists in location file_path""" filenames = [ "t10k-images-idx3-ubyte", "t10k-labels-idx1-ubyte", "train-images-idx3-ubyte", "train-labels-idx1-ubyte", ] data_path = os.path.join(file_path, "data") return check_data_exists(data_path, filenames)
def _remove_any_existing_report(self, report_path, filename): """Helper function to check whether filename exists in report_path. If it does, the file is removed.""" if check_data_exists(report_path, [filename]): os.remove(os.path.join(report_path, filename))