EXtra-proposal 0.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {extra_proposal-0.1 → extra_proposal-0.1.2}/PKG-INFO +1 -1
- {extra_proposal-0.1 → extra_proposal-0.1.2}/extra_proposal/__init__.py +1 -1
- {extra_proposal-0.1 → extra_proposal-0.1.2}/extra_proposal/proposal.py +22 -16
- {extra_proposal-0.1 → extra_proposal-0.1.2}/LICENSE +0 -0
- {extra_proposal-0.1 → extra_proposal-0.1.2}/README.md +0 -0
- {extra_proposal-0.1 → extra_proposal-0.1.2}/extra_proposal/mymdc.py +0 -0
- {extra_proposal-0.1 → extra_proposal-0.1.2}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: EXtra-proposal
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: An interface to a European XFEL proposal
|
|
5
5
|
Author-email: James Wrigley <james.wrigley@xfel.eu>, Luca Gelisio <luca.gelisio@xfel.eu>, Thomas Kluyver <thomas.kluyver@xfel.eu>
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -5,7 +5,6 @@ import os
|
|
|
5
5
|
import re
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from functools import wraps
|
|
8
|
-
from glob import iglob
|
|
9
8
|
from itertools import count, groupby
|
|
10
9
|
from pathlib import Path
|
|
11
10
|
from typing import Any, Optional
|
|
@@ -25,11 +24,14 @@ class ProposalNotFoundError(Exception):
|
|
|
25
24
|
pass
|
|
26
25
|
|
|
27
26
|
|
|
27
|
+
def data_root_dir():
|
|
28
|
+
return Path(os.environ.get('EXTRA_DATA_DATA_ROOT', '/gpfs/exfel/exp'))
|
|
29
|
+
|
|
30
|
+
|
|
28
31
|
# Copied from extra-data
|
|
29
32
|
def find_proposal(propno):
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return Path(d)
|
|
33
|
+
for d in data_root_dir().glob(f'*/*/{propno}'):
|
|
34
|
+
return d
|
|
33
35
|
|
|
34
36
|
raise ProposalNotFoundError(f"Proposal {propno!r} was not found")
|
|
35
37
|
|
|
@@ -42,7 +44,7 @@ class RunReference:
|
|
|
42
44
|
def data(self, **kwargs):
|
|
43
45
|
"""Open the data of this run with extra_data"""
|
|
44
46
|
from extra_data import open_run
|
|
45
|
-
return open_run(self.proposal.directory, self.run_num, **kwargs)
|
|
47
|
+
return open_run(str(self.proposal.directory), self.run_num, **kwargs)
|
|
46
48
|
|
|
47
49
|
def damnit(self):
|
|
48
50
|
"""Access DAMNIT results from this run through the damnit API"""
|
|
@@ -56,6 +58,10 @@ class RunReference:
|
|
|
56
58
|
"""Get the run type from myMdC for this run"""
|
|
57
59
|
return self.proposal.run_type(self.run_num)
|
|
58
60
|
|
|
61
|
+
def techniques(self):
|
|
62
|
+
"""Get the run techniques from myMDC for this run"""
|
|
63
|
+
return self.proposal.run_techniques(self.run_num)
|
|
64
|
+
|
|
59
65
|
def plot_timeline(self):
|
|
60
66
|
"""Make a timeline of when this run was taken, migrated & calibrated"""
|
|
61
67
|
import matplotlib.pyplot as plt
|
|
@@ -160,11 +166,11 @@ class Proposal:
|
|
|
160
166
|
logger.info("Found proposal {}.".format(self.directory_name))
|
|
161
167
|
|
|
162
168
|
if user_id is not None:
|
|
163
|
-
self.
|
|
169
|
+
self._mymdc = MyMdcAccess.oauth(
|
|
164
170
|
client_id=user_id, client_secret=user_secret, user_email=user_email,
|
|
165
171
|
)
|
|
166
172
|
else:
|
|
167
|
-
self.
|
|
173
|
+
self._mymdc = MyMdcAccess.zwop(self.number)
|
|
168
174
|
|
|
169
175
|
self._cached_data = {}
|
|
170
176
|
self._timeout = 10
|
|
@@ -205,12 +211,12 @@ class Proposal:
|
|
|
205
211
|
if 'mymdc_info' in self._cached_data:
|
|
206
212
|
return self._cached_data['mymdc_info']
|
|
207
213
|
|
|
208
|
-
inf = self.
|
|
214
|
+
inf = self._mymdc.get(self._by_number_api_url())
|
|
209
215
|
self._cached_data['mymdc_info'] = inf
|
|
210
216
|
return inf
|
|
211
217
|
|
|
212
218
|
def _get_runs_mymdc(self) -> list:
|
|
213
|
-
return self.
|
|
219
|
+
return self._mymdc.get(self._by_number_api_url("/runs"))["runs"]
|
|
214
220
|
|
|
215
221
|
def title(self):
|
|
216
222
|
"""Get the proposal title from myMdC"""
|
|
@@ -227,8 +233,8 @@ class Proposal:
|
|
|
227
233
|
|
|
228
234
|
@_cache_by_run
|
|
229
235
|
def _run_info(self, run: int) -> dict[str, Any]:
|
|
230
|
-
data = self.
|
|
231
|
-
|
|
236
|
+
data = self._mymdc.get(self._by_number_api_url(f"/runs/{run}"),
|
|
237
|
+
timeout=self._timeout)
|
|
232
238
|
if len(data["runs"]) == 0:
|
|
233
239
|
raise RuntimeError(f"Couldn't get run information from mymdc for p{self.number}, r{run}")
|
|
234
240
|
|
|
@@ -237,28 +243,28 @@ class Proposal:
|
|
|
237
243
|
@_cache_by_run
|
|
238
244
|
def run_techniques(self, run: int) -> dict[str, Any]:
|
|
239
245
|
run_info = self._run_info(run)
|
|
240
|
-
data = self.
|
|
246
|
+
data = self._mymdc.get(f'runs/{run_info["id"]}', timeout=self._timeout)
|
|
241
247
|
return data['techniques']
|
|
242
248
|
|
|
243
249
|
@_cache_by_run
|
|
244
250
|
def run_sample_name(self, run: int) -> str:
|
|
245
251
|
run_info = self._run_info(run)
|
|
246
252
|
sample_id = run_info["sample_id"]
|
|
247
|
-
data = self.
|
|
253
|
+
data = self._mymdc.get(f"samples/{sample_id}", timeout=self._timeout)
|
|
248
254
|
return data["name"]
|
|
249
255
|
|
|
250
256
|
@_cache_by_run
|
|
251
257
|
def run_type(self, run: int) -> str:
|
|
252
258
|
run_info = self._run_info(run)
|
|
253
259
|
experiment_id = run_info["experiment_id"]
|
|
254
|
-
data = self.
|
|
260
|
+
data = self._mymdc.get(f"experiments/{experiment_id}",
|
|
255
261
|
timeout=self._timeout)
|
|
256
262
|
|
|
257
263
|
return data["name"]
|
|
258
264
|
|
|
259
265
|
def _get_samples_mymdc(self) -> list:
|
|
260
266
|
prop_id = self._mymdc_info()["id"]
|
|
261
|
-
return self.
|
|
267
|
+
return self._mymdc.get("samples", params={"proposal_id": prop_id})
|
|
262
268
|
|
|
263
269
|
def samples_table(self):
|
|
264
270
|
import pandas as pd
|
|
@@ -289,7 +295,7 @@ class Proposal:
|
|
|
289
295
|
|
|
290
296
|
@property
|
|
291
297
|
def instrument(self):
|
|
292
|
-
return self.directory.relative_to(
|
|
298
|
+
return self.directory.relative_to(data_root_dir()).parts[0]
|
|
293
299
|
|
|
294
300
|
def info(self):
|
|
295
301
|
"""Display information on a given proposal."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|