mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-05 10:40:06 +01:00
osaca now writes and reads from data files in ~/.osaca
This commit is contained in:
@@ -26,8 +26,9 @@ class Scheduler(object):
|
||||
print('Architecture not supportet for EU scheduling.', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
self.instrList = instruction_list
|
||||
curr_dir = os.path.realpath(__file__)[:-11]
|
||||
self.df = pd.read_csv(curr_dir + 'data/' + arch.lower() + '_data.csv', quotechar='"',
|
||||
#curr_dir = os.path.realpath(__file__)[:-11]
|
||||
osaca_dir = os.path.expanduser('~/.osaca/')
|
||||
self.df = pd.read_csv(osaca_dir + 'data/' + arch.lower() + '_data.csv', quotechar='"',
|
||||
converters={'ports': ast.literal_eval})
|
||||
def new_schedule(self):
|
||||
"""
|
||||
|
||||
@@ -24,6 +24,7 @@ class Osaca(object):
|
||||
instr_forms = None
|
||||
tp_list = False
|
||||
file_output = ''
|
||||
osaca_dir = os.path.expanduser('~') + '/.osaca/'
|
||||
# Variables for checking lines
|
||||
numSeps = 0
|
||||
indentChar = ''
|
||||
@@ -48,6 +49,14 @@ class Osaca(object):
|
||||
self.filepath = _filepath
|
||||
self.instr_forms = []
|
||||
self.file_output = output
|
||||
# Check if data files are already in usr dir, otherwise create them
|
||||
if(not os.path.isdir(self.osaca_dir + 'data')):
|
||||
print('Copying files in user directory...', file=self.file_output, end='')
|
||||
subprocess.call(['mkdir', '-p', self.osaca_dir])
|
||||
subprocess.call(['cp', '-r',
|
||||
'/'.join(os.path.realpath(__file__).split('/')[:-1]) + '/data',
|
||||
self.osaca_dir])
|
||||
print('Done!', file=self.file_output)
|
||||
|
||||
# -----------------main functions depending on arguments--------------------
|
||||
def include_ibench(self):
|
||||
@@ -283,8 +292,8 @@ class Osaca(object):
|
||||
DataFrame
|
||||
CSV as DataFrame object
|
||||
"""
|
||||
curr_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1])
|
||||
df = pd.read_csv(curr_dir+'/data/'+self.arch.lower()+'_data.csv')
|
||||
#curr_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1])
|
||||
df = pd.read_csv(self.osaca_dir+'data/'+self.arch.lower()+'_data.csv')
|
||||
return df
|
||||
|
||||
def write_csv(self, csv):
|
||||
@@ -296,12 +305,12 @@ class Osaca(object):
|
||||
csv : str
|
||||
CSV data as string
|
||||
"""
|
||||
curr_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1])
|
||||
#curr_dir = '/'.join(os.path.realpath(__file__).split('/')[:-1])
|
||||
try:
|
||||
f = open(curr_dir+'/data/'+self.arch.lower()+'_data.csv', 'w')
|
||||
f = open(self.osaca_dir+'data/'+self.arch.lower()+'_data.csv', 'w')
|
||||
except IOError:
|
||||
print('IOError: file \'{}\' not found in ./data'.format(self.arch.lower()+'_data.csv'),
|
||||
file=self.file_output)
|
||||
print('IOError: file \'{}\' not found in $HOME/.osaca/data'.format(self.arch.lower()
|
||||
+ '_data.csv'), file=self.file_output)
|
||||
f.write(csv)
|
||||
f.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user