coiled / feedback

A place to provide Coiled feedback
14 stars 3 forks source link

Coiled inspect doesn't work in JupyterLab #83

Closed DPeterK closed 3 years ago

DPeterK commented 3 years ago

If you try to inspect a coiled software environment in JupyterLab you hit an error:

coiled.inspect("tiledb")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-9-0829b31b39f9> in <module>
----> 1 coiled.inspect("tiledb")

/anaconda/envs/tiledb2/lib/python3.7/site-packages/coiled/cli/env.py in inspect(name)
     82 
     83     """
---> 84     results = get_event_loop().run_until_complete(get_software_info(name))
     85     for key in ["container", "conda", "pip", "post_build"]:
     86         print(f"{key}:")

/anaconda/envs/tiledb2/lib/python3.7/asyncio/base_events.py in run_until_complete(self, future)
    561         """
    562         self._check_closed()
--> 563         self._check_runnung()
    564 
    565         new_task = not futures.isfuture(future)

/anaconda/envs/tiledb2/lib/python3.7/asyncio/base_events.py in _check_runnung(self)
    521     def _check_runnung(self):
    522         if self.is_running():
--> 523             raise RuntimeError('This event loop is already running')
    524         if events._get_running_loop() is not None:
    525             raise RuntimeError(

RuntimeError: This event loop is already running

I get a near-identical error if I run coiled.install("tiledb").

I don't get either error if I just use a plain Python prompt. I'm using coiled v0.0.27 here.

Note this isn't preventing me from being able to use coiled at all. I just happened to come across it, so thought I'd raise 🙂

jrbourbeau commented 3 years ago

Thanks for letting us know about this @DPeterK! It looks like there's a poor interaction between the JupyterLab event loop and the event loop coiled is using. We'll look into it!

mrocklin commented 3 years ago

It looks like the inspect and maybe other CLI methods are creating their own event loop. In this case one thing we could do is take the functions in cloud/cli/utils.py and put them on the Cloud object. Maybe most logic/interactions should go on that object rather than in separate functions. CLI functions should maybe also be pointers to code in core.py rather than the other way around.

jrbourbeau commented 3 years ago

Thanks @mrocklin. I was just revisiting this issue as it came up elsewhere recently. I'll give moving some functions in cloud/cli/utils.py toCloud methods a shot.

jrbourbeau commented 3 years ago

Thanks for reporting @DPeterK! This will be fixed in the next coiled release

DPeterK commented 3 years ago

Great stuff! Thanks @jrbourbeau and @mrocklin