diff --git a/experimentation/.myconfig.dist b/experimentation/.myconfig.dist index a50ea24..adcb49d 100644 --- a/experimentation/.myconfig.dist +++ b/experimentation/.myconfig.dist @@ -1,4 +1,5 @@ host= +port=tunnel user=stree password= database=stree_experiments \ No newline at end of file diff --git a/experimentation/.tunnel.dist b/experimentation/.tunnel.dist index 6dab163..8bd2186 100644 --- a/experimentation/.tunnel.dist +++ b/experimentation/.tunnel.dist @@ -1,4 +1,5 @@ ssh_address_or_host=(, ) ssh_username= ssh_private_key=/id_rsa -remote_bind_address=('127.0.0.1', 3306) \ No newline at end of file +remote_bind_address=('127.0.0.1', 3306) +enabled=1 \ No newline at end of file diff --git a/experimentation/Database.py b/experimentation/Database.py index a7a2ee9..8e2ada5 100644 --- a/experimentation/Database.py +++ b/experimentation/Database.py @@ -13,14 +13,13 @@ from .Utils import TextColor class MySQL: def __init__(self): self._server = None - - def get_connection(self): - config_db = dict() + self._tunnel = False + self._config_db = dict() dir_path = os.path.dirname(os.path.realpath(__file__)) with open(os.path.join(dir_path, ".myconfig")) as f: for line in f.read().splitlines(): key, value = line.split("=") - config_db[key] = value + self._config_db[key] = value config_tunnel = dict() with open(os.path.join(dir_path, ".tunnel")) as f: for line in f.read().splitlines(): @@ -32,11 +31,17 @@ class MySQL: config_tunnel["ssh_address_or_host"] = make_tuple( config_tunnel["ssh_address_or_host"] ) - self._server = SSHTunnelForwarder(**config_tunnel) - self._server.daemon_forward_servers = True - self._server.start() - config_db["port"] = self._server.local_bind_port - self._database = mysql.connector.connect(**config_db) + self._tunnel = config_tunnel["enabled"] == "1" + if self._tunnel: + del config_tunnel["enabled"] + self._server = SSHTunnelForwarder(**config_tunnel) + self._server.daemon_forward_servers = True + + def get_connection(self): + if self._tunnel: + self._server.start() + self._config_db["port"] = self._server.local_bind_port + self._database = mysql.connector.connect(**self._config_db) return self._database def find_best(self, dataset, classifier="any"): @@ -60,7 +65,8 @@ class MySQL: return cursor.fetchone() def close(self): - self._server.close() + if self._tunnel: + self._server.close() class BD(ABC): diff --git a/scripts/experiment.slurm b/scripts/experiment.slurm index 5951c83..8630d1c 100644 --- a/scripts/experiment.slurm +++ b/scripts/experiment.slurm @@ -1,13 +1,11 @@ #!/bin/bash -#SBATCH --time=96:00:00 # walltime +#SBATCH --partition=qdata #SBATCH --ntasks=4 # number of processor cores (i.e. tasks) #SBATCH --nodes=1 # number of nodes -#SBATCH --mem-per-cpu=4096M # memory per CPU core #SBATCH -J "---" # job name #SBATCH --mail-user=ricardo.montanana@alu.uclm.es # email address -#SBATCH --mail-type=END -#SBATCH --mail-type=FAIL +#SBATCH --mail-type=END,FAIL # LOAD MODULES, INSERT CODE, AND RUN YOUR PROGRAMS HERE cd diff --git a/scripts/interactive.sh b/scripts/interactive_pbs.sh similarity index 100% rename from scripts/interactive.sh rename to scripts/interactive_pbs.sh diff --git a/scripts/killall.sh b/scripts/killall_pbs.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/killall.sh rename to scripts/killall_pbs.sh diff --git a/scripts/launchsome.sh b/scripts/launchsome.sh index 9bf893b..396be07 100755 --- a/scripts/launchsome.sh +++ b/scripts/launchsome.sh @@ -1,10 +1,11 @@ #!/bin/bash -if [ "$1" = "" -o "$2" = "" -o "$3" = "" -o "$4" = "" ] ; then +if [ "$1" = "" -o "$2" = "" -o "$3" = "" -o "$4" = "" -o "$5" = "" ] ; then echo "Hay que seleccionar:" echo " - el tipo de experimento {gridsearch, gridbest, cross}" echo " - el modelo {stree, adaBoost, bagging, odte}" echo " - el kernel {linear, poly, rbf, any}" echo " - el archivo con nombres de datasets" + echo " - el tipo de plataforma {pbs, slurm}" echo "opcionalmente al final: dry-run" exit 1 fi @@ -20,16 +21,25 @@ if [[ ! "linearpolyrbfany" == *$3* ]] ; then echo "Hay que seleccionar el kernel {linear, poly, rbf, any}" exit 1 fi +if [[ ! "pbsslurm" == *$4* ]] ; then + echo "Hay que especificar la plataforma {pbs, slurm}" + exit 1 +fi +if [ $4 = "pbs" ] ; then + launcher="qsub" +else + launcher="sbatch" +fi script_path="$(pwd)" cd $1/$2/$3 counter=0 -lines="$(cat $script_path/$4|cut -d " " -f 2|tail -49)" +lines="$(cat $script_path/$5|cut -d " " -f 2|tail -49)" for a in $lines; do echo "launch experiment_$a.sh" if [ "$5" = "dry-run" ] ; then echo "not launched" else - qsub experiment_$a.sh + $launcher experiment_$a.sh fi let counter++ done