Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to make getters available #568

Closed
bnmajor opened this issue Oct 25, 2022 · 3 comments
Closed

Need to make getters available #568

bnmajor opened this issue Oct 25, 2022 · 3 comments

Comments

@bnmajor
Copy link
Collaborator

bnmajor commented Oct 25, 2022

We should expose the getter functions to users so that they can access the information that they may need. Currently progress on this is barred by two issues, the first of which being the major barrier:

  • (Highest Priority) For some reason we currently get stuck with awaiting the results. Calling the ImJoyPluginAPI we can see that the value is retrieved, but for some reason the <FuturePromise pending> never resolves when we await it. Can be reproduced with the following:
from imjoy_rpc import api
import imageio.v2 as imageio

image = imageio.imread("https://data.kitware.com/api/v1/file/5b843d468d777f43cc8d4f6b/download/engine.nrrd")

class ImJoyPlugin():
    async def setup(self):
        pass

    async def run(self, ctx):
        # create a viewer
        viewer = await api.createWindow(src="https://bafybeicuvbx4cfp3zgo25j376bmmysh73a2ui5dbapuwqtmjcvcaipmpbi.on.fleek.co/")
        # show an image
        viewer.setImage(image)

    async def getUICollapsed(self):
        return await self.viewer.getUICollapsed()

viewer = ImJoyPlugin()
api.export(viewer)
await viewer.getUICollapsed()
  • (Useful but lower priority) To handle the case of "Run All" we need to think about how to handle calls to these getters so that they don't produce errors that interrupt the notebook. Some ideas:
    • Use the background thread like we do with the setters. In this case we would need to rethink the current approach a little to make sure we get the result back. We'd also need a way to associate the result with the correct cell. Would also need a "placeholder" for the returned value to indicate that it hasn't yet returned even though the cell has "completed". Less than ideal.
    • Try to move the rpc to the background thread so that cells can block while they wait for results.
@bnmajor
Copy link
Collaborator Author

bnmajor commented Nov 4, 2022

Linking this discussion here to keep this issue updated.

@thewtex
Copy link
Member

thewtex commented Nov 30, 2022

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 13, 2023

Fixed in #587 and improved in #702. Closing.

@bnmajor bnmajor closed this as completed Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants