Pete R Jemian
Pete R Jemian
```py In [3]: run = c["bdp2022"]["43044b6e-f6ba-48cb-a975-90d236dcbaaa"].values().first() In [7]: run Out[7]: In [8]: [doc for name, doc in run.documents() if name == 'resource'] --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell...
Za! ```py In [9]: run = c["bdp2022"]["43044b6e-f6ba-48cb-a975-90d236dcbaaa"] In [10]: [doc for name, doc in run.documents() if name == 'resource'] Out[10]: [Resource({'path_semantics': 'posix', 'resource_kwargs': {'frame_per_point': 1}, 'resource_path': 'clhome/BDP/voyager/adsimdet/2022/08/30/d585f272-dd9b-4ac0-b521_000.h5', 'root': '/', 'run_start':...
or even more detail: ```py In [14]: [doc for name, doc in run.documents() if name in ('resource', 'datum_page')] Out[14]: [Resource({'path_semantics': 'posix', 'resource_kwargs': {'frame_per_point': 1}, 'resource_path': 'clhome/BDP/voyager/adsimdet/2022/08/30/d585f272-dd9b-4ac0-b521_000.h5', 'root': '/', 'run_start': '43044b6e-f6ba-48cb-a975-90d236dcbaaa',...
Now, trying that same request using `requests.get(uri)` 👍 ```py In [11]: r = requests.get(uri) In [12]: import json In [13]: json.loads(r.text) --------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last) Cell In[13],...
But this works: ```py In [28]: for line in r.text.splitlines(): ...: key, doc = json.loads(line) ...: if key in ("resource", "datum_page"): ...: print(f"{key}: {doc}") ...: resource: {'spec': 'AD_HDF5', 'root': '/',...
Something about this request: ```py In [30]: requests.get("http://localhost:8000/api/v1/documents/bdp2022/43044b6e-f6ba-48cb-a975-90d236dcbaaa?fill=false") Out[30]: ``` that returns `results.text` which cannot be parsed in whole as JSON.
This works: ```py yaml.load(f"[{requests.get(uri).text.strip()}]".replace("\n", ","), yaml.Loader) ```
So does: ```py json.loads(f"[{requests.get(uri).text.strip()}]".replace("\n", ",")) ```
Here is the concise code that overcomes: ```py # special handling here to overcome a problem with this API request import json r = requests.get(uri) # note no json() call...
@danielballan You have put a **lot** of thought into this tool. I learn more each day.