def _setup_env(): sysinfo = _get_ubuntu_info() # dotfiles run( '[ ! -f ~/.tmux.conf ] && { ' 'git clone -b minimal --single-branch --recursive ' 'https://github.com/ichuan/dotfiles.git ' "&& echo 'y' | bash dotfiles/bootstrap.sh; }", warn_only=True) # UTC timezone sudo('cp /usr/share/zoneinfo/UTC /etc/localtime', warn_only=True) # limits.conf, max open files _limits() # rc.local after 15.04 # https://wiki.ubuntu.com/SystemdForUpstartUsers if _V(sysinfo['release']) >= _V('15.04'): _enable_rc_local() # sysctl.conf _sysctl() # disable ubuntu upgrade check sudo( "sed -i 's/^Prompt.*/Prompt=never/' " "/etc/update-manager/release-upgrades", warn_only=True) # douban pip config run('mkdir -p ~/.pip', warn_only=True) run(r'echo -e "[global]\nindex-url = https://pypi.douban.com/simple\n' r'trusted-host = pypi.douban.com" > ~/.pip/pip.conf')
def _setup_mariadb(): ''' can be used to migrate mysql to mariadb ''' if run('test -f /etc/mysql/conf.d/mariadb.cnf ', warn_only=True).succeeded: print 'Already installed mariadb' return # user/password => root/root sudo("debconf-set-selections <<< 'mariadb-server mysql-server/" "root_password password root'") sudo("debconf-set-selections <<< 'mariadb-server mysql-server/" "root_password_again password root'") # https://mariadb.com/kb/en/mariadb/installing-mariadb-deb-files/ sysinfo = _get_ubuntu_info() key = '0xcbcb082a1bb943db' if _V(sysinfo['release']) >= _V('16.04'): key = '0xF1656F24C74CD1D8' sudo('apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 %s' % key) sudo('apt-get install -yq software-properties-common') sudo("add-apt-repository -y 'deb http://ftp.osuosl.org/pub/mariadb/repo/" "10.2/ubuntu %s main'" % sysinfo['codename']) sudo('apt-get update -yq') sudo('service mysql stop', warn_only=True) sudo('apt-get install -yq mariadb-server libmysqld-dev', warn_only=True)
import json import os import sys from distutils.version import LooseVersion as _V from fabric.api import cd, env, get, lcd, local, prefix, run, sudo from fabric.context_managers import shell_env from version import VERSION version = _V(VERSION) env.hosts = ["systori.io"] PROD_MEDIA_PATH = "/var/lib/systori/production" PROD_MEDIA_FILE = "systori.media.tgz" def prepare(service, branch): "copy database and migrate" settings = { "HOST": "db", "NAME": "systori_{}".format(service), "USER": "******" } if service != "production": local("dropdb -h {HOST} -U {USER} {NAME}".format(**settings)) local( "createdb -T systori_production -h {HOST} -U {USER} {NAME}".format(
import sympy as sp import re from sympy.core.function import AppliedUndef as _AppliedUndef from sympy.printing import StrPrinter as _StrPrinter from sympy.printing.ccode import CCodePrinter as _CCodePrinter from sympy.printing.latex import LatexPrinter as _LatexPrinter from sympy.printing.latex import latex as _sympy_latex from sympy.printing.precedence import precedence as _precedence from modelparameters.utils import check_arg as _check_arg from modelparameters.utils import scalars as _scalars from distutils.version import LooseVersion as _V _current_sympy_version = _V(sp.__version__) # Check version for order arguments if _current_sympy_version >= _V("0.7.2"): _order = "none" else: _order = None # A collection of language specific keywords _cpp_keywords = ["auto", "const", "double", "float", "int", "short", "struct", "break", "continue", "else", "for", "long", "signed", "switch", "case", "default", "enum", "goto", "register", "sizeof", "typedef", "char", "do", "extern", "if", "return", "static", "union", "while", "asm", "dynamic_cast", "namespace", "reinterpret_cast", "try", "bool", "explicit", "new", "static_cast", "typeid", "volatile", "catch", "operator", "template", "typename",
def _default_params(exclude=None): exclude = exclude or [] check_arg(exclude, list, itemtypes=str) # Add not implemented parameters to excludes exclude += ["max_terms", "parameter_contraction", "use_variables"] # Build a dict with allowed parameters params = {} if "use_state_names" not in exclude: # Use state names in code (compared to array with indices) params["use_state_names"] = Param( True, description="Use state names in code " "(compared to array with indices)", ) if "use_parameter_names" not in exclude: # Use parameter names in code (compared to array with indices) params["use_parameter_names"] = Param( True, description="Use parameter names " "in code (compared to array with indices)", ) if "keep_intermediates" not in exclude: # Keep all intermediates params["keep_intermediates"] = Param( True, description="Keep intermediates in code", ) if "use_variables" not in exclude: # If True, code for altering variables are created # FIXME: Not used params["use_variables"] = Param( False, description="If True, code for altering variables are created", ) if "parameter_contraction" not in exclude: # Find sub expressions of only parameters and create a dummy parameter # FIXME: Not used params["parameter_contraction"] = Param( False, description="Find sub expressions of only parameters " "and create a dummy parameter", ) if "parameter_numerals" not in exclude: # Exchange all parameters with their initial numerical values params["parameter_numerals"] = Param( False, description="Exchange all parameters with their initial" " numerical values", ) if "max_terms" not in exclude: # Split terms with more than max_terms into several evaluations # FIXME: Not used params["max_terms"] = ScalarParam( 5, ge=2, description="Split terms with more than max_terms " "into several evaluations", ) if "use_cse" not in exclude: # Use sympy common sub expression simplifications, # only when keep_intermediates is false params["use_cse"] = Param( False, description="Use sympy common sub expression " "simplifications, only when keep_intermediates is false", ) if "generate_jacobian" not in exclude: # Generate code for the computation of the jacobian params["generate_jacobian"] = Param( True, description="Generate code for the computation of the jacobian", ) if "transposed_jacobian" not in exclude: # Generate code for the computation of the jacobian params["transposed_jacobian"] = Param( False, description="The Jacobian is transposed", ) if "generate_lu_factorization" not in exclude: # Generate code for the factorization of the jacobian params["generate_lu_factorization"] = Param( True, description="Generate code for the factorization of the jacobian", ) if "generate_forward_backward_subst" not in exclude: # Generate code for the forward backward substitution code params["generate_forward_backward_subst"] = Param( True, description= "Generate code for the forward backward substitution code", ) if "generate_linearized_evaluation" not in exclude: # Generate code for linearized evaluation # For sympy versions lower than 0.7.2 linearized computation does not work default_linearized_evaluation = _current_sympy_version > _V("0.7.2") params["generate_linearized_evaluation"] = Param( default_linearized_evaluation, description="Generate code for linearized evaluation", ) # Return the ParameterDict return ParameterDict(**params)
from modelparameters.parameterdict import ScalarParam from modelparameters.sympy import cse from modelparameters.sympytools import iter_symbol_params_from_expr from modelparameters.sympytools import sp from modelparameters.utils import check_arg from modelparameters.utils import check_kwarg from ..model.ode import ODE from ..model.odecomponent import Comment from ..model.odecomponent import ODEComponent # System imports # Model parametrs imports # Local gotran imports _current_sympy_version = _V(sp.__version__) _jacobian_pattern = re.compile("_([0-9]+)") def _iszero(x): """Returns True if x is zero.""" x = sp.sympify(x) return x.is_zero def _default_params(exclude=None): exclude = exclude or [] check_arg(exclude, list, itemtypes=str) # Add not implemented parameters to excludes exclude += ["max_terms", "parameter_contraction", "use_variables"]