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

feat(share): add sharing using magic-wormhole #223

Merged
merged 81 commits into from
Dec 12, 2023

Conversation

Mustaballer
Copy link
Collaborator

@Mustaballer Mustaballer commented Jun 5, 2023

Overview

Unit Tests Created

  • test_export_recording_to_folder: Tests the exporting of a recording to a folder. It creates a temporary recording database file and checks that the exported zip file path is not None and exists.
  • test_send_file: Verifies the sending of a file. It creates a temporary file and checks that the subprocess.run() function is called with the correct arguments.
  • test_send_recording: Ensures the sending of a recording. It mocks the necessary functions and verifies that both export_recording_to_folder() and send_file() are called.
  • test_receive_recording: Validates the receiving of a recording. It mocks the subprocess.run() function and checks that it is called with the correct arguments.

image

Steps to QA

  • move your .env to root directory
    After creating a recording, run these following commands in your venv environment
  • For sending a recording: python -m puterbot.share send --recording_id=1
  • For receiving a recording:
    • create/navigate to data/zipped
    • run python -m puterbot.share receive --wormhole_code=<wormhole_code>

@Mustaballer Mustaballer requested a review from abrichr June 5, 2023 17:55
@0dm
Copy link
Collaborator

0dm commented Jun 7, 2023

I'm unable to run send.

steps:

  1. recorded "testing openadapt" where I clicked around my screen and stopped recording
  2. ran python -m openadapt.share send --recording_id=1
  File "/Users/aaron/Documents/GitHub/OpenAdapt/openadapt/share.py", line 75, in send_recording
    zip_file_path = export_recording_to_folder(recording_id)
  File "/Users/aaron/Documents/GitHub/OpenAdapt/openadapt/share.py", line 31, in export_recording_to_folder
    recording_db_path = crud.export_recording(recording_id)
  File "/Users/aaron/Documents/GitHub/OpenAdapt/openadapt/crud.py", line 209, in export_recording
    t, db_file_path = create_db(recording_id, sql)
  File "/Users/aaron/Documents/GitHub/OpenAdapt/openadapt/crud.py", line 180, in create_db
    connection.execute(sql)
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1365, in execute
    return self._exec_driver_sql(
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1669, in _exec_driver_sql
    ret = self._execute_context(
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
    self._handle_dbapi_exception(
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
    util.raise_(
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/Users/aaron/Documents/GitHub/OpenAdapt/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: recording.id
[SQL: INSERT INTO recording VALUES (1, 1686111670.272712, 4000, 1080, 0.5, 5, 'darwin', 'testing openadapt')]
(Background on this error at: https://sqlalche.me/e/14/gkpj)

I had another issue but I just had to move my .env file to the root directory (instead of openadapt/.env)
It appears that my .env file is being duplicated in this directory now though:
image

openadapt/config.py Outdated Show resolved Hide resolved
@abrichr
Copy link
Contributor

abrichr commented Jun 14, 2023

Please resolve merge conflicts 🙏

@Mustaballer
Copy link
Collaborator Author

Please resolve merge conflicts 🙏

Will do :)

@Mustaballer Mustaballer requested a review from abrichr June 15, 2023 16:07
openadapt/crud.py Outdated Show resolved Hide resolved
openadapt/crud.py Outdated Show resolved Hide resolved
openadapt/utils.py Outdated Show resolved Hide resolved
openadapt/crud.py Outdated Show resolved Hide resolved
@abrichr abrichr changed the title Add Publishing using magic-wormhole #46 Add Sharing using magic-wormhole #46 Jun 19, 2023
@Mustaballer Mustaballer marked this pull request as draft June 19, 2023 16:41
@Mustaballer Mustaballer marked this pull request as ready for review June 25, 2023 00:19
@Mustaballer Mustaballer requested a review from abrichr June 25, 2023 00:19
@Mustaballer
Copy link
Collaborator Author

Ready for review! I addressed the comments you've had :)

@Mustaballer
Copy link
Collaborator Author

@abrichr Ready for Review!

@Mustaballer
Copy link
Collaborator Author

Mustaballer commented Dec 11, 2023

I've transferred the visualize function to share.py, as seen in commit 1367cb9 at #223. This change was made because visualizing any database is already feasible by altering the DB_FNAME in the .env file, rendering the previous function redundant.

Edit: the github actions fail, I will address that.

Copy link
Contributor

@abrichr abrichr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Adding my TODOs would be great, once CI passes please feel free to merge 🙏

Excellent work @Mustaballer !! 🚀

openadapt/config.py Show resolved Hide resolved
openadapt/config.py Show resolved Hide resolved
Mustaballer and others added 2 commits December 12, 2023 16:04
Co-authored-by: Richard Abrich <richard.abrich@gmail.com>
Co-authored-by: Richard Abrich <richard.abrich@gmail.com>
@Mustaballer Mustaballer merged commit cf81f1a into OpenAdaptAI:main Dec 12, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Publishing
4 participants