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

Unable to play back recordings #41

Closed
angelala3252 opened this issue Apr 30, 2023 · 5 comments
Closed

Unable to play back recordings #41

angelala3252 opened this issue Apr 30, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@angelala3252
Copy link
Collaborator

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
Copy link
Collaborator Author

angelala3252 commented Apr 30, 2023

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
Copy link
Member

abrichr commented Apr 30, 2023

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

  • python --version
  • python -c "import sqlalchemy; print(sqlalchemy.__version__)"
  • git status

Thank you!

@angelala3252
Copy link
Collaborator Author

angelala3252 commented May 1, 2023

Here's the output:

  • Python 3.10.1
  • 1.4.43

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

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

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." 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 <file>..." to include in what will be committed)
        .idea/
        MiniGPT-4/

@abrichr
Copy link
Member

abrichr commented May 1, 2023

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
  1. 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 😄

@abrichr abrichr added the bug Something isn't working label May 1, 2023
@angelala3252
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants