Skip to content

Commit 6ee04b8

Browse files
authored
Merge pull request #6 from roy-cruz/main
OMS data now accessed through OMS proxy provided by `cmsdials`
2 parents 8371b99 + 0458906 commit 6ee04b8

File tree

7 files changed

+18048
-396
lines changed

7 files changed

+18048
-396
lines changed

README.md

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,37 @@
11
# DQMExplore
22

3-
This repository hosts `dqmexplore`, a Python package which provides tools that facilitate the exploration of CMS DQM data for shifters, shift leaders & experts. These tools enable the evaluation of runs at a per-lumisection level. It utilized the [DIALS API](https://github.com/cms-DQM/dials-py) to access monitoring element histograms, as well as the [OMS API](https://gitlab.cern.ch/cmsoms/oms-api-client) to obtain information regarding the data taking conditions and trigger rate.
3+
This repository hosts `dqmexplore`, a Python software package that provides tools to facilitate the exploration of CMS DQM data for shifters, shift leaders, and experts. These tools enable the evaluation of runs at a per-lumisection level by allowing the user to plot 1D and 2D monitoring elements as well as trends in these using data obtained from the [DIALS Python API](https://github.com/cms-DQM/dials-py).
44

55
## Setup
66

7-
The tools offered in this repo are meant to be primarily used in [SWAN](https://swan.web.cern.ch/swan/), but this project includes a `pyproject.toml` and `requirements.txt` which defines all of the dependencies, so you can set things up in your preferred way. However, if you are going to use the OMS API, you will need to be working inside the lxplus. Using this API also requires authentication. Please visit the official [OMS API repo](https://gitlab.cern.ch/cmsoms/oms-api-client/-/tree/master) for more information on the available authentication methods.
7+
The tools offered in this repo are meant to be primarily used in [SWAN](https://swan.web.cern.ch/swan/). The tools provided by `dqmexplore` can be used by either installing it as a Python package, for which a `pyproject.toml` and `requirements.txt` are included, or by adding `src/` to the system path and importing it.
88

9-
To setup DQMExplore, firstly:
10-
1. Navigate to SWAN and click the "Download Project from git" button in the top right.
11-
2. Insert the link to this repository, namely `https://github.com/CMSTrackerDPG/DQMExplore.git`, and click "Download". SWAN will automatically create a new project with all of the files from this repository.
12-
3. Launch the notebook you wish to use. Template notebooks are found in the `DQMExplore/notebooks` directory. SWAN should already have all the depedencies you need except for the `omsapi` & `dqmplore` . Assuming you are in the `notebooks` subdirectory, to install them, simply run the following in your notebook.
13-
```
14-
!pip3 install omsapi
15-
!pip3 install .. --no-dependencies
16-
```
17-
If you are setting your virtual environment, assuming you are located in the project's root directory, you can install all the required libraries by running the following inside your environment.
18-
```bash
19-
pip3 install poetry
20-
poetry install -E oms -E nb
21-
```
9+
### Accessing and Plotting Data with `dqmexplore` & `cmsdials`
2210

23-
### Importing `cmsdials`
24-
25-
To import `cmsdials`, run the following in your notebook
11+
In `src/utils/setupdials.py`, the small function `setup_dials_object_deviceauth()` ([original source](https://github.com/cms-DQM/dials-py/blob/develop/tests/integration/utils.py)) is included. This function will automate the setup of DIALS so you can start accesing data easily. Here is an example usage where we use it to access some PixelPhase1 1D monitoring elements for run 380238:
2612

2713
```python
28-
import cmsdials
29-
from cmsdials.auth.client import AuthClient
30-
from cmsdials.auth.bearer import Credentials
31-
from cmsdials import Dials
32-
from cmsdials.filters import LumisectionHistogram1DFilters, LumisectionHistogram2DFilters
33-
34-
auth = AuthClient()
35-
token = auth.device_auth_flow()
36-
creds = Credentials.from_authclient_token(token)
37-
38-
creds = Credentials.from_creds_file()
39-
dials = Dials(creds)
14+
import sys
15+
sys.path.append("../src/")
16+
17+
# Setup DIALS
18+
from utils.setupdials import setup_dials_object_deviceauth
19+
dials = setup_dials_object_deviceauth()
20+
21+
# Query
22+
runnb = 380238
23+
me__regex = "PixelPhase1/Tracks/PXBarrel/charge_PXLayer_."
24+
25+
data1D = dials.h1d.list_all(
26+
LumisectionHistogram1DFilters(
27+
run_number = runnb,
28+
dataset__regex = "ZeroBias",
29+
me__regex = me__regex
30+
),
31+
# max_pages=200
32+
).to_pandas() # Returns a Dataframe
4033
```
4134

42-
Click on the link it provides and log in using your CERN account. Once you do that, come back to your notebook. For more information, please visit the [DIALS API repository](https://github.com/cms-DQM/dials-py).
43-
44-
### Instructions for obtaining OMS API Credentials
45-
46-
If you wish to use token authentication for OMS API, you can follow the following steps to obtain the credentials. More information can be found in the [OMS API repository](https://gitlab.cern.ch/cmsoms/oms-api-client/-/tree/master).
35+
When run, this will prompt the user to follow a link which, when clicked will open a webpage which will prompt you to log in using your CERN account. One logged in, click "Yes" when it asks if you want to grant access privileges to cms-dials-prod-confidential-app. Once that is done, come back to your notebook. For more information, please visit the [DIALS Python API repository](https://github.com/cms-DQM/dials-py).
4736

48-
1. Navigate to to [this link]('https://application-portal.web.cern.ch/') and click "Add an Application".
49-
2. Fill in the Application Identifier information. Generate it using a format such as `<yourusername>-oms-api` and include your name. The rest of the details are not necessary at this step. Proceed to SSO Registration.
50-
3. Keep the protocol for authentication as OpenID Connect (OIDC). Generate a Redirect URI (e.g. `https://<yourusername>-oms-api.cern.ch`) and a Base URL (e.g. `https://<yourusername>-oms-dev.cern.ch`). Select the option: "My application will need to get tokens using its own client ID and secret".
51-
Note: It is not necessary for these URLs to exist.
52-
4. You should see your "CLIENT ID" and "CLIENT SECRET". Save them as these are the credentials you need. However, they can't be used until permission is granted.
53-
5. Send an email to [email protected] or [email protected] to get the approval. Once it's granted, the OMS API credentials may be utilized.
37+
For examples on how to use the tools provided by `dqmexplore` to plot the data obtained from `cmsdials`, please refer to the notebooks found in `notebooks/`.

0 commit comments

Comments
 (0)