Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F75560658
manual.tex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 2, 23:32
Size
6 KB
Mime Type
text/x-tex
Expires
Sun, Aug 4, 23:32 (2 d)
Engine
blob
Format
Raw Data
Handle
19568310
Attached To
R3127 blackdynamite
manual.tex
View Options
\documentclass
[openright,a4paper,9pt,fleqn]
{
manual
}
\usepackage
{
manual
}
\usepackage
{
manual-macros
}
\setlength
{
\oddsidemargin
}{
-1cm
}
% Marge gauche sur pages impaires
\setlength
{
\evensidemargin
}{
-1cm
}
% Marge gauche sur pages paires
\setlength
{
\marginparwidth
}{
0cm
}
% Largeur de note dans la marge
\setlength
{
\textwidth
}{
18cm
}
% Largeur de la zone de texte (17cm)
\setlength
{
\marginparsep
}{
0pt
}
% Separation de la marge
\setlength\parindent
{
0pt
}
\author
{}
\date
{}
\newcommand
{
\version
}{
0.1
}
\newcommand
{
\blackdynamite
}{
\textbf
{
BlackDynamite
}
\xspace
}
\title
{
\textbf
{
\Huge
\blackdynamite
}
\\
\vspace
{
0.5cm
}
\textbf
{
\huge
User's Guide
}
\\
\vspace
{
1cm
}
{
\small
\today
{}
--- Version
\version
}
}
\begin
{
document
}
\setcounter
{
page
}{
1
}
\renewcommand
{
\thepage
}{
\roman
{
page
}}
\pdfbookmark
[0]
{
Titlepage
}{
maintitlepage
}
\label
{
maintitlepage
}
\maketitle
\tableofcontents
\ifodd\value
{
page
}
\insertblankpage
\else
\insertblankpage\insertblankpage
\fi
\setcounter
{
page
}{
1
}
\renewcommand\thepage
{
\arabic
{
page
}}
\chapter
{
Installing and compiling
}
\chapter
{
Introduction and philosophy
}
\chapter
{
Setting up a parametric study
}
\section
{
Database setup
}
The first thing to do is to setup the database. For this to be done
you need, first of all, to list all the parameters that decide
a specific case/computation. This parameters can be of simple types
like string, integers, floats, etc. At current time no vectorial
quantity can be considered as an input parameter.
Once this list is done you need to create a script, usually named
\code
{
createDB.py
}
that will do this task. Let us examine such an example script.
\\
First we need to set the python headers and to import the
\blackdynamite
modules by
\begin
{
command
}
#!/usr/bin/env python
import base
import job
import run
import psycopg2
import sys
\end
{
command
}
Then you have to create a connection to the database
\begin
{
command
}
connection = psycopg2.connect(host = "lsmssrv1")
\end
{
command
}
Then you have to create a new job description and add parameters.
For instance with int and float parameters as presented below.
\begin
{
command
}
myjob
_
desc = job.Job()
myjob
_
desc.types["param1"] = int
myjob
_
desc.types["param2"] = int
\end
{
command
}
Then you have to create and describe your runs
\begin
{
command
}
myruns
_
desc = run.Run()
myruns
_
desc.types["compiler"]
\end
{
command
}
The default entries of a run are
\begin
{
itemize
}
\item
machine
\_
name: the name of the machine where the run must be executed
\item
job
\_
id (integer): the ID of the running job
\item
has
\_
started (bool): flag to know whether the job has already started
\item
has
\_
finished (bool): flag to know whether the job has already finished
\item
run
\_
name (string): the name of the run
\item
wait
\_
id (int): The id of a run to wait before starting
\item
start
\_
time (TIMESTAMP): The start time for the run
\end
{
itemize
}
Then you have to push these informations to the database
\begin
{
command
}
base = base.Base("MySuperCoolStudy",connection)
base.createSchema()
base.createTable(myjob
_
desc)
base.createTable(myruns
_
desc)
base.createGenericTables()
\end
{
command
}
Then, you have to push the quantitites
that your program will measure and will push to the
database
\begin
{
command
}
base.pushQuantity("Quantity1","float")
base.pushQuantity("Quantity2","float")
\end
{
command
}
Finally you have to commit every change to the database
\begin
{
command
}
connection.commit()
\end
{
command
}
\section
{
Creating the jobs
}
Since jobs represent the part of the parametric space
that need to be explored we need a script to generate it.
We start by now the usual headers
\begin
{
command
}
#!/usr/bin/env python
import base
import job
import run
import sys
import psycopg2
connection = psycopg2.connect(host = "lsmssrv1")
base = base.Base("MySuperCoolStudy",connection)
\end
{
command
}
Then I need to create a job
\begin
{
command
}
jobs = job.Job()
jobs.prepare(base)
\end
{
command
}
the prepare method is filling the fields of the jobs
with default values. It is up to you to generate the needed
values and insert the jobs to the base
\begin
{
command
}
jobs["param1"] = 1
for seed in range(0, 500, 10):
jobs["param2"] = seed
base.insert(jobs)
connection.commit()
\end
{
command
}
\section
{
Creating the runs and launching them
}
At this point the jobs are in the database. You need to create runs
that will precise the condition of the run. For example the machine onto
which the job will run, path dependent information, executable information and others.
We start with the headers
\begin
{
command
}
#!/usr/bin/env python
import base
import job
import run
import psycopg2
import sys
import socket
hostname = socket.gethostname()
connection = psycopg2.connect(host = hostname)
base = base.Base("MySuperCoolStudy",connection)
\end
{
command
}
The we set the standard options of the run
\begin
{
command
}
myrun = run.Run()
myrun.prepare(base)
myrun["machine
_
name"] = hostname
myrun["run
_
name"] = "MySuperCoolStudy"
\end
{
command
}
Then we retreive the list of jobs and create runs associated
\begin
{
command
}
job
_
list = base.getObjectList(job.Job())
for j in job
_
list:
if (criterion(j)):
myrun.attachToJob(j)
base.insert(myrun)
print (j.entries)
\end
{
command
}
When done, from a given host you can call
\begin
{
command
}
> pyton launchJobs.py MySuperCoolStudy
\end
{
command
}
to launch locally the jobs
\chapter
{
Instrumenting the a simulation code
}
Within you program you need a pusher correctly initialized
in order to push data to the database.
\\
First
\blackdynamite
includes are required:
\begin
{
cpp
}
#include "pusher.hh"
\end
{
cpp
}
Then you need to create a Pusher object and initialize it.
\begin
{
cpp
}
BlackDynamite::Pusher bd;
bd.init();
\end
{
cpp
}
The constructor by default reads environment variables to get
the database connection and schema informations:
\begin
{
itemize
}
\item
RUN
\_
ID: the identifier of the runid
\item
SCHEMA: the schema where the parametric study is to be stored
\item
HOST: the database hostname
\end
{
itemize
}
Then in the places where values are created
you push the values to the database
\begin
{
cpp
}
bd.push(val1,"quantity1",step);
bd.push(val2,"quantity2",step);
\end
{
cpp
}
Step is a stage identifier. It can be the step index within an
explicit loop, or a within a convergence descent or whatever you whish.
It will serve later to compare quantity entries.
Finally, when the job ended the following call inform the database that the run is finished:
\begin
{
cpp
}
bd.endRun();
\end
{
cpp
}
\chapter
{
Instrumenting a python script
}
\chapter
{
Useful Postgresql commands
}
How to list the available schemas ?
\begin
{
command
}
>
\dn
\end
{
command
}
How to get into the schema ?
\begin
{
command
}
> set search path to schema
_
name;
\end
{
command
}
How to list all the tables ?
\begin
{
command
}
>
\d
\end
{
command
}
How to list entries from a table ?
\begin
{
command
}
> SELECT * from table
_
name ;
\end
{
command
}
\end
{
document
}
Event Timeline
Log In to Comment