()
return info
Collects information about the environment, for reproducibility
Collects information about the environment, for reproducibility
Collects information about the environment for reproducibility
def env_info():
    """ Collects information about the environment, for reproducibility """
    info = {}
    info['python_version'] = sys.version
    info['command'] = subprocess.list2cmdline(sys.argv)
    with open(os.devnull, 'w') as devnull:
        info['pip_modules'] = subprocess.check_output(['pip', 'freeze'], stderr=devnull)
        try:
            git_branch_cmd = ['git', 'rev-parse', '--abbrev-ref', 'HEAD']
            info['git_branch'] = subprocess.check_output(git_branch_cmd, stderr=devnull).strip().decode('UTF-8')
            git_local_commit_cmd = ['git', 'rev-parse', 'HEAD']
            git_status_cmd = ['git', 'status']
            git_origin_commit_cmd = ['git', 'rev-parse', 'origin/{}'.format(info['git_branch'])]
            git_diff_origin_commit_cmd = ['git', 'diff', 'origin/{}'.format(info['git_branch'])]
            info['git_origin_commit'] = subprocess.check_output(git_origin_commit_cmd, stderr=devnull)
            git_log_since_origin_cmd = ['git', 'log', '--pretty=oneline', '{}..HEAD'.format(info['git_origin_commit'])]
            info['git_local_commit'] = subprocess.check_output(git_local_commit_cmd, stderr=devnull)
            info['git_status'] = subprocess.check_output(git_status_cmd, stderr=devnull)
            info['git_diff_origin_commit'] = subprocess.check_output(git_diff_origin_commit_cmd, stderr=devnull)
            info['git_log_since_origin'] = subprocess.check_output(git_log_since_origin_cmd, stderr=devnull)
        except subprocess.CalledProcessError:
            pass
    info['creation_time'] = time.strftime('%y-%m-%d-%H-%M-%S')
    info['sysname'] = os.uname()[0]
    info['nodename'] = os.uname()[1]
    info['release'] = os.uname()[2]
    info['version'] = os.uname()[3]
    info['architecture'] = os.uname()[4]
    info['user'] = os.environ['USER']
    info['path'] = os.environ['PWD']
    info['conda_environment'] = os.environ.get('CONDA_DEFAULT_ENV', '')
    info['environment_vars'] = dict(os.environ)
    info = {k: info[k].decode("UTF-8") if type(info[k]) == bytes else info[k] for k in info}
    return info
def env_info ( ) : info = { } info [ 'python_version' ] = sys . version info [ 'command' ] = subprocess . list2cmdline ( sys . argv ) with open ( os . devnull , 'w' ) as devnull : info [ 'pip_modules' ] = subprocess . check_output ( [ 'pip' , 'freeze' ] , stderr = devnull ) try : git_branch_cmd = [ 'git' , 'rev-parse' , '--abbrev-ref' , 'HEAD' ] info [ 'git_branch' ] = subprocess . check_output ( git_branch_cmd , stderr = devnull ) . strip ( ) . decode ( 'UTF-8' ) git_local_commit_cmd = [ 'git' , 'rev-parse' , 'HEAD' ] git_status_cmd = [ 'git' , 'status' ] git_origin_commit_cmd = [ 'git' , 'rev-parse' , 'origin/{}' . format ( info [ 'git_branch' ] ) ] git_diff_origin_commit_cmd = [ 'git' , 'diff' , 'origin/{}' . format ( info [ 'git_branch' ] ) ] info [ 'git_origin_commit' ] = subprocess . check_output ( git_origin_commit_cmd , stderr = devnull ) git_log_since_origin_cmd = [ 'git' , 'log' , '--pretty=oneline' , '{}..HEAD' . format ( info [ 'git_origin_commit' ] ) ] info [ 'git_local_commit' ] = subprocess . check_output ( git_local_commit_cmd , stderr = devnull ) info [ 'git_status' ] = subprocess . check_output ( git_status_cmd , stderr = devnull ) info [ 'git_diff_origin_commit' ] = subprocess . check_output ( git_diff_origin_commit_cmd , stderr = devnull ) info [ 'git_log_since_origin' ] = subprocess . check_output ( git_log_since_origin_cmd , stderr = devnull ) except subprocess . CalledProcessError : pass info [ 'creation_time' ] = time . strftime ( '%y-%m-%d-%H-%M-%S' ) info [ 'sysname' ] = os . uname ( ) [ 0 ] info [ 'nodename' ] = os . uname ( ) [ 1 ] info [ 'release' ] = os . uname ( ) [ 2 ] info [ 'version' ] = os . uname ( ) [ 3 ] info [ 'architecture' ] = os . uname ( ) [ 4 ] info [ 'user' ] = os . environ [ 'USER' ] info [ 'path' ] = os . environ [ 'PWD' ] info [ 'conda_environment' ] = os . environ . get ( 'CONDA_DEFAULT_ENV' , '' ) info [ 'environment_vars' ] = dict ( os . environ ) info = { k : info [ k ] . decode ( "UTF-8" ) if type ( info [ k ] ) == bytes else info [ k ] for k in info } return info