Skip to content

Commit

Permalink
Add an API to dump system info
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Feb 11, 2024
1 parent 6f8ce43 commit 3540f3b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
19 changes: 3 additions & 16 deletions pyscf/gto/mole.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import sys
import types
import re
import platform
import gc
import time

import json
import ctypes
Expand Down Expand Up @@ -2695,7 +2693,6 @@ def gto_norm(self, l, expnt):

def dump_input(self):
import __main__
import pyscf
if hasattr(__main__, '__file__'):
try:
filename = os.path.abspath(__main__.__file__)
Expand All @@ -2709,19 +2706,9 @@ def dump_input(self):
except IOError:
logger.warn(self, 'input file does not exist')

self.stdout.write('System: %s Threads %s\n' %
(str(platform.uname()), lib.num_threads()))
self.stdout.write('Python %s\n' % sys.version)
self.stdout.write('numpy %s scipy %s\n' %
(numpy.__version__, scipy.__version__))
self.stdout.write('Date: %s\n' % time.ctime())
self.stdout.write('PySCF version %s\n' % pyscf.__version__)
info = lib.repo_info(os.path.join(__file__, '..', '..'))
self.stdout.write('PySCF path %s\n' % info['path'])
if 'git' in info:
self.stdout.write(info['git'] + '\n')

self.stdout.write('\n')
self.stdout.write('\n'.join(lib.misc.format_sys_info()))

self.stdout.write('\n\n')
for key in os.environ:
if 'PYSCF' in key:
self.stdout.write('[ENV] %s %s\n' % (key, os.environ[key]))
Expand Down
19 changes: 19 additions & 0 deletions pyscf/lib/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import os
import sys
import time
import platform
import warnings
import tempfile
import functools
Expand All @@ -30,6 +32,7 @@
import collections
import ctypes
import numpy
import scipy
import h5py
from threading import Thread
from multiprocessing import Queue, Process
Expand Down Expand Up @@ -1303,6 +1306,22 @@ def git_info(repo_path):
pass
return orig_head, head, branch

def format_sys_info():
'''Format a list of system information for printing.'''
import pyscf
info = repo_info(os.path.join(__file__, '..', '..'))
result = [
f'System: {platform.uname()} Threads {num_threads()}',
f'Python {sys.version}',
f'numpy {numpy.__version__} scipy {scipy.__version__}',
f'Date: {time.ctime()}',
f'PySCF version {pyscf.__version__}',
f'PySCF path {info["path"]}',
]
if 'git' in info:
result.append(info['git'])
return result


def isinteger(obj):
'''
Expand Down

0 comments on commit 3540f3b

Please sign in to comment.