Fetching data with `ArchiveQuery` in jupyter notebook fails

Using the API v1 from a jupyter notebook to fetch data fails:

query = ArchiveQuery(query={}, required={}, page_size=10, results_max=10000)
query.fetch()
results = query.download()


Fetching remote uploads...
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_6653/3604038133.py in <module>
      1 from nomad.client.archive import ArchiveQuery
      2 query = ArchiveQuery(query={}, required={}, page_size=10, results_max=10000)
----> 3 query.fetch()
      4 results = query.download()

/home1/similarity_search_development/analytics_dos_similarity_search_venv/lib/python3.7/site-packages/nomad/client/archive.py in fetch(self, number)
    402         print('Fetching remote uploads...')
    403 
--> 404         return asyncio.run(self._fetch_async(number))
    405 
    406     def download(self, number: int = 0) -> List[EntryArchive]:

~/anaconda3/lib/python3.7/asyncio/runners.py in run(main, debug)
     32     if events._get_running_loop() is not None:
     33         raise RuntimeError(
---> 34             "asyncio.run() cannot be called from a running event loop")
     35 
     36     if not coroutines.iscoroutine(main):

RuntimeError: asyncio.run() cannot be called from a running event loop

This code runs fine from a .py script.

Edited Mar 10, 2022 by Simon Gabaj
Assignee Loading
Time tracking Loading