Skip to content
Snippets Groups Projects
Commit 5180b4db authored by René Schöne's avatar René Schöne
Browse files

Little restructuring.

parent b0a3fce7
Branches
No related tags found
No related merge requests found
......@@ -2,13 +2,20 @@
# terms of the MIT license (X11 license) which accompanies this distribution.
# Author: R. Schoene
import os
RACR_HOME = "$HOME/git/2bt/racr/racr/"
PROGRAM_HOME = "$HOME/git/racr-mquat/"
PROGRAM_PACKAGE = "mquat"
class Bin(object):
def __init__(self, racr_bin, mquat_bin):
def __init__(self, racr_bin, program_bin):
self.racr_bin = racr_bin
self.mquat_bin = mquat_bin
self.program_bin = program_bin
racketBin = Bin("$HOME/git/2bt/racr/racr/racket-bin", "$HOME/git/racr-mquat/racket-bin")
larcenyBin = Bin("$HOME/git/2bt/racr/racr/larceny-bin", "$HOME/git/racr-mquat/larceny-bin")
racketBin = Bin(os.path.join(RACR_HOME, "racket-bin"), os.path.join(PROGRAM_HOME, "racket-bin"))
larcenyBin = Bin(os.path.join(RACR_HOME, "larceny-bin"), os.path.join(PROGRAM_HOME, "larceny-bin"))
##racketExec = "$HOME/git/racket/racket/bin/plt-r6rs"
racketExec = "plt-r6rs"
......
......@@ -2,12 +2,10 @@
# terms of the MIT license (X11 license) which accompanies this distribution.
# Author: R. Schoene
import utils
import properties, utils, install, sockets
import ilp_test as test
import ilp_measurement as measure
import ilp_check as check
import install
import sockets
import os
from fabric.api import local, task, get, hosts, run
......
......@@ -15,8 +15,9 @@ try:
# from fabric.contrib.console import confirm
except ImportError:
from fabric_workaround import task, red, lcd, green
import utils, properties
from utils import local_quiet, call_racket, call_larceny, assertTrue, secure_remove
import utils
from utils import local_quiet, call_racket, call_larceny, assertTrue, assertTrueAssertion, secure_remove
from properties import timing, log_info, log_debug, lp_write, profiling, flushed, noncached, preesleep, items
assertTrue = utils.assertTrueAssertion
......@@ -463,33 +464,6 @@ def prepare_normal():
local_quiet('sed -i "s/measure.non-cached = 1/measure.non-cached = 0/" scheme.properties', capture = False)
local_quiet('make racket', capture = False)
@task
def check():
""" Checks dependencies.txt and scheme.properties """
def nc_tostring(val):
return red('non-cached') if val else 'cached'
noncached_scm = False
with open('dependencies.txt') as fd:
if 'ilp-noncached\n' in fd:
noncached_scm = True
print '\n- '.join(( 'Evaluation is set to:',
red('non-cached') if properties.noncached.value else 'cached',
red('flushed') if properties.flushed.value else 'unflushed',
(green('Yes: ') if properties.timing.value else 'No ') + 'measurement of execution times',
(green('Yes: ') if properties.profiling.value else 'No ') + 'profiling of attribute metrics',
(green('Yes: ') if properties.lp_write.value else 'No ') + 'write of LP files',
'Wait {0} second(s) before each experiment'.format(properties.preesleep.value)))
if noncached_scm != properties.noncached.value:
print 'Attention: Compiled ilp ({}) differs from properties file setting ({}).'.format(
nc_tostring(noncached_scm), nc_tostring(properties.noncached.value))
if properties.timing.value and properties.profiling.value:
print 'Attention: Both, enabled profiling will influence timing.'
if properties.flushed.value and properties.noncached.value:
print 'Disabling "flushed", as noncached is enabled'
properties.flushed.value = False
if not (properties.timing.value or properties.lp_write.value or properties.profiling.value):
print 'Nothing is done or measured, either set timing, lp_write or profiling'
@task
def help():
print 'Measurement driver for racr-mquat'
......@@ -499,42 +473,6 @@ def help():
print '4. (Mandatory) Execute distinction-of-changes, to create splitted csv files'
print '5. (Optional) Rerun notebook to update diagrams'
def confirm(question, default_val = False):
prompt = question
if isinstance(default_val, bool):
prompt += ' [{0}]'.format('Y/n' if default_val else 'y/N')
answer = raw_input(prompt + ' ')
if answer == '':
answer = default_val
if isinstance(default_val, bool):
return answer in ('y','Y','yes','Yes',True)
if isinstance(default_val,int):
return int(answer)
return answer
@task
def setup(name = None, to_default = False):
"""
Interactive setup of all settings or given specific one.
Overrides the file "scheme.properties"
"""
def default_val(item):
return item.default if to_default else item.value
def confirm_s(wanted, item):
if not wanted or item.name.startswith(wanted):
return confirm(item.question, default_val(item))
return default_val(item)
for p in properties.items:
p.value = confirm_s(name, p)
# consistency checking
check()
for p in properties.items:
p.write_value()
print 'Remember to invoke prepare-{} if noncached setting was changed'.format(
'noncached' if properties.noncached.value else 'normal')
@task(name = 'new-measurements')
def new_measurements():
result = execute(get_remote_measurements)
......
......@@ -7,7 +7,7 @@ try:
from fabric.api import lcd, task
except ImportError:
from fabric_workaround import lcd, task
from constants import racketBin, larcenyBin, racketExec, larcenyExec
from constants import racketBin, larcenyBin, racketExec, larcenyExec, PROGRAM_PACKAGE
from utils import local_quiet
def parse(names = None):
......@@ -29,7 +29,7 @@ def compile_racket(*names):
""" Compile every listed source for Racket.
If none given, compile each dependency. """
for name in parse(names):
output = 'racket-bin/mquat/{0}'.format('main_.ss' if name == 'main.scm' else (name[:-2] + 's'))
output = 'racket-bin/{0}/{1}'.format(PROGRAM_PACKAGE, 'main_.ss' if name == 'main.scm' else (name[:-2] + 's'))
if os.path.exists(output):
os.remove(output)
local_quiet('{0} ++path {1} --install --collections racket-bin {2}'.
......@@ -45,7 +45,7 @@ compile_stale_text = """#!r6rs
@task(name = 'larceny')
def compile_larceny():
""" Compile each dependency for larceny """
larceny_dir = 'larceny-bin/mquat'
larceny_dir = 'larceny-bin/' + PROGRAM_PACKAGE
compile_stale = 'compile-stale'
if not os.path.exists(larceny_dir):
os.makedirs(larceny_dir)
......
......@@ -3,6 +3,11 @@
# Author: R. Schoene
from utils import local_quiet
try:
from fabric.api import task
from fabric.colors import red, green
except ImportError:
from fabric_workaround import task, red, green
properties_fname = 'scheme.properties'
......@@ -55,3 +60,66 @@ with open(properties_fname) as fd:
print 'Could not find property for {}'.format(key)
else:
item.value = value
def confirm(question, default_val = False):
prompt = question
if isinstance(default_val, bool):
prompt += ' [{0}]'.format('Y/n' if default_val else 'y/N')
answer = raw_input(prompt + ' ')
if answer == '':
answer = default_val
if isinstance(default_val, bool):
return answer in ('y','Y','yes','Yes',True)
if isinstance(default_val,int):
return int(answer)
return answer
@task
def check():
""" Checks dependencies.txt and scheme.properties """
def nc_tostring(val):
return red('non-cached') if val else 'cached'
noncached_scm = False
with open('dependencies.txt') as fd:
if 'ilp-noncached\n' in fd:
noncached_scm = True
print '\n- '.join(( 'Evaluation is set to:',
red('non-cached') if noncached.value else 'cached',
red('flushed') if flushed.value else 'unflushed',
(green('Yes: ') if timing.value else 'No ') + 'measurement of execution times',
(green('Yes: ') if profiling.value else 'No ') + 'profiling of attribute metrics',
(green('Yes: ') if lp_write.value else 'No ') + 'write of LP files',
'Wait {0} second(s) before each experiment'.format(preesleep.value)))
if noncached_scm != noncached.value:
print 'Attention: Compiled ilp ({}) differs from properties file setting ({}).'.format(
nc_tostring(noncached_scm), nc_tostring(noncached.value))
if timing.value and profiling.value:
print 'Attention: Both, enabled profiling will influence timing.'
if flushed.value and noncached.value:
print 'Disabling "flushed", as noncached is enabled'
flushed.value = False
if not (timing.value or lp_write.value or profiling.value):
print 'Nothing is done or measured, either set timing, lp_write or profiling'
@task
def setup(name = None, to_default = False):
"""
Interactive setup of all settings or given specific one.
Overrides the file "scheme.properties"
"""
def default_val(item):
return item.default if to_default else item.value
def confirm_s(wanted, item):
if not wanted or item.name.startswith(wanted):
return confirm(item.question, default_val(item))
return default_val(item)
for p in items:
p.value = confirm_s(name, p)
# consistency checking
check()
for p in items:
p.write_value()
print 'Remember to invoke prepare-{} if noncached setting was changed'.format(
'noncached' if noncached.value else 'normal')
......@@ -38,12 +38,12 @@ def local_quiet(cmd, abort_on_stderr = False, capture = True):
def call_racket(f, *args, **kwargs):
return local_quiet('{0} ++path {1} ++path {2} {3} {4}'.format(racketExec,
racketBin.racr_bin, racketBin.mquat_bin, f, ' '.join(str(x) for x in args)),
racketBin.racr_bin, racketBin.program_bin, f, ' '.join(str(x) for x in args)),
capture = kwargs.get('capture', True))
def call_larceny(f, *args, **kwargs):
return local_quiet('{0} --r6rs --path {1}:{2} --program {3} -- {4}'.format(larcenyExec,
larcenyBin.racr_bin, larcenyBin.mquat_bin, f, ' '.join(str(x) for x in args)),
larcenyBin.racr_bin, larcenyBin.program_bin, f, ' '.join(str(x) for x in args)),
abort_on_stderr = True, capture = kwargs.get('capture', True))
def secure_remove(spec, globbing = False, dryrun = False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment