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

Refactor agentql repo #97

Merged
merged 11 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .dockerignore

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/js-precommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: JSPre-commit checks

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "examples/JS/**"

jobs:
js-pre-commit:
name: JS Pre-commit checks
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install dependencies
working-directory: ./examples/JS
run: npm install

- name: Run ESLint
working-directory: ./examples/JS
run: npm run lint

- name: Run Prettier
working-directory: ./examples/JS
run: npx prettier --check .
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Pre-commit checks
name: Python Pre-commit checks

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "examples/Python/**"

jobs:
python-pre-commit:
Expand Down Expand Up @@ -32,44 +34,25 @@ jobs:
# ----- install dependencies -----
#----------------------------------------------
- name: Install dependencies
working-directory: ./examples/Python
run: |
poetry install --no-interaction --no-root --with dev

- name: Lint check
working-directory: ./examples/Python
run: pylint --disable=R,C application_examples examples

- name: Code style check
working-directory: ./examples/Python
run: black . --check

- name: Imports sort check
working-directory: ./examples/Python
uses: isort/isort-action@master

- name: Static check
working-directory: ./examples/Python
uses: jakebailey/pyright-action@v2
continue-on-error: true
with:
pylance-version: latest-release

js-pre-commit:
name: JS Pre-commit checks
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install dependencies
working-directory: ./javascript-sdk
run: npm install

- name: Run ESLint
working-directory: ./javascript-sdk
run: npm run lint

- name: Run Prettier
working-directory: ./javascript-sdk
run: npx prettier --check .
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ tmp/

*env.local

javascript-sdk/node_modules
examples/JS/node_modules/
examples/Python/__pycache__/
examples/Python/.venv/
3 changes: 0 additions & 3 deletions .stylelintrc.js

This file was deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

please don't use capitalized folder names

File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"eslint.workingDirectories": [
{
"directory": "./javascript-sdk",
"directory": "./examples/JS",
"changeProcessCWD": true
}
],
Expand All @@ -34,8 +34,8 @@
],
"pylint.importStrategy": "fromEnvironment",
"pylint.args": [
"--rcfile=.pylintrc"
"--rcfile=./examples/Python/.pylintrc"
],
"python.analysis.typeCheckingMode": "standard",
"python.analysis.typeCheckingMode": "basic",
Copy link
Contributor

Choose a reason for hiding this comment

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

why and what's the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial thinking is that "basic" is more lenient in terms of reporting static type warnings/errors and might make it easier for others to contribute. But on a second thought, we should probably still make it standard to ensure code quality -- I will revert the change

"editor.rulers": [100]
}
File renamed without changes.
8 changes: 0 additions & 8 deletions .prettierignore → examples/JS/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,3 @@
!.*
.eslintcache
.lint-todo/

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to use AgentQL close a site's dialog for rejecting
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **close_cookie_dialog.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 close_cookies.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to close popup windows (like promotion form) with
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **close_popup.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 close_popup.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This is an example of how to collect pricing data from e-commerce website using
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **collect_pricing_data.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 collect_pricing_data.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to compare product prices across websites with que
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **compare_product_prices.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 compare_product_prices.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ This example demonstrates how to debug AgentQL scripts in both synchronous and a
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **debug_agentql_script.py** for debugging in **synchronous environment** or **async_debug_agentql_script.py** for debugging in **asynchronous environment**
- Save this python file locally as **main.py** for debugging in **synchronous environment** or **async_main.py** for debugging in **asynchronous environment**
- Run the following command from the project's folder:

```bash
python3 debug_agentql_script.py
python3 async_debug_agentql_script.py
python3 main.py
python3 async_main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This is an example of collecting pricing data from e-commerce website using Agen
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **first_steps.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 first_steps.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example shows how to use AgentQL's [`get_by_prompt`](https://docs.agentql.c
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **get_by_prompt.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 get_by_prompt.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to load additional content on pages that load cont
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **infinite_scroll.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 infinite_scroll.py
python3 main.py
```

## Adjust the scrolling method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example demonstrates how to interact with an external or existing browser w
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this Python file locally as **run_script_with_local_browser.py**
- Save this Python file locally as **main.py**
- Close your Google Chrome application if it is open.
- If you're using **Mac**, open the terminal and run the following command:

Expand All @@ -22,12 +22,12 @@ chrome.exe --remote-debugging-port=9222
**Make sure to replace `chrome.exe` with the path to your Chrome executable if it's not already in your system's PATH.**

- In the browser window that's opened, select the Google profile you would like to use for this session.
- In `run_script_with_local_browser.py`, replace variable `WEBSOCKET_URL`'s placeholder value with the actual WebSocket URL returned in terminal or command prompt. The URL should be in the format of `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
- In `main.py`, replace variable `WEBSOCKET_URL`'s placeholder value with the actual WebSocket URL returned in terminal or command prompt. The URL should be in the format of `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.

- Run the following command from the project's folder:

```bash
python3 run_script_with_local_browser.py
python3 main.py
```

- If you want to learn how to work with open pages, navigate to [Scrapeme website](https://scrapeme.live/shop/Charmander/) within the browser, and use `fetch_data_from_open_website_page()` method in the script to fetch data from the page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to query a list of items on the page.
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **list_query_usage.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 list_query_usage.py
python3 main.py
```

## Play with it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This is an example shows how to login into websites by retrieving and interactin
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **log_into_sites.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 log_into_sites.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This example demonstrates how to perform sentiment analysis on YouTube comments
pip install openai
```

- Save this python file locally as **perform_sentiment_analysis.py**
- Save this python file locally as **main.py**
- Set your OpenAI API key as an environment variable with the following command:

```bash
Expand All @@ -21,7 +21,7 @@ export OPENAI_API_KEY="My API Key"
- Run the following command from the project's folder:

```bash
python3 perform_sentiment_analysis.py
python3 main.py
```

## Play with the query
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to run the script in headless browser.
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **run_in_headless_browser.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 run_in_headless_browser.py
python3 main.py
```

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example demonstrates how to run AgentQL script in online development enviro
## Run the script

- Go to [Google Colaboratory](https://colab.research.google.com/) website
- Upload the **agentql.ipynb** file to Google Colab
- Upload the **main.ipynb** file to Google Colab
- Run the script by clicking the run button of each cell sequentially.

## Play with the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "NL1z6COzYn31"
},
"metadata": {},
"source": [
"This example demonstrates how to run AgentQL script in online development environment like [Google Colaboratory](https://colab.research.google.com/)."
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This example demonstrates how to save and load a authenticated state (i.e. signe
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/installation/sdk-installation)
- Save this python file locally as **save_and_load_authenticated_state.py**
- Save this python file locally as **main.py**
- Run the following command from the project's folder:

```bash
python3 save_and_load_authenticated_state.py
python3 main.py
```

## Play with the query
Expand Down
Loading
Loading