CederGroupHub / alabos

AlabOS: Managing the workflows in the Autonomous lab
https://cedergrouphub.github.io/alabos/
MIT License
28 stars 7 forks source link

[Bug]: TypeError: duplicate base class TimeoutError #79

Closed jkitchin closed 1 week ago

jkitchin commented 1 week ago

Current behavior

Running this in an empty directory gives an error.

(base) Johns-iMac-4:tutorial jkitchin$ alabos init
Traceback (most recent call last):
  File "/Users/jkitchin/anaconda3/bin/alabos", line 5, in <module>
    from alab_management.scripts.cli import cli
  File "/Users/jkitchin/Dropbox/emacs/projects/projects/claude/alabos/alab_management/scripts/__init__.py", line 3, in <module>
    from .cli import cli
  File "/Users/jkitchin/Dropbox/emacs/projects/projects/claude/alabos/alab_management/scripts/cli.py", line 10, in <module>
    from .launch_worker import launch_worker
  File "/Users/jkitchin/Dropbox/emacs/projects/projects/claude/alabos/alab_management/scripts/launch_worker.py", line 3, in <module>
    from alab_management.task_manager.task_manager import TaskManager
  File "/Users/jkitchin/Dropbox/emacs/projects/projects/claude/alabos/alab_management/task_manager/task_manager.py", line 10, in <module>
    from alab_management.lab_view import LabView
  File "/Users/jkitchin/Dropbox/emacs/projects/projects/claude/alabos/alab_management/lab_view.py", line 19, in <module>
    from alab_management.resource_manager.resource_requester import ResourceRequester
  File "/Users/jkitchin/Dropbox/emacs/projects/projects/claude/alabos/alab_management/resource_manager/resource_requester.py", line 37, in <module>
    class CombinedTimeoutError(TimeoutError, concurrent.futures.TimeoutError):
TypeError: duplicate base class TimeoutError

Expected Behavior

the output at https://cedergrouphub.github.io/alabos/setup.html

Minimal example

git clone https://github.com/CederGroupHub/alabos
cd alabos/
pip install -e .
cd ..
mkdir tutorial
cd tutorial
alabos init


### Relevant files/images/logs

_No response_
idocx commented 1 week ago

I believe the error is because concurrent.futures.TimeoutError becomes alias to TimeoutError in the standard library starting from Python 3.11. Fixing this bug now.

jkitchin commented 1 week ago

I am indeed using Python 3.11!

idocx commented 1 week ago

I have merged the fix for this issue. The current code in the main branch should work and have been tested with Python 3.11. Thank you for reporting this bug and let me know if there are any other issues!

jkitchin commented 1 week ago

This didn't fix it for me. This code does not return True as the logic in the fix suggests.

>>> from concurrent.futures import Future
>>> isinstance(concurrent.futures.TimeoutError, TimeoutError)
False

In the CI, I suggest adding a test that makes an empty directory and runs alabos init in it.

idocx commented 1 week ago

Sorry I realized that TimeError is a class, not an instance. It should be

import concurrent.futures
concurrent.futures.TimeoutError is TimeoutError

I am working on the CI now.

idocx commented 1 week ago

Hi John! I have fixed this with an is statement instead of isinstance. I also added a test_init to the CI to make sure it behaves as expected. Thank you for reporting the issue and for your patience! :-)

jkitchin commented 1 week ago

thanks for the quick fixes. I got alabos init to work as expected.