automl / DEHB

https://automl.github.io/DEHB/
Apache License 2.0
71 stars 16 forks source link

[Bug] `isinstance(self, Client)` will never be `True` #45

Closed eddiebergman closed 1 year ago

eddiebergman commented 1 year ago

Found this while looking for where the Client is located.

https://github.com/automl/DEHB/blob/54ce41c4c516e38aefc5944a2b677b95cfa2e05a/dehb/optimizers/de.py#L254

Neeratyoy commented 1 year ago

Does it mean that the client is never destructed in this code base or could be a Dask version-related thing?

eddiebergman commented 1 year ago

Not a dask version related thing, it's basically doing:

class A:

    def __del__(self):
        if isisntance(self, Client):
            ...

Also relying on __del__ for for cleanup is usually a bad practice and can lead to problems if DEHB would be the last thing to be cleaned up.

The correct way, is that Dask Clients can be used as context managers and is likely what you want to have around your hot loop. In the case of a user supplied dask, not sure what you want, might be bad form to automatically shut down their client unless they've specified it somehow.

Neeratyoy commented 1 year ago

Okay thanks, so 2 aspects here as I see:

Bronzila commented 1 year ago

I think using the Dask Client as a context manager would definetly be an improvement. However this would involve quite some refactoring and since we are planing to release on Thursday, I would propose to simply fix the bug for now and create a new issue regarding using Dask Clients as context managers. What do you think? @eddiebergman @Neeratyoy

eddiebergman commented 1 year ago

Sounds fine to me, as long as it works generally at the moment, then fire away.

Neeratyoy commented 1 year ago

I second @eddiebergman! Just keep an issue alive to remind us :)