diff --git a/constants.py b/constants.py index 8e5849197d85ae588cf0288abc8c90da7ba2f978..acbc30d0c85c3855ce1d09e211b05ecda348743e 100644 --- a/constants.py +++ b/constants.py @@ -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" diff --git a/fabfile.py b/fabfile.py index f146150834ea6e1bfb73ff203b8ad89fb9ebe8db..c95b4d55e591286f7e2f5edb669cbf5a279f0a12 100644 --- a/fabfile.py +++ b/fabfile.py @@ -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 diff --git a/ilp_measurement.py b/ilp_measurement.py index cea63bd7babf3ed7f21d9bcae48a42942a39521b..e26e690f0ff248014b11366c5930f9ea1b5ef5a2 100644 --- a/ilp_measurement.py +++ b/ilp_measurement.py @@ -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) diff --git a/install.py b/install.py index fbce5f434d06bc5135ffb4bd673e3f9db072e856..992d6e41875863d00eecdecc440abd1efc75301c 100644 --- a/install.py +++ b/install.py @@ -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) diff --git a/properties.py b/properties.py index 8b42e349d2c5ee552e5c26643ce794122e652d7e..f64854ab03ab669372dc3a478fd686dbb3e9579e 100644 --- a/properties.py +++ b/properties.py @@ -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') diff --git a/utils.py b/utils.py index e3f61f261b3bde21a8f72c21d66eddd4285be83e..4bf904cf29a63918c4a4c2229f5f2ef9acef5264 100644 --- a/utils.py +++ b/utils.py @@ -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):