File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import json
2- import os
3- from glob import iglob
4- from pathlib import Path
52from urllib .parse import urljoin
63
74import yaml
85import requests
96from oauth2_xfel_client import Oauth2ClientBackend
107
8+ from .utils import find_proposal
9+
1110MYMDC_BASE_URL = "https://in.xfel.eu/metadata"
1211ZWOP_BASE_URL = "https://exfldadev01.desy.de/zwop"
1312
14- # Copied from extra-data
15- def find_proposal (propno ):
16- root_dir = Path (os .environ .get ('EXTRA_DATA_DATA_ROOT' , '/gpfs/exfel/exp' ))
17- for d in iglob (str (root_dir / f'*/*/{ propno } ' )):
18- return Path (d )
19-
20- raise Exception (f"Couldn't find proposal dir for { propno !r} " )
21-
2213
2314class MyMdcAccess :
2415 _oauth_cache = {} # Keyed by client ID
Original file line number Diff line number Diff line change 11import fnmatch
22import glob
33import logging
4- import os
54import re
65from datetime import datetime
76from functools import wraps
87from itertools import count , groupby
9- from pathlib import Path
108from typing import Any , Optional
119
1210import numpy as np
1311
1412from .mymdc import MyMdcAccess
13+ from .utils import data_root_dir , find_proposal
1514
1615logger = logging .getLogger (__name__ )
1716
1817
19- class ProposalNotFoundError (Exception ):
20- """
21- Raised when the proposal is not found.
22- """
23-
24- pass
25-
26-
27- def data_root_dir ():
28- return Path (os .environ .get ('EXTRA_DATA_DATA_ROOT' , '/gpfs/exfel/exp' ))
29-
30-
31- # Copied from extra-data
32- def find_proposal (propno ):
33- for d in data_root_dir ().glob (f'*/*/{ propno } ' ):
34- return d
35-
36- raise ProposalNotFoundError (f"Proposal { propno !r} was not found" )
37-
38-
3918class RunReference :
4019 def __init__ (self , proposal : 'Proposal' , run_num : int ):
4120 self .proposal = proposal
Original file line number Diff line number Diff line change 1+ import os
2+ from pathlib import Path
3+
4+ class ProposalNotFoundError (Exception ):
5+ """
6+ Raised when the proposal is not found.
7+ """
8+ pass
9+
10+
11+ def data_root_dir ():
12+ return Path (os .environ .get ('EXTRA_DATA_DATA_ROOT' , '/gpfs/exfel/exp' ))
13+
14+
15+ # Copied from extra-data
16+ def find_proposal (propno ):
17+ for d in data_root_dir ().glob (f'*/*/{ propno } ' ):
18+ return d
19+
20+ raise ProposalNotFoundError (f"Proposal { propno !r} was not found" )
Original file line number Diff line number Diff line change 66import matplotlib .pyplot as plt
77
88from extra_proposal import Proposal
9- from extra_proposal .proposal import ProposalNotFoundError
9+ from extra_proposal .utils import ProposalNotFoundError
1010
1111
1212# Helper function to mock requests.get() for different endpoints
You can’t perform that action at this time.
0 commit comments