From b8983523085cf1410c768207dc1f5af2fc9f9270 Mon Sep 17 00:00:00 2001
From: Karim Ahmed <karim.ahmed@xfel.eu>
Date: Tue, 27 Aug 2019 09:24:32 +0200
Subject: [PATCH] copy figs of diff dets in on instr. and new conf

---
 reportservice/report_conf.yaml  | 145 ++++++++++++++++++++++++++++++--
 reportservice/report_service.py |  42 ++++-----
 2 files changed, 159 insertions(+), 28 deletions(-)

diff --git a/reportservice/report_conf.yaml b/reportservice/report_conf.yaml
index 87e51687d..ed8156375 100644
--- a/reportservice/report_conf.yaml
+++ b/reportservice/report_conf.yaml
@@ -3,19 +3,19 @@ GLOBAL:
         figures-local: "/gpfs/exfel/data/scratch/ahmedk/calibration/DetectorCharacterization/figures"
         repo-local: "/gpfs/exfel/data/scratch/ahmedk/calibration/DetectorCharacterization/"
         figures-remote: "http://git@git.xfel.eu/gitlab/detectors/DetectorCharacterization.git"
-    server-port: "tcp://max-exfl015:5555"
+    server-port: "tcp://max-exfl015:5556"
 
     run-on:
-        - Friday 08:30:00 UTC
+        - Monday 08:30:00 UTC
         - Friday 10:33:00 UTC
 
     report-service:
-        port: 5555
+        port: 5556
         bind-to: tcp://*
         allowed-ips:
-        job-db: ./webservice_jobs.sqlite
+        job-db: ./reportservice_jobs.sqlite
         job-update-interval: 30
-        job-timeout: 3600
+        job-timeout: 12000
 
 SPB:
     AGIPD1M1:
@@ -29,7 +29,7 @@ SPB:
             - "SlopesFF"
             - "SlopesPC"
             - "Offset"
-        modules: "0-15"
+        modules: "0-3"
         bias-voltages:
             - 300
             - 500
@@ -37,7 +37,136 @@ SPB:
             - 128
             - 176
         photon-energy: 9.2
-        use-existing: "/gpfs/exfel/data/scratch/karnem/testAGIPD16_21/"
-        out-folder: "/gpfs/exfel/data/scratch/karnem/testAGIPD16_21/"
+        use-existing: "''"
+        out-folder: "/gpfs/exfel/data/scratch/ahmedk/tmp_files/AGIPD1M1_out1/"
+        cal-db-timeout: 180000
+        cal-db-interface: "tcp://max-exfl016:8015#8025"
+
+MID:
+    AGIPD1M2:
+        det-type:
+            - "AGIPD"
+            - "STATS_FROM_DB"
+        db-module: "AGIPD1M2"
+        start-date: "2019-01-01"
+        end-date: "2019-12-12"
+        constants:
+            - "Noise"
+            - "SlopesFF"
+            - "SlopesPC"
+            - "Offset"
+        modules: "0-3"
+        bias-voltages:
+            - 300
+            - 500
+        mem-cells:
+            - 176
+        photon-energy: 9.2
+        use-existing: "''"
+        out-folder: "/gpfs/exfel/data/scratch/ahmedk/tmp_files/AGIPD1M2_out1/"
+        cal-db-timeout: 180000
+        cal-db-interface: "tcp://max-exfl016:8015#8025"
+        range-offset:
+            - 800.
+            - 1500.
+            - 600
+            - 900
+        range-noise:
+            - 2.0
+            - 16.
+            - 1.0
+            - 7.0
+        range-gain:
+            - 20
+            - 30
+            - 20
+            - 30
+        range-noise-e:
+            - 100.
+            - 600.
+            - 100.
+            - 600.
+        range-slopesPC:
+            - 0.95
+            - 1.05
+            - 0.0
+            - 0.5
+        range-slopesFF:
+            - 0.8
+            - 1.2
+            - 0.8
+            - 1.2 
+
+    EPIX01:
+        det-type:
+            - "EPIX"
+            - "STATS_FROM_DB"
+        db-module: "ePix100_M15"
+        start-date: "2019-01-01"
+        end-date: "2019-05-12"
+        constants:
+            - "Noise"
+            - "Offset"
+        bias-voltage:
+            - 200
+        temperature:
+            - 288
+        integration-time:
+            - 1
+            - 50
+        photon-energy: 9.2
+        use-existing: "''"
+        out-folder: "/gpfs/exfel/data/scratch/ahmedk/tmp_files/EPIX01_out1/"
+        cal-db-timeout: 180000
+        cal-db-interface: "tcp://max-exfl016:8015#8025"
+
+    EPIX02:
+        det-type:
+            - "EPIX"
+            - "STATS_FROM_DB"
+        db-module: "ePix100_M18"
+        start-date: "2019-01-01"
+        end-date: "2019-05-12"
+        constants:
+            - "Noise"
+            - "Offset"
+        bias-voltage:
+            - 200
+        temperature:
+            - 288
+        integration-time:
+            - 1
+            - 50
+        photon-energy: 9.2
+        use-existing: "''"
+        out-folder: "/gpfs/exfel/data/scratch/ahmedk/tmp_files/EPIX02_out1/"
+        cal-db-timeout: 180000
+        cal-db-interface: "tcp://max-exfl016:8015#8025"
+
+FXE:
+    LPD1M1:
+        det-type:
+            - "LPD"
+            - "STATS_FROM_DB"
+        db-module: "LPD1M1"
+        start-date: "2018-01-01"
+        end-date: "2018-12-12"
+        constants:
+            - "Noise"
+            - "SlopesFF"
+            - "SlopesCI"
+            - "Offset"
+        modules: "0-3"
+        bias-voltages:
+            - 250
+            - 500
+        mem-cells:
+            - 1
+            - 128
+            - 256
+            - 512
+        photon-energy: 9.2
+        use-existing: "''"
+        out-folder: "/gpfs/exfel/data/scratch/ahmedk/tmp_files/LPD1M1_out1/"
         cal-db-timeout: 180000
         cal-db-interface: "tcp://max-exfl016:8015#8025"
diff --git a/reportservice/report_service.py b/reportservice/report_service.py
index 5cd6a0879..185f722ca 100644
--- a/reportservice/report_service.py
+++ b/reportservice/report_service.py
@@ -262,31 +262,33 @@ async def server_runner(conf_file):
                     logging.error('Jobs timeout!')
 
                 # Copy all plots
-                out_folder = det_conf['out-folder']
-                path = cfg['GLOBAL']['git']['figures-local']
-                figures = glob.glob("{}/*png".format(out_folder))
-                logging.info('Copy figures to: {}'.format(path))
+                for det_name, det_conf in instrument.items():
+                    
+                    out_folder = det_conf['out-folder']
+                    path = cfg['GLOBAL']['git']['figures-local']
+                    figures = glob.glob("{}/*png".format(out_folder))
+                    logging.info('Copy figures to: {}'.format(path))
 
-                det_new_files = {}
+                    det_new_files = {}
 
-                for f in figures:
-                    const = f.split('/')[-1].split('_')[0]
-                    fpath = '{}/{}/{}'.format(path, det_name, const)
+                    for f in figures:
+                        const = f.split('/')[-1].split('_')[0]
+                        fpath = '{}/{}/{}'.format(path, det_name, const)
 
-                    os.makedirs(fpath, exist_ok=True)
-                    det_new_files[f] = fpath
-                    
-                    # Set concurrency limitation.
-                    # 50 have been chosen by trial 
-                    # Note: This is not the max limitation.
-                    sem = asyncio.Semaphore(50)
-                    all_new_files.append(
-                        '{}/{}'.format(fpath, f.split('/')[-1]))
+                        os.makedirs(fpath, exist_ok=True)
+                        det_new_files[f] = fpath
+                        
+                        # Set concurrency limitation.
+                        # 50 have been chosen by trial 
+                        # Note: This is not the max limitation.
+                        sem = asyncio.Semaphore(50)
+                        all_new_files.append(
+                            '{}/{}'.format(fpath, f.split('/')[-1]))
 
-                await asyncio.gather(*[copy_files(k, v, sem)
-                                    for k, v in det_new_files.items()])
+                    await asyncio.gather(*[copy_files(k, v, sem)
+                                        for k, v in det_new_files.items()])
 
-                logging.info('Figures Copied')
+                    logging.info('{} figures Copied'.format(det_name))
 
             asyncio.ensure_future(
                            push_figures(cfg['GLOBAL']['git']['repo-local'],
-- 
GitLab