From e3840246edaa97867267d641c3f736b75500714b Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Mon, 18 Mar 2019 13:22:30 -0700 Subject: [PATCH 1/2] Add tools to synchronize with dmlc/tvm --- dmlc_tvm_commit_id | 1 + neo-tools/sync-with-dmlc.py | 73 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 dmlc_tvm_commit_id create mode 100755 neo-tools/sync-with-dmlc.py diff --git a/dmlc_tvm_commit_id b/dmlc_tvm_commit_id new file mode 100644 index 000000000000..25e2fbfcf16d --- /dev/null +++ b/dmlc_tvm_commit_id @@ -0,0 +1 @@ +5e3ceaa073f8540eec0e1334a9190041b88921c4 diff --git a/neo-tools/sync-with-dmlc.py b/neo-tools/sync-with-dmlc.py new file mode 100755 index 000000000000..db770da5deb0 --- /dev/null +++ b/neo-tools/sync-with-dmlc.py @@ -0,0 +1,73 @@ +import argparse +import logging + +# Install via: pip install GitPython +from git import Repo + +logging.basicConfig(level=logging.INFO) + +def parse_args(): + parser = argparse.ArgumentParser(description='Pull latest commits from dmlc/tvm') + parser.add_argument('--sum', dest='accumulate', action='store_const', + const=sum, default=max, + help='sum the integers (default: find the max)') + + return parser.parse_args() + +def add_remote(repo, name, url): + for remote in repo.remotes: + if remote.name == name: + assert remote.url == url + logging.info("Remote {} already exists".format(name)) + return + logging.info("Add remote {} with url {}".format(name, url)) + repo.create_remote(name, url) + +""" +This tool automatically cherry picks commit from dmlc/tvm into neo-ai/tvm's dev +branch, it keeps track of last selected commit id in file dmlc_tvm_commit_id. It +fetches from dmlc/tvm first, get the latest commit id from master branch, and cherry-picks +commits from last slected commit until latest commit. +""" +def main(): + args = parse_args() + last_commit_file = 'dmlc_tvm_commit_id' + last_commit = None + with open(last_commit_file) as f: + last_commit = f.read().strip() + if last_commit is None: + logging.error('can not find last commit file {}'.format(last_commit_file)) + logging.info('Synchronizing from commit {}'.format(last_commit)) + + # Add dmlc/tvm to remote 'upstream' if not + repo = Repo() + add_remote(repo, 'upstream', 'git@github.com:dmlc/tvm.git') + + # Fetch 'upstream' remote + logging.info("Fetching remote upstrean") + upstream = repo.remote('upstream') + upstream.fetch() + + # Switch to 'master' in 'upstream' + repo.git.checkout('upstream/master') + + # Save HEAD commit + head = repo.commit('HEAD') + head_commit = head.hexsha + + # Switch back to 'dev' branch to do cherry pick + repo.git.checkout('dev') + + # Do the cherry-pick from last_commit to head_commit + repo.git.cherry_pick('{}..{}'.format(last_commit, head_commit)) + + # Update submodule + repo.git.submodule('update') + + with open(last_commit_file, 'w') as f: + f.write(head_commit) + + logging.info("Update successfully") + +if __name__ == '__main__': + main() \ No newline at end of file From 2eaf9174b7fe3e6009402aee49d0f9b972bd1378 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Mon, 18 Mar 2019 17:38:52 -0700 Subject: [PATCH 2/2] Add newline --- neo-tools/sync-with-dmlc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo-tools/sync-with-dmlc.py b/neo-tools/sync-with-dmlc.py index db770da5deb0..5046131c6a3f 100755 --- a/neo-tools/sync-with-dmlc.py +++ b/neo-tools/sync-with-dmlc.py @@ -70,4 +70,4 @@ def main(): logging.info("Update successfully") if __name__ == '__main__': - main() \ No newline at end of file + main()