def test_log_capture(self): LOG.log_capture_start() with jt.var_scope(log_v=1000, log_vprefix=""): LOG.v("1") LOG.vv("2") LOG.i("3") LOG.w("4") LOG.e("5") a = jt.zeros([10]) a.sync() LOG.log_capture_stop() # TODO: why need manually delete this variable? del a logs = LOG.log_capture_read() logs2 = LOG.log_capture_read() assert len(logs2) == 0 for i in range(5): assert logs[i]['msg'] == str(i + 1) assert logs[i]['level'] == 'iiiwe'[i] assert logs[i]['name'] == 'test_log.py' finished_log = [ l["msg"] for l in logs if l["name"] == "executor.cc" and "return vars:" in l["msg"] ] assert len(finished_log) == 1 and "[10,]" in finished_log[0]
def init(): cmd = sys.executable + " " + os.path.join(dirname, "md_to_ipynb.py") LOG.i("init notebooks:", cmd) jt.compiler.run_cmd(cmd)
def test(name): LOG.i(f"Run test {name} from {dirname}") ipynb_name = os.path.join(notebook_dir, name + ".ipynb") jt.compiler.run_cmd("ipython " + ipynb_name)
def test(name): doc = eval(f"jt.tests.{name}.__doc__") doc = doc[doc.find("From"):].strip() LOG.i(f"Run test {name} {doc}") exec(f"jt.tests.{name}()")
from jittor_utils import translator import sys jittor_path = jt.flags.jittor_path root_path = os.path.realpath(os.path.join(jt.flags.jittor_path, "..", "..")) data_path = os.path.join(jittor_path, "src", "__data__") build_path = os.path.join(data_path, "build") if not os.path.isdir(build_path): os.mkdir(build_path) status = run_cmd("git status", data_path) print(status) if "working tree clean" not in status: LOG.f("__data__ has untracked files") git_version = run_cmd("git rev-parse HEAD", data_path) LOG.i("git_version", git_version) run_cmd(f"git rev-parse HEAD > {jittor_path}/version", data_path) # remove files files = jt.compiler.files data_files = [name for name in files if "__data__" in name] LOG.i("data_files", data_files) # compile data files from pathlib import Path home = str(Path.home()) # for cc_type in ["g++", "clang"]: # for device in ["cpu", "cuda"]: for cc_type in ["g++"]: for device in ["cpu"]:
# 7. push to github # 8. push to pip import os import jittor as jt from jittor import LOG from jittor.compiler import run_cmd from jittor_utils import translator import sys jittor_path = os.path.realpath(os.path.join(jt.flags.jittor_path, "..", "..")) polish_path = os.path.join(jittor_path, "..", "jittor-polish") polish_path = os.path.realpath(polish_path) build_path = polish_path + "/build" LOG.i("Polish path:", polish_path) if not os.path.isdir(polish_path): # create jittor-polish repo os.mkdir(polish_path) os.mkdir(build_path) run_cmd( "git init . && git remote add origin [email protected]:Jittor/Jittor.git", polish_path) # copy jittor src into it names = "extern notebook python script src README.md README.src.md README.cn.md LICENSE.txt setup.py .gitignore".split( ) for name in names: run_cmd(f"rsync -a {jittor_path}/{name} {polish_path}/") git_version = run_cmd("git rev-parse HEAD", jittor_path)