You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/11/29 14:18:49 UTC

[GitHub] [incubator-mxnet] szha commented on a change in pull request #20755: [FEATURE] Hardcode build-time branch and commit hash into the library

szha commented on a change in pull request #20755:
URL: https://github.com/apache/incubator-mxnet/pull/20755#discussion_r758404476



##########
File path: tools/diagnose.py
##########
@@ -96,13 +96,8 @@ def check_mxnet():
         print('Version      :', mxnet.__version__)
         mx_dir = os.path.dirname(mxnet.__file__)
         print('Directory    :', mx_dir)
-        commit_hash = os.path.join(mx_dir, 'COMMIT_HASH')
-        if os.path.exists(commit_hash):
-            with open(commit_hash, 'r') as f:
-                ch = f.read().strip()
-                print('Commit Hash   :', ch)
-        else:
-            print('Commit hash file "{}" not found. Not installed from pre-built package or built from source.'.format(commit_hash))
+        print('Branch       :', mxnet.base.get_branch())
+        print('Commit Hash  :', mxnet.base.get_commit_hash())

Review comment:
       Our website points people to this script in master branch regardless of the version, and as a result some older builds would not have these interfaces. It would be better to do a try/except here.

##########
File path: python/mxnet/base.py
##########
@@ -957,3 +957,15 @@ def _init_np_op_module(root_module_name, np_module_name, mx_module_name, make_op
             function.__doc__ = getattr(_np_op_doc, name).__doc__
         else:
             function.__doc__ = re.sub('NDArray', 'ndarray', function.__doc__)
+
+
+def get_branch():
+    out = ctypes.c_char_p()
+    check_call(_LIB.MXGetBranch(ctypes.byref(out)))
+    return py_str(out.value)
+
+def get_commit_hash():
+    out = ctypes.c_char_p()
+    check_call(_LIB.MXGetCommitHash(ctypes.byref(out)))
+    return py_str(out.value)

Review comment:
       These APIs seem more suitable in `python/mxnet/runtime.py`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org