result_HWC_QHD_PM_LIST.ipynb 23.2 KB
Newer Older
1
2
{
 "cells": [
Aleksandra Mnich's avatar
Aleksandra Mnich committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2b3664d3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:02.645122Z",
     "iopub.status.busy": "2021-10-27T21:41:02.644194Z",
     "iopub.status.idle": "2021-10-27T21:41:39.944927Z",
     "shell.execute_reply": "2021-10-27T21:41:39.943923Z"
    },
    "papermill": {
     "duration": 37.359841,
     "end_time": "2021-10-27T21:41:39.945145",
     "exception": false,
     "start_time": "2021-10-27T21:41:02.585304",
     "status": "completed"
    }
   },
   "outputs": [],
   "source": [
    "\"\"\"Manual spark configuration based on the default Spark configuration from the NXCALS bundle\n",
    "and https://gitlab.cern.ch/msobiesz/spark-pipelines/-/blob/master/NXCALS-example-for-DAaaS.ipynb.\n",
    "Used unless the spark context is already created. (outside of SWAN service or pyspark)\n",
    "\"\"\"\n",
    "if 'spark' not in locals() and 'spark' not in globals():\n",
    "    import os\n",
    "    from pyspark import SparkContext, SparkConf\n",
    "    from pyspark.sql import SparkSession\n",
    "\n",
    "    nxcals_jars = os.getenv('NXCALS_JARS')\n",
    "    conf = SparkConf()\n",
    "    conf.set('spark.master', 'yarn')\n",
    "    conf.set(\"spark.driver.host\", \"spark-runner.cern.ch\")\n",
    "    conf.set(\"spark.driver.port\", '5001')\n",
    "    conf.set(\"spark.blockManager.port\", '5101')\n",
    "    conf.set(\"spark.ui.port\", '5201')\n",
    "    conf.set('spark.executorEnv.PYTHONPATH', os.getenv('PYTHONPATH'))\n",
    "    conf.set('spark.executorEnv.LD_LIBRARY_PATH', os.getenv('LD_LIBRARY_PATH'))\n",
    "    conf.set('spark.executorEnv.JAVA_HOME', os.getenv('JAVA_HOME'))\n",
    "    conf.set('spark.executorEnv.SPARK_HOME', os.getenv('SPARK_HOME'))\n",
    "    conf.set('spark.executorEnv.SPARK_EXTRA_CLASSPATH', os.getenv('SPARK_DIST_CLASSPATH'))\n",
    "    conf.set('spark.driver.extraClassPath', nxcals_jars)\n",
    "    conf.set('spark.executor.extraClassPath', nxcals_jars)\n",
    "    conf.set('spark.driver.extraJavaOptions',\n",
    "             \"-Dservice.url=https://cs-ccr-nxcals5.cern.ch:19093,https://cs-ccr-nxcals5.cern.ch:19094,\"\n",
    "             \"https://cs-ccr-nxcals6.cern.ch:19093,https://cs-ccr-nxcals6.cern.ch:19094,\"\n",
    "             \"https://cs-ccr-nxcals7.cern.ch:19093,https://cs-ccr-nxcals7.cern.ch:19094,\"\n",
    "             \"https://cs-ccr-nxcals8.cern.ch:19093,https://cs-ccr-nxcals8.cern.ch:19094,\"\n",
    "             \"https://cs-ccr-nxcalsstr4.cern.ch:19093,https://cs-ccr-nxcalsstr5.cern.ch:19093\")\n",
    "\n",
    "    sc = SparkContext(conf=conf)\n",
    "    spark = SparkSession(sc)\n"
   ]
  },
58
59
  {
   "cell_type": "markdown",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
60
61
62
63
64
65
66
67
68
69
70
   "id": "86e93e96",
   "metadata": {
    "papermill": {
     "duration": 0.043237,
     "end_time": "2021-10-27T21:41:40.048851",
     "exception": false,
     "start_time": "2021-10-27T21:41:40.005614",
     "status": "completed"
    },
    "tags": []
   },
71
   "source": [
72
    "# Notebook to list QHD PM timestamps by circuit type and time range"
73
74
75
76
   ]
  },
  {
   "cell_type": "markdown",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
77
78
79
80
81
82
83
84
85
86
87
   "id": "6e01e66c",
   "metadata": {
    "papermill": {
     "duration": 0.043459,
     "end_time": "2021-10-27T21:41:40.136848",
     "exception": false,
     "start_time": "2021-10-27T21:41:40.093389",
     "status": "completed"
    },
    "tags": []
   },
88
   "source": [
89
    "# 0. Initialise Working Environment"
90
91
92
93
   ]
  },
  {
   "cell_type": "code",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
   "execution_count": 2,
   "id": "ebe73a7a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:40.236170Z",
     "iopub.status.busy": "2021-10-27T21:41:40.235298Z",
     "iopub.status.idle": "2021-10-27T21:41:45.929222Z",
     "shell.execute_reply": "2021-10-27T21:41:45.929995Z"
    },
    "papermill": {
     "duration": 5.749358,
     "end_time": "2021-10-27T21:41:45.930320",
     "exception": false,
     "start_time": "2021-10-27T21:41:40.180962",
     "status": "completed"
    },
    "tags": []
   },
112
113
   "outputs": [
    {
114
     "name": "stdout",
115
116
     "output_type": "stream",
     "text": [
117
      "Analysis executed with lhc-sm-api version: 1.5.17\n",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
118
      "Analysis executed with lhc-sm-hwc notebooks version: 1.5.66\n"
119
120
121
122
123
124
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "`np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n"
143
144
145
146
     ]
    }
   ],
   "source": [
147
148
149
150
    "import os, sys, warnings\n",
    "import pandas as pd\n",
    "from IPython.display import display, HTML, Javascript, clear_output, Markdown\n",
    "#\n",
151
152
153
154
    "import lhcsmapi\n",
    "from lhcsmapi.Time import Time\n",
    "from lhcsmapi.Timer import Timer\n",
    "from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder\n",
155
156
    "from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery\n",
    "from lhcsmapi.analysis.RqCircuitQuery import RqCircuitQuery\n",
157
158
159
160
    "from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n",
    "from lhcsmapi.analysis.IpdCircuitQuery import IpdCircuitQuery\n",
    "from lhcsmapi.analysis.ItCircuitQuery import ItCircuitQuery\n",
    "from lhcsmapi.metadata.SignalMetadata import SignalMetadata\n",
161
    "from lhcsmapi.analysis.report_template import apply_report_template\n",
162
163
164
165
166
167
168
169
    "\n",
    "analysis_start_time = Time.get_analysis_start_time()\n",
    "lhcsmapi.get_lhcsmapi_version()\n",
    "lhcsmapi.get_lhcsmhwc_version('../__init__.py')"
   ]
  },
  {
   "cell_type": "markdown",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
170
171
172
173
174
175
176
177
178
179
180
   "id": "61c76b35",
   "metadata": {
    "papermill": {
     "duration": 0.039167,
     "end_time": "2021-10-27T21:41:46.011951",
     "exception": false,
     "start_time": "2021-10-27T21:41:45.972784",
     "status": "completed"
    },
    "tags": []
   },
181
182
183
184
185
186
   "source": [
    "# 1.  User Input (circuit types: RB, RQ, IPQ, IPD, IT)"
   ]
  },
  {
   "cell_type": "code",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
   "execution_count": 3,
   "id": "2d5e6653",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:46.097084Z",
     "iopub.status.busy": "2021-10-27T21:41:46.096250Z",
     "iopub.status.idle": "2021-10-27T21:41:46.099544Z",
     "shell.execute_reply": "2021-10-27T21:41:46.099002Z"
    },
    "papermill": {
     "duration": 0.048872,
     "end_time": "2021-10-27T21:41:46.099750",
     "exception": false,
     "start_time": "2021-10-27T21:41:46.050878",
     "status": "completed"
    },
    "tags": [
     "parameters"
    ]
   },
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
   "outputs": [],
   "source": [
    "detailed_circuit_types = {\n",
    "    'RB': ['RB'],\n",
    "    'RQ': ['RQ'],\n",
    "    'IPQ': ['IPQ2', 'IPQ4', 'IPQ8'],\n",
    "    'IPD': ['IPD2', 'IPD2_B1B2'],\n",
    "    'IT': ['IT']\n",
    "}\n",
    "\n",
    "start_time = '2021-10-18 07:00:00'\n",
    "stop_time  = '2021-10-20 23:01:00'\n"
   ]
  },
  {
   "cell_type": "code",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
   "execution_count": 4,
   "id": "b095af0e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:46.188975Z",
     "iopub.status.busy": "2021-10-27T21:41:46.188167Z",
     "iopub.status.idle": "2021-10-27T21:41:46.192141Z",
     "shell.execute_reply": "2021-10-27T21:41:46.191154Z"
    },
    "papermill": {
     "duration": 0.04905,
     "end_time": "2021-10-27T21:41:46.192344",
     "exception": false,
     "start_time": "2021-10-27T21:41:46.143294",
     "status": "completed"
    },
    "tags": [
     "injected-parameters"
    ]
   },
   "outputs": [],
   "source": [
    "# Parameters\n",
    "start_time = \"2021-10-18 07:00:00\"\n",
    "stop_time = \"2021-10-20 23:01:00\"\n",
    "parametrized_marker = None\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8f3fb7b2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:46.287901Z",
     "iopub.status.busy": "2021-10-27T21:41:46.287093Z",
     "iopub.status.idle": "2021-10-27T21:41:46.289713Z",
     "shell.execute_reply": "2021-10-27T21:41:46.290214Z"
    },
    "papermill": {
     "duration": 0.053989,
     "end_time": "2021-10-27T21:41:46.290392",
     "exception": false,
     "start_time": "2021-10-27T21:41:46.236403",
     "status": "completed"
    },
    "tags": []
   },
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "start_time =  2021-10-18 07:00:00\n",
      "stop_time =  2021-10-20 23:01:00\n"
     ]
    }
   ],
   "source": [
    "print('start_time = ', start_time)\n",
    "print('stop_time = ', stop_time)"
   ]
  },
  {
   "cell_type": "markdown",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
288
289
290
291
292
293
294
295
296
297
298
   "id": "5ad1ec68",
   "metadata": {
    "papermill": {
     "duration": 0.042729,
     "end_time": "2021-10-27T21:41:46.376602",
     "exception": false,
     "start_time": "2021-10-27T21:41:46.333873",
     "status": "completed"
    },
    "tags": []
   },
299
   "source": [
300
    "# 2.  Search for PMs"
301
302
303
304
   ]
  },
  {
   "cell_type": "code",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
305
306
   "execution_count": 6,
   "id": "09ed9696",
307
   "metadata": {
Aleksandra Mnich's avatar
Aleksandra Mnich committed
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:46.476179Z",
     "iopub.status.busy": "2021-10-27T21:41:46.475307Z",
     "iopub.status.idle": "2021-10-27T21:41:52.090267Z",
     "shell.execute_reply": "2021-10-27T21:41:52.089513Z"
    },
    "papermill": {
     "duration": 5.665805,
     "end_time": "2021-10-27T21:41:52.090551",
     "exception": false,
     "start_time": "2021-10-27T21:41:46.424746",
     "status": "completed"
    },
    "scrolled": false,
    "tags": []
323
   },
324
325
326
327
328
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Aleksandra Mnich's avatar
Aleksandra Mnich committed
329
330
331
332
333
334
335
      "RB\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
336
337
338
339
340
341
342
      "  source            timestamp\n",
      "0  A28L3  1634542949913000000\n",
      "1  B29L3  1634542949913000000\n",
      "2  C28L3  1634542949913000000\n",
      "  source            timestamp\n",
      "0  B15R5  1634605470606000000\n",
      "1  B15R5  1634607003034000000\n",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
343
344
345
346
347
348
349
350
351
352
353
354
355
356
      "2  B15R5  1634646052393000000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RQ\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
357
358
      "  source            timestamp\n",
      "0   27L3  1634542916538649604\n",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
359
360
361
362
363
364
365
366
367
368
369
370
371
372
      "IPQ\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "IPD\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
373
374
375
376
      "IT\n"
     ]
    }
   ],
377
   "source": [
378
379
380
381
382
383
384
385
386
387
    "source_timestamp_qds_df = pd.DataFrame()\n",
    "\n",
    "for circuit_type in detailed_circuit_types:\n",
    "    print(f\"{circuit_type}\")\n",
    "    circuits = SignalMetadata.get_circuit_names(detailed_circuit_types[circuit_type])\n",
    "    if circuit_type == 'RQ':\n",
    "        circuits = circuits[0:7]\n",
    "\n",
    "    for circuit_name in circuits:\n",
    "        meta_circuit_type = circuit_type\n",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
388
    "        if circuit_type == 'IPQ' or circuit_type == 'IPD': \n",
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
    "            meta_circuit_type = SignalMetadata.get_circuit_type_for_circuit_name(circuit_name)\n",
    "            \n",
    "        source_timestamp_qds_df_i = QueryBuilder().with_pm() \\\n",
    "            .with_duration(t_start=start_time, t_end=stop_time) \\\n",
    "            .with_circuit_type(meta_circuit_type) \\\n",
    "            .with_metadata(circuit_name=circuit_name, system='QH', source='*') \\\n",
    "            .event_query() \\\n",
    "            .filter_source(circuit_name, 'QH') \\\n",
    "            .sort_values(by='timestamp').df\n",
    "\n",
    "        if source_timestamp_qds_df_i.empty == False:\n",
    "            print(source_timestamp_qds_df_i)\n",
    "            source_timestamp_qds_df_i['circuit_type'] = source_timestamp_qds_df_i.apply(lambda row: circuit_type, axis=1)\n",
    "            source_timestamp_qds_df = pd.concat([source_timestamp_qds_df, source_timestamp_qds_df_i], ignore_index=True)\n",
    "\n",
    "if source_timestamp_qds_df.empty == False:\n",
    "    source_timestamp_qds_df['datetime'] = source_timestamp_qds_df.apply(lambda row: Time.to_string(row['timestamp']), axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
410
411
412
413
414
415
416
417
418
419
420
   "id": "763ab95e",
   "metadata": {
    "papermill": {
     "duration": 0.051634,
     "end_time": "2021-10-27T21:41:52.196288",
     "exception": false,
     "start_time": "2021-10-27T21:41:52.144654",
     "status": "completed"
    },
    "tags": []
   },
421
422
   "source": [
    "# 3. The list of QHD PM Timestamps, if any"
423
424
425
426
   ]
  },
  {
   "cell_type": "code",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
   "execution_count": 7,
   "id": "53accbff",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-10-27T21:41:52.310862Z",
     "iopub.status.busy": "2021-10-27T21:41:52.310077Z",
     "iopub.status.idle": "2021-10-27T21:41:52.322775Z",
     "shell.execute_reply": "2021-10-27T21:41:52.322069Z"
    },
    "papermill": {
     "duration": 0.07574,
     "end_time": "2021-10-27T21:41:52.322965",
     "exception": false,
     "start_time": "2021-10-27T21:41:52.247225",
     "status": "completed"
    },
    "tags": []
   },
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>timestamp</th>\n",
469
       "      <th>circuit_type</th>\n",
470
471
472
473
474
475
       "      <th>datetime</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
476
477
478
479
       "      <td>A28L3</td>\n",
       "      <td>1634542949913000000</td>\n",
       "      <td>RB</td>\n",
       "      <td>2021-10-18 09:42:29.913000+02:00</td>\n",
480
481
482
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
483
484
485
486
       "      <td>B29L3</td>\n",
       "      <td>1634542949913000000</td>\n",
       "      <td>RB</td>\n",
       "      <td>2021-10-18 09:42:29.913000+02:00</td>\n",
487
488
489
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
490
491
492
493
       "      <td>C28L3</td>\n",
       "      <td>1634542949913000000</td>\n",
       "      <td>RB</td>\n",
       "      <td>2021-10-18 09:42:29.913000+02:00</td>\n",
494
495
496
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
497
498
499
500
       "      <td>B15R5</td>\n",
       "      <td>1634605470606000000</td>\n",
       "      <td>RB</td>\n",
       "      <td>2021-10-19 03:04:30.606000+02:00</td>\n",
501
502
503
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
504
505
506
507
       "      <td>B15R5</td>\n",
       "      <td>1634607003034000000</td>\n",
       "      <td>RB</td>\n",
       "      <td>2021-10-19 03:30:03.034000+02:00</td>\n",
508
509
510
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
511
512
513
514
       "      <td>B15R5</td>\n",
       "      <td>1634646052393000000</td>\n",
       "      <td>RB</td>\n",
       "      <td>2021-10-19 14:20:52.393000+02:00</td>\n",
515
516
517
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
518
519
520
521
       "      <td>27L3</td>\n",
       "      <td>1634542916538649604</td>\n",
       "      <td>RQ</td>\n",
       "      <td>2021-10-18 09:41:56.538649604+02:00</td>\n",
522
523
524
525
526
527
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
       "  source            timestamp circuit_type  \\\n",
       "0  A28L3  1634542949913000000           RB   \n",
       "1  B29L3  1634542949913000000           RB   \n",
       "2  C28L3  1634542949913000000           RB   \n",
       "3  B15R5  1634605470606000000           RB   \n",
       "4  B15R5  1634607003034000000           RB   \n",
       "5  B15R5  1634646052393000000           RB   \n",
       "6   27L3  1634542916538649604           RQ   \n",
       "\n",
       "                              datetime  \n",
       "0     2021-10-18 09:42:29.913000+02:00  \n",
       "1     2021-10-18 09:42:29.913000+02:00  \n",
       "2     2021-10-18 09:42:29.913000+02:00  \n",
       "3     2021-10-19 03:04:30.606000+02:00  \n",
       "4     2021-10-19 03:30:03.034000+02:00  \n",
       "5     2021-10-19 14:20:52.393000+02:00  \n",
       "6  2021-10-18 09:41:56.538649604+02:00  "
545
546
547
      ]
     },
     "metadata": {},
548
549
550
551
552
553
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Aleksandra Mnich's avatar
Aleksandra Mnich committed
554
      "WARNINIG: To be checked that QH discharges has been accepted by QHDA-notebooks!\n"
555
     ]
556
557
558
    }
   ],
   "source": [
559
560
    "if source_timestamp_qds_df.empty == False:\n",
    "    display(source_timestamp_qds_df)\n",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
561
    "    warnings.warn('WARNINIG: To be checked that QH discharges has been accepted by QHDA-notebooks!', stacklevel=2)\n",
562
563
    "else:\n",
    "    print('There were no QH discharges on selected time range!')"
564
565
566
567
   ]
  },
  {
   "cell_type": "markdown",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
568
569
570
571
572
573
574
575
576
577
578
   "id": "ef492ad3",
   "metadata": {
    "papermill": {
     "duration": 0.057517,
     "end_time": "2021-10-27T21:41:52.436373",
     "exception": false,
     "start_time": "2021-10-27T21:41:52.378856",
     "status": "completed"
    },
    "tags": []
   },
579
   "source": [
580
    "# 4. Save html-report"
581
582
583
   ]
  },
  {
Aleksandra Mnich's avatar
Aleksandra Mnich committed
584
585
586
587
588
589
590
591
592
593
   "cell_type": "raw",
   "execution_count": null,
   "id": "223bacf3",
   "metadata": {
    "papermill": {
     "duration": 0.05694,
     "end_time": "2021-10-27T21:41:52.549521",
     "exception": false,
     "start_time": "2021-10-27T21:41:52.492581",
     "status": "completed"
594
    },
Aleksandra Mnich's avatar
Aleksandra Mnich committed
595
596
597
598
599
    "tags": [
     "ignore"
    ]
   },
   "outputs": [],
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
   "source": [
    "if source_timestamp_qds_df.empty == False:\n",
    "    # pd.set_option('display.max_columns', None)\n",
    "    pd.set_option('display.max_rows', None)\n",
    "    analysis_start_time = Time.get_analysis_start_time()\n",
    "    date_time_qhd_pm_list = Time.to_datetime(start_time).strftime(\"%Y-%m-%d-%Hh%M\")\n",
    "    !mkdir -p /eos/project/m/mp3/LHC_QHs\n",
    "\n",
    "    file_name = \"LHC_QHD_PM_LIST-{}-{}\".format(date_time_qhd_pm_list, analysis_start_time)\n",
    "    \n",
    "    apply_report_template()\n",
    "    file_name_html = file_name + '.html'\n",
    "    full_path = '/eos/project/m/mp3/LHC_QHs/{}'.format(file_name_html)\n",
    "    print('Compact notebook report saved to (Windows): ' + '\\\\\\\\cernbox-smb' + full_path.replace('/', '\\\\'))\n",
    "    display(Javascript('IPython.notebook.save_notebook();'))\n",
    "    Time.sleep(5)\n",
Aleksandra Mnich's avatar
Aleksandra Mnich committed
616
    "    !{sys.executable} -m jupyter nbconvert --to html $'HWC_QHD_PM_LIST.ipynb' --output /eos/project/m/mp3/LHC_QHs/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='[\"skip_output\"]' --TagRemovePreprocessor.remove_cell_tags='[\"skip_cell\"]'"
617
   ]
618
619
620
  }
 ],
 "metadata": {
Aleksandra Mnich's avatar
Aleksandra Mnich committed
621
  "celltoolbar": "Tags",
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  },
Aleksandra Mnich's avatar
Aleksandra Mnich committed
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
  "papermill": {
   "default_parameters": {},
   "duration": 53.4518,
   "end_time": "2021-10-27T21:41:53.223268",
   "environment_variables": {},
   "exception": null,
   "input_path": "/builds/LHCData/lhc-sm-hwc/test/../qh/HWC_QHD_PM_LIST.ipynb",
   "output_path": "results/result_HWC_QHD_PM_LIST.ipynb",
   "parameters": {
    "parametrized_marker": null,
    "start_time": "2021-10-18 07:00:00",
    "stop_time": "2021-10-20 23:01:00"
   },
   "start_time": "2021-10-27T21:40:59.771468",
   "version": "2.3.3"
  },
655
656
657
  "sparkconnect": {
   "bundled_options": [],
   "list_of_options": []
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
Aleksandra Mnich's avatar
Aleksandra Mnich committed
674
 "nbformat_minor": 5
675
}