Skip to content

Commit

Permalink
removed commands.py which included incompatible subprocess.run call
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Hoffman committed Nov 13, 2018
1 parent d23f4b1 commit 9a34701
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
import argparse
import os
import platform
import commands
try:
from commands import getoutput
except ImportError:
from subprocess import getoutput
import logging
import datetime
import pickle
Expand Down Expand Up @@ -263,13 +266,13 @@ def main(opt):
opt.sys_uname = platform.uname()
if platform.system() == 'Darwin':
opt.sys_info =\
commands.getoutput('system_profiler'
' -detailLevel mini SPHardwareDataType')\
getoutput('system_profiler'
' -detailLevel mini SPHardwareDataType')\
.split('\n')[4:-1]
elif platform.system() == 'FreeBSD':
opt.sys_info = commands.getoutput('sysctl hw').split('\n')
opt.sys_info = getoutput('sysctl hw').split('\n')
elif platform.system() == 'Linux':
opt.sys_info = commands.getoutput('cat /proc/cpuinfo').split('\n')
opt.sys_info = getoutput('cat /proc/cpuinfo').split('\n')

### suppress warnings in numerical computation
np.seterr(all='ignore')
Expand Down
13 changes: 8 additions & 5 deletions aif360/algorithms/inprocessing/kamfadm-2012ecmlpkdd/train_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
import argparse
import os
import platform
import commands
try:
from commands import getoutput
except ImportError:
from subprocess import getoutput
import logging
import datetime
import pickle
Expand Down Expand Up @@ -304,13 +307,13 @@ def main(opt):
opt.sys_uname = platform.uname()
if platform.system() == 'Darwin':
opt.sys_info =\
commands.getoutput('system_profiler'
' -detailLevel mini SPHardwareDataType')\
getoutput('system_profiler'
' -detailLevel mini SPHardwareDataType')\
.split('\n')[4:-1]
elif platform.system() == 'FreeBSD':
opt.sys_info = commands.getoutput('sysctl hw').split('\n')
opt.sys_info = getoutput('sysctl hw').split('\n')
elif platform.system() == 'Linux':
opt.sys_info = commands.getoutput('cat /proc/cpuinfo').split('\n')
opt.sys_info = getoutput('cat /proc/cpuinfo').split('\n')

### suppress warnings in numerical computation
np.seterr(all='ignore')
Expand Down
18 changes: 10 additions & 8 deletions aif360/algorithms/inprocessing/prejudice_remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- kamfadm-2012ecmlpkdd/train_lr.py
- kamfadm-2012ecmlpkdd/train_nb.py
* fixed typo in kamfadm-2012ecmlpkdd/fadm/lr/pr.py:244 (typeError -> TypeError)
* removed commands.py and instead use subprocess.getoutput if commands is
not available
Notes from fairness-comparison's KamishimaAlgorithm.py on changes made to
original Kamishima code.
Expand Down Expand Up @@ -187,10 +189,10 @@ def create_file_in_kamishima_format(df):
k_path = os.path.dirname(os.path.abspath(__file__))
#changed paths in the calls below to (a) specify path of train_pr,predict_lr RELATIVE to this file, and (b) compute & use absolute path, and (c) replace python3 with python
subprocess.call(['python', os.path.join(k_path, 'kamfadm-2012ecmlpkdd', 'train_pr.py'),
'-e', str(eta_val),
'-i', train_name,
'-o', model_name,
'--quiet'])
'-e', str(eta_val),
'-i', train_name,
'-o', model_name,
'--quiet'])
os.unlink(train_name)
#os.unlink(model_name)

Expand Down Expand Up @@ -229,10 +231,10 @@ def create_file_in_kamishima_format(df):
k_path = os.path.dirname(os.path.abspath(__file__))
#changed paths in the calls below to (a) specify path of train_pr,predict_lr RELATIVE to this file, and (b) compute & use absolute path, and (c) replace python3 with python
subprocess.call(['python', os.path.join(k_path, 'kamfadm-2012ecmlpkdd', 'predict_lr.py'),
'-i', test_name,
'-m', self.model_name,
'-o', output_name,
'--quiet'])
'-i', test_name,
'-m', self.model_name,
'-o', output_name,
'--quiet'])

#os.unlink(model_name)
os.unlink(test_name)
Expand Down

0 comments on commit 9a34701

Please sign in to comment.