Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into share-magic-wormhole
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustaballer committed Sep 8, 2023
2 parents a94c303 + f1bb00e commit ca04296
Show file tree
Hide file tree
Showing 29 changed files with 865 additions and 238 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
# TODO: add windows matrix
os: [macos-latest]

env:
REPO: ${{ github.event.pull_request.head.repo.full_name }}
BRANCH: ${{ github.event.pull_request.head.ref }}
SKIP_POETRY_SHELL: 1

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -28,13 +33,13 @@ jobs:

- name: Run tests using the shell script (macOS compatible).
if: matrix.os == 'macos-latest'
run: SKIP_POETRY_SHELL=1 sh install/install_openadapt.sh
run: sh install/install_openadapt.sh

- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ env.BRANCH }}
repository: ${{ env.REPO }}

- name: Install poetry
uses: snok/install-poetry@v1
Expand Down
120 changes: 120 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,122 @@



## v0.13.1 (2023-08-30)

### Fix

* fix(tests.openadapt.privacy.providers): failing `test_comprehend_scrub.py` (#488)

* skip all the tests if ther is an issue wiht aws config files, either they are not htere or incorrect values are porided

* format ([`cec2a53`](https://github.com/OpenAdaptAI/OpenAdapt/commit/cec2a53ed329060ed20f1d80773d1a2873cb9fb3))

### Unknown

* Merge pull request #483 from OpenAdaptAI/modify-install-script ([`5fa12eb`](https://github.com/OpenAdaptAI/OpenAdapt/commit/5fa12ebddf8271883aa54c6beb6d43df79a8a609))

* Merge branch 'main' into modify-install-script ([`73bfad4`](https://github.com/OpenAdaptAI/OpenAdapt/commit/73bfad4bd845f91563c1f50a23ef851a68a864b4))


## v0.13.0 (2023-08-29)

### Feature

* feat(privacy.providers): add aws_comprehend as scrubbing provider (#476)

* add aws_comprehend provider module

* fix typo

* add boto3 and botocore to poetry

* ran poetry update

* add the AWS Comprehend Class

* update the script

* create test module to test comprhend

* refactor name

* add full fleged test module

* try to fix failing tests

* try to fix failing tests

* fixed pytest

* format test file

* fix all flake 8 formattings

* add naming meaning for NER

* remove repeated code and make a TextMixin

* format

* change scrub enabled to false
after testing visualization

* remove redundant rmethods

* add enum style provider names

addressing: https://github.com/OpenAdaptAI/OpenAdapt/pull/476#discussion_r1304821459

* fix all flak8 errors

* add files for private_ai scrubbing provider

* change name

* add scrub text function in
PrivateAIScrubbingProvider

* try to skip tests if api key is incorrect or missing or the syntax used in code is incorrect

* pytest passes for test_private_ai

* add temp code for pdfs redaction

* remove the PRIVATE_AI provider code as it will be added in seprate pr

* remove omre prvt_ai files

* ran black

---------

Co-authored-by: Richard Abrich <[email protected]> ([`33fe244`](https://github.com/OpenAdaptAI/OpenAdapt/commit/33fe2446311dd8dea1465f617662407d3bc182cc))

### Unknown

* Merge branch 'main' into modify-install-script ([`705a2f0`](https://github.com/OpenAdaptAI/OpenAdapt/commit/705a2f0d0414d9010f9b0cea7a3a3a1306b49de1))


## v0.12.0 (2023-08-29)

### Feature

* feat: manage recording database (#451)

* implemented db module
* use click + loguru ([`5b25b90`](https://github.com/OpenAdaptAI/OpenAdapt/commit/5b25b90fc4b0a7221a062170c3cb38c520afc718))

### Unknown

* fix formatting ([`d668901`](https://github.com/OpenAdaptAI/OpenAdapt/commit/d66890159c202308ee22aa919784f2d13a46b349))

* Merge branch 'modify-install-script' of github.com:OpenAdaptAI/OpenAdapt into modify-install-script ([`4e52dc3`](https://github.com/OpenAdaptAI/OpenAdapt/commit/4e52dc3bc9c50207683f09067b3b70f330662222))

* address formatting errors ([`2fa3fde`](https://github.com/OpenAdaptAI/OpenAdapt/commit/2fa3fde760692a4c820ebc06976064ce2b865eab))

* Merge branch 'main' into modify-install-script ([`b5ad05c`](https://github.com/OpenAdaptAI/OpenAdapt/commit/b5ad05c90e9fba38b0d9e95145a0d98b209ba4ac))


## v0.11.0 (2023-08-29)

### Feature
Expand Down Expand Up @@ -145,6 +261,8 @@ Co-authored-by: Richard Abrich <[email protected]> ([`90bfe8f`](htt

* remove config ([`212452c`](https://github.com/OpenAdaptAI/OpenAdapt/commit/212452ca99d4895b86f7005536e186f39097c10d))

* chore: modify install script to execute on user's repo and branch ([`21e4942`](https://github.com/OpenAdaptAI/OpenAdapt/commit/21e4942fda2748501f07280194e5150129d5e9af))

* chore: validate functionality of status checks (#477)

* chore: validate functionality of status checks
Expand Down Expand Up @@ -320,6 +438,8 @@ Co-authored-by: Richard Abrich <[email protected]> ([`09f4e71`](htt

* Update README.md ([`250949f`](https://github.com/OpenAdaptAI/OpenAdapt/commit/250949f18ad6c72df16bce2ab6d32764c0af3a82))

* add default values when no parameters are passed ([`e8775e8`](https://github.com/OpenAdaptAI/OpenAdapt/commit/e8775e8151fbb3965f372c89fc8d1c52b892b5c8))

* Productivity measurement (#234)

* check for long gaps in recording
Expand Down
4 changes: 2 additions & 2 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from alembic import context
from openadapt.config import DB_URL
from openadapt.db import Base
from openadapt.db import db

# This is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand All @@ -24,7 +24,7 @@
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
target_metadata = db.Base.metadata


def get_url() -> str:
Expand Down
Binary file added assets/sample_llc_1.pdf
Binary file not shown.
10 changes: 8 additions & 2 deletions install/install_openadapt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ pythonCmd="python3.10"
pythonVerStr="Python 3.10*"
pythonInstallerLoc="https://www.python.org/ftp/python/3.10.11/python-3.10.11-macos11.pkg"

# Set default values when no parameters are provided
BRANCH=${BRANCH:-main}
REPO=${REPO:-https://github.com/MLDSAI/OpenAdapt.git}

REPO_URL="https://github.com/$REPO"

################################ HELPER FUNCTIONS ################################

# Remove OpenAdapt if it exists
Expand Down Expand Up @@ -121,9 +127,9 @@ fi
CheckPythonExists

[ -d "OpenAdapt" ] && mv OpenAdapt OpenAdapt-$(date +%Y-%m-%d_%H-%M-%S)
RunAndCheck "git clone https://github.com/MLDSAI/OpenAdapt.git" "Clone git repo"

RunAndCheck "git clone $REPO_URL" "Clone git repo"
cd OpenAdapt
RunAndCheck "git checkout $BRANCH" "Checkout branch $BRANCH"

RunAndCheck "pip3.10 install poetry" "Install Poetry"
RunAndCheck "poetry install" "Install Python dependencies"
Expand Down
4 changes: 2 additions & 2 deletions openadapt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"nlp_engine_name": "spacy",
"models": [{"lang_code": "en", "model_name": "en_core_web_trf"}],
},
"SCRUB_IGNORE_ENTITIES": [
"SCRUB_PRESIDIO_IGNORE_ENTITIES": [
# 'US_PASSPORT',
# 'US_DRIVER_LICENSE',
# 'CRYPTO',
Expand Down Expand Up @@ -110,7 +110,7 @@
# Calculate and save the difference between 2 neighboring screenshots
"SAVE_SCREENSHOT_DIFF": False,
"SPACY_MODEL_NAME": "en_core_web_trf",
"SCRUB_PROVIDER_NAME": ["Presidio"],
"PRIVATE_AI_API_KEY": "<set your api key in .env>",
}

# each string in STOP_STRS should only contain strings
Expand Down
1 change: 1 addition & 0 deletions openadapt/db/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Package for interacting with the OpenAdapt database."""
8 changes: 7 additions & 1 deletion openadapt/crud.py → openadapt/db/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sqlalchemy as sa

from openadapt import config
from openadapt.db import BaseModel, Session
from openadapt.db.db import BaseModel, Session
from openadapt.models import (
ActionEvent,
MemoryStat,
Expand Down Expand Up @@ -196,6 +196,12 @@ def insert_recording(recording_data: Recording) -> Recording:
return db_obj


def delete_recording(recording_timestamp: int) -> None:
"""Remove the recording from the db."""
db.query(Recording).filter(Recording.timestamp == recording_timestamp).delete()
db.commit()


def get_all_recordings() -> list[Recording]:
"""Get all recordings.
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions openadapt/db/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Lists all recordings in the database.
Usage: python -m openadapt.db.list
"""

from sys import stdout

from loguru import logger

from openadapt.db.crud import get_all_recordings


def main() -> None:
"""Prints all recordings in the database."""
logger.remove()
logger.add(
stdout,
colorize=True,
format="<blue>[DB] </blue><yellow>{message}</yellow>",
)
print() # newline

if not get_all_recordings():
logger.info("No recordings found.")

for idx, recording in enumerate(get_all_recordings()[::-1], start=1):
logger.info(
f"[{idx}]: {recording.task_description} | {recording.timestamp}"
+ (" [latest]" if idx == len(get_all_recordings()) else "")
)


if __name__ == "__main__":
main()
69 changes: 69 additions & 0 deletions openadapt/db/remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Removes recordings from the database.
Usage: python -m openadapt.db.remove [--all | --latest | --id <recording_id>]
"""
from sys import stdout

from loguru import logger
import click

from openadapt.db.crud import delete_recording, get_all_recordings

print() # newline


@click.command()
@click.option("--all", is_flag=True, help="Remove all recordings.")
@click.option("--latest", is_flag=True, help="Remove the latest recording.")
@click.option("--id", "recording_id", type=int, help="Remove recording by ID.")
def remove(all: str, latest: str, recording_id: int) -> int:
"""Removes a recording from the database."""
recordings = get_all_recordings()[::-1]

logger.remove()
logger.add(
stdout,
colorize=True,
format="<blue>[DB] </blue><yellow>{message}</yellow>",
)

if sum([all, latest, recording_id is not None]) > 1:
logger.error("Invalid usage.")
logger.error("Use --help for more information.")
return 1

if not recordings:
logger.error("No recordings found.")
return 1

if all:
if click.confirm("Are you sure you want to delete all recordings?"):
for r in recordings:
logger.info(f"Deleting {r.task_description} | {r.timestamp}...")
delete_recording(r.timestamp)
logger.info("All recordings deleted.")
else:
logger.info("Aborting...")
return 0

if latest:
recording_id = len(recordings)

elif recording_id is None or not (1 <= recording_id <= len(recordings)):
logger.error("Invalid recording ID.")
return 1
recording_to_delete = recordings[recording_id - 1]

if click.confirm(
"Are you sure you want to delete recording"
f" {recording_to_delete.task_description} | {recording_to_delete.timestamp}?"
):
delete_recording(recording_to_delete.timestamp)
logger.info("Recording deleted.")
else:
logger.info("Aborting...")
return 0


if __name__ == "__main__":
remove()
3 changes: 2 additions & 1 deletion openadapt/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from scipy.spatial import distance
import numpy as np

from openadapt import common, crud, models, utils
from openadapt import common, models, utils
from openadapt.db import crud

MAX_PROCESS_ITERS = 1
MOUSE_MOVE_EVENT_MERGE_DISTANCE_THRESHOLD = 1
Expand Down
3 changes: 2 additions & 1 deletion openadapt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import numpy as np
import sqlalchemy as sa

from openadapt import config, db, window
from openadapt import config, window
from openadapt.db import db


# https://groups.google.com/g/sqlalchemy/c/wlr7sShU6-k
Expand Down
Loading

0 comments on commit ca04296

Please sign in to comment.