superintendent icon indicating copy to clipboard operation
superintendent copied to clipboard

worker_id argument not working

Open Haffi112 opened this issue 2 years ago • 1 comments

When passing worker_id=True to the distributed classes, it seems as if the prompt for asking the user for a name or ID string is skipped.

The widget for the prompt is created, but it is never displayed. For some reason, the displaying of the annotation interface takes over. I tried fixing it in a hacky way by forcing the worker_id prompt to appear before other things are initialized, but that broke some functionality, such as calling the add_features before the widget is displayed.

More precisely, I was trying to fix it by displaying the worker_id prompt before super().__init__(**kwargs) is called in the _DistributedMixin class. Calling it seems to be the problem. Possibly it would make sense to pass widgets to that initialization function that take precedence over the annotation interface.

@janfreyberg Do you have a suggestion for a clean way to fix this?

(btw. I absolutely love this package, thank you so much for open sourcing it)

Haffi112 avatar Aug 21 '22 09:08 Haffi112

Hi there,

I'm sorry for not getting back to you on this any sooner. In part I was waiting to finish a fairly big re-factor of superintendent.

On the latest version, it works OK to me. I actually removed the Distributed class, and everything now has the same interface (and, by default, uses an in-memory SQLite database which makes it easy to switch to the distributed setup with a proper database).

For me, this now works:

from sklearn.datasets import load_digits
import numpy as np
from superintendent import Superintendent
from ipyannotations.images import ClassLabeller

digits = load_digits().data.reshape(-1, 8, 8)

annotation_widget = ClassLabeller(
    options=[f"{i}" for i in range(10)],
    image_size=(256, 256),
    allow_freetext=False)

annotation_widget.on_submit(print)

widget = Superintendent(
    database_url="sqlite:///demo.db",
    labelling_widget=annotation_widget,
    worker_id=True,
)
widget

image

And after entering a user ID I see the labelling interface: image

Could you try the new version and report back?

Please note that it now requires getting the actual labelling widget from ipyannotations, as above (which is another package I am developing :) )

janfreyberg avatar Sep 16 '22 20:09 janfreyberg