update slurm template and tunnel/mysql config

This commit is contained in:
2020-12-24 12:55:16 +01:00
parent 159e75410d
commit 6d0e7d1297
7 changed files with 34 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
host=<server>
port=tunnel
user=stree
password=<password>
database=stree_experiments

View File

@@ -1,4 +1,5 @@
ssh_address_or_host=(<host>, <port>)
ssh_username=<user>
ssh_private_key=<path_to>/id_rsa
remote_bind_address=('127.0.0.1', 3306)
remote_bind_address=('127.0.0.1', 3306)
enabled=1

View File

@@ -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):

View File

@@ -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 "<experiment>-<data>-<model>-<kernel>" # 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 <folder>

0
scripts/killall.sh → scripts/killall_pbs.sh Normal file → Executable file
View File

View File

@@ -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