OpenAdaptAI / OpenAdapt

Open Source Generative Process Automation (i.e. Generative RPA). AI-First Process Automation with Large ([Language (LLMs) / Action (LAMs) / Multimodal (LMMs)] / Visual Language (VLMs)) Models
https://www.OpenAdapt.AI
MIT License
961 stars 132 forks source link

Unable to play back recordings #41

Closed angelala3252 closed 1 year ago

angelala3252 commented 1 year ago

Whenever I try to play back a recording, I get this error. I'm not sure what the playbacks are supposed to look like since I can't test them. Any help is appreciated!

Traceback (most recent call last):
  File "C:\Users\Angel\Desktop\puterbot\puterbot\replay.py", line 43, in <module>
    fire.Fire(replay)
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\fire\core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\fire\core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\fire\core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "C:\Users\Angel\Desktop\puterbot\puterbot\replay.py", line 21, in replay
    strategy_class_by_name = get_strategy_class_by_name()
  File "C:\Users\Angel\Desktop\puterbot\puterbot\utils.py", line 375, in get_strategy_class_by_name
    from strategies import BaseReplayStrategy
  File "C:\Users\Angel\Desktop\puterbot\puterbot\strategies\__init__.py", line 1, in <module>
    from strategies.base import BaseReplayStrategy
  File "C:\Users\Angel\Desktop\puterbot\puterbot\strategies\base.py", line 15, in <module>
    from puterbot.models import InputEvent, Recording, Screenshot
  File "C:\Users\Angel\Desktop\puterbot\../puterbot\puterbot\models.py", line 13, in <module>
    class Recording(Base):
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\orm\decl_api.py", line 76, in __init__
    _as_declarative(reg, cls, dict_)
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\orm\decl_base.py", line 126, in _as_declarative
    return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\orm\decl_base.py", line 183, in setup_mapping
    return cfg_cls(registry, cls_, dict_, table, mapper_kw)
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\orm\decl_base.py", line 331, in __init__
    self._setup_table(table)
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\orm\decl_base.py", line 854, in _setup_table
    table_cls(
  File "<string>", line 2, in __new__
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\util\deprecations.py", line 309, in warned
    return fn(*args, **kwargs)
  File "C:\Users\Angel\Desktop\puterbot\venv\lib\site-packages\sqlalchemy\sql\schema.py", line 594, in __new__
    raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Table 'recording' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
angelala3252 commented 1 year ago

I was able to resolve the above error by adding __table_args__ = {'extend_existing': True} under every __tablename__ line. Now, I'm getting this error: ImportError: cannot import name 'NaiveReplayStrategy' from partially initialized module 'strategies.naive' (most likely due to a circular import) (C:\Users\Angel\Desktop\puterbot\puterbot\strategies\naive.py)

I can't find the issue though as there doesn't seem to be a circular import between base.py and naive.py.

abrichr commented 1 year ago

Thanks @angelala3252 ! Can you please provide the output of the following commands?

Thank you!

angelala3252 commented 1 year ago

Here's the output:

On branch main Your branch is up to date with 'origin/main'.

Changes to be committed: (use "git restore --staged ..." to unstage) new file: puterbot/strategies/minigpt4.py

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: puterbot/config.py modified: puterbot/crud.py modified: puterbot/db.py modified: puterbot/events.py modified: puterbot/models.py modified: puterbot/record.py modified: puterbot/replay.py modified: puterbot/strategies/init.py modified: puterbot/strategies/base.py modified: puterbot/strategies/minigpt4.py modified: puterbot/strategies/naive.py modified: puterbot/utils.py modified: puterbot/visualize.py

Untracked files: (use "git add ..." to include in what will be committed) .idea/ MiniGPT-4/

abrichr commented 1 year ago

Thanks @angelala3252! Please try this:

  1. Create a new branch:
git checkout -b feat/my-feature
  1. Commit all your changes and push them:
git commit -am "work in progress"
git push
  1. Check out the main branch:
git checkout main
  1. Pull the latest changes:
git pull
  1. Try playing back again:
python -m puterbot.replay NaiveReplayStrategy

If that doesn't work:

  1. Re-create your environment and create a new recording:
deactivate
python3.10 -m venv .venv
source .venv/bin/activate
pip install wheel
pip install -r requirements.txt
pip install -e .
mv puterbot.db puterbot.db.old   # backup your old database
alembic upgrade head
pytest
python -m puterbot.record "testing out puterbot"
  1. And try again:

    python -m puterbot.replay NaiveReplayStrategy
  2. Once you are able to replay again, check out your branch:

git checkout feat/my-feature
  1. And try again:
    python -m puterbot.replay NaiveReplayStrategy

If that doesn't work that means the bug is being triggered by something in your changes, and we can track it down 😄

angelala3252 commented 1 year ago

The bug was an issue on my end that I was able to resolve by only keeping my relevant changes. Thanks for the help!