Pascal=Python Analysis and SQL Computation and Logic.
If you are unfamiliar with docker see my Docker_Tutorials_V2.pdf (also if you want Dockerfile_tutorials_V1.pdf, docker_run_tutorials_V1.pdf. This assumes you don't have a mac with the recent M1 chip (blame Apple)
Step 1: Pull the image
docker pull alialkadhim/pascal
Step 2: Run the image in an interactive container:
sudo docker run --net=host -e DISPLAY=$DISPLAY --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --volume="/tmp/.X11-unix:/tmp/.X11-unix" -p 8888:8888 -it alialkadhim/pascal /bin/bash
Step 3: Now you're inside the docker container. Your working directory is /home/: See what's there! Establish an ssh tunnel to lxplus: do the follwoing inside the docker container
*Replace aalkadhi to your lxplus username in /home/tunnel.sh and do bash tunnel.sh
tunnel.shis included out of the box in/home/directory of the docker container. If interested, the run command looks like:
#!/bin/bash
lsof -ti:10131 | xargs kill -9
ssh -4 -fNL 10131:itrac1609-v.cern.ch:10121 -L 10132:itrac1601-v.cern.ch:10121 [email protected]
Of course, type "yes" if asked "are you sure?" and enter your CERN account (lxplus) password.
Note: If you get an error
bund: address already in usethis means the initial port is already in use in the host machine. Exit the container (by typingexit) then on your host (local) machine dolsof -ti:10131 | xargs kill -9then start the container again (with thedocker runcommand in step 2.
Step 4: Inside the docker container, start a jupyterlab session using the same port forwarding (8888 in this case):
jupyter-lab --ip 0.0.0.0 --port 8888 --allow-root &
the
&at the end is so that you dont lose that terminal! (press enter in terminal to use it).
Step 5: Now in your host (local) machine, go to the url that is given to you in the docker terminal. It will say something like Or copy and paste one of these URLs:. If you have some other version of jupyterlab on your local machine, you might have to go to localhost:8888 in a browser and type the password from the docker container that is shown after ?="". Note: some other versions of jupyterlab use token instead of password, the token will be after lab?token= once you start jupyter-lab.
Step 6: Follow the HGCAL DB Python Query Tutorial in by double-clicking Pascal_jupyter_tutrial_1.ipynb in the left tab.
We will be using the python module cx_Oracle to connect and execute SQL queries for the HGCAL INT2R database. The documentation of cx_Oracle is here, but I took care of the installation/configuration, etc, so that you focus on the simplest ways that you can interact with the database.
docker run command.Put this in a file like RUN_dca_int2e-linux-gui.sh so that you don't forget these commands
#!/bin/bash
sudo docker run \
--rm \
--net=host \
-e DISPLAY=$DISPLAY \
--volume="$HOME/.Xauthority:/root/.Xauthority:rw" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix" \
-p 8888:8888 \
-it alialkadhim/pascal \
/bin/bash
and do bash RUN_dca_int2e-linux-gui.sh to run it.
Here are what the options do
-v /media/ali/DATA/DATABASE/DCA:/home/shared mounts the directory /media/ali/DATA/DATABASE/DCA on your local machine (host) to /home/shared on the Docker container (client).
-p 8000:8000 maps the 8000 port of your container to the 8000 port of your real server (the host network), i.e. publishes this port.
p flag is -p <host-port>:<container-port>.-it alialkadhim/dca_int2r:linux-gui run the alialkadhim/dca_int2r:linux-gui docker image (username alialkadhim , image name: dca_int2r , tag: linux-gui ) wich can be found on dockerhub here, interactively (meaning when you run it your shell will be inside the docker container).
-i for interactive. -t is for enabling a terminal typing interface (i.e. it makes sure the container will work as a terminal would)docker run pascal whereis Sensor ID 24958
But allow the possibility for people to enter SQL commands themselves. These commands can be inserted in the command line or called on by typing the command in .txtor.sql` file.
Each query is saved in a .sql file, and the function just opens and grabs these DONE
.sql templates. E.g. HPK data, tables other than Si sensors.DONE FOR CSV/JSON
BASICALLY DONE FOR JUPYTER
Related: see if it can talk to Phillip's Module assembly API on Openshift
Example: saying
"What baseplates and detector parts at what locations?"
Which would be translated to the correct SQL command and executed with output.
Related:
Query History/log. Maybe every time you run
execute_query()
Option to Save query if you like it, or put your own query in the queries directory as a .sql Queries. Collect info from users on how they liked it and what can be improved.
see
$DISPLAY variable pointing to the correct display (usually set to :0)$XAUTHORITY or xauth)
$XAUTHORITY should point to ~/.Xauthority.
export XAUTHORITY=~/.Xauthorityxauth list to find authentication information.You might need to install xauth so that the container can access the X server. On your host machine do
xauth list | grep `uname -n`
and copy the hex key. Then add this display with
xauth add $DISPLAY . hexkey
Note: Other ways to run a GUI inside a docker container is to use SSH with X11 forwarding, or VNC (Virtual Network Computin). See e.g. https://blog.mkari.de/posts/glx-on-mac/
--volume="/tmp/.X11-unix:/tmp/.X11-unix" is a bind mount of the X server directory to the container.
--volume="$HOME/.Xauthority:/root/.Xauthority:rw" is providing your host's X socket to the docker container - it gives the container the required credentials .The X socket can be found in /tmp/.X11-unix on your host.
--env="DISPLAY" is providing the container with a DISPLAY environment variable (so that a gui, i.e. an X client, can can connect to the X server.)
echo $DISPLAY to seeDISPLAY variable in the container to the value of $DISPLAY on the host. This is usually set to :0. The number is just to distinguish with different displays. For example the socket file /etc/.X11-unix/X0 or /tmp/.X11-unix/X0 uses the :0 display.-e DISPLAY=$DISPLAY is equivalent to --env="DISPLAY"--net=host makes the programs inside the docker container look like they are running on the host itself, from the perspective of the network.sqlite3cx-Oracle==7.0.0 which uses the installed oracle-instantClient with their versions corresponding to those that host int2r. cx_oracle documentation: https://cx-oracle.readthedocs.io/Installation instructions: https://docs.oracle.com/en/database/oracle/oracle-database/21/lacli/install-instant-client-using-zip.html#GUID-D3DCB4FB-D3CA-4C25-BE48-3A1FB5A22E84
After you docker pull and docker run -it ... as described above, your working directory is /home. Do
tree
Currently a few basic ones are included based on what should be included by Alex and Ludivine.
You should think of the CMS_HGC_CORE_COND.COND_DATA_SETS table as the master table that has a record of everything that was uploaded, and the CONDITION_DATA_SET_ID as the successful upload ID that relates schemas and tables.
select * from CMS_HGC_CORE_MANAGEMNT.CONDITIONS_DATA_AUDITLOG where RECORD_LASTUPDATE_USER LIKE 'Ali%';
- QUERY_EVA="select * from CMS_HGC_CORE_MANAGEMNT.CONDITIONS_DATA_AUDITLOG where RECORD_LASTUPDATE_USER LIKE 'Chao%'"
execute_query(QUERY_EVA)
CONDITIONS_DATA_AUDITLOG has a record and log file of uploads/attempt to upload. Replace "Ali" with the name of the user who aploaded something, and you should see it, whether it was uploaded successfully and a log file associated with it!select * from CMS_HGC_CORE_MANAGEMNT.CONDITIONS_DATA_AUDITLOG where RECORD_LASTUPDATE_USER LIKE 'Ali%';
CMS_HGC_HGCAL_COND account (and the number of rows in each)select table_name, num_rows
from all_tables
where owner='CMS_HGC_HGCAL_COND';
hcg_cern_sensor_ivl table:select * from CMS_HGC_HGCAL_COND.hgc_cern_sensor_iv;
select * from CMS_HGC_CORE_CONSTRUCT.PARTS order by RECORD_INSERTION_TIME ASC;
select * from CMS_HGC_CORE_CONSTRUCT.PARTS where SERIAL_NUMBER='100113';
Alex%" (i.e. it matches any user name that starts with "Alex").select KIND_OF_PART_ID, NAME_LABEL
from CMS_HGC_CORE_CONSTRUCT.PARTS Where RECORD_INSERTION_USER LIKE 'Alex%';
For the HGCAL data we sometimes need to use some Inner join commands in our SQL query. Basically inner join lets you join your initial table with another table, at a particular field that is the same in both tables.
select * from CMS_HGC_HGCAL_COND.HGC_CERN_SENSOR_CV
INNER JOIN CMS_HGC_CORE_COND.COND_DATA_SETS
ON CMS_HGC_HGCAL_COND.HGC_CERN_SENSOR_CV.CONDITION_DATA_SET_ID = CMS_HGC_CORE_COND.COND_DATA_SETS.CONDITION_DATA_SET_ID
where CMS_HGC_CORE_COND.COND_DATA_SETS.RECORD_INSERTION_USER LIKE '%Ali%'
ORDER BY CELL_NR;
Content type
Image
Digest
sha256:cab1d0a9d…
Size
1.2 GB
Last updated
over 3 years ago
docker pull alialkadhim/pascal