Skip to content

Commit

Permalink
use dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole White committed Feb 22, 2024
1 parent e5d5710 commit 4d8464a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 24 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/autoblocks-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ jobs:
- name: Install dependencies
run: poetry install

- name: Create .env file
run: |
touch .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "AUTOBLOCKS_API_KEY=${{ secrets.AUTOBLOCKS_API_KEY }}" >> .env
- name: Run Autoblocks tests
run: npx autoblocks testing exec -- poetry run start
env:
# Add your OpenAI API key & Autoblocks API key to the repository secrets.
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AUTOBLOCKS_API_KEY: ${{ secrets.AUTOBLOCKS_API_KEY }}
37 changes: 18 additions & 19 deletions Python/testing-sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- banner start -->
<p align="center">
<img src="https://app.autoblocks.ai/images/logo.png" width="150px">
<img src="https://app.autoblocks.ai/images/logo.png" width="300px">
</p>

<p align="center">
📚
<a href="https://docs.autoblocks.ai/">Documentation</a>
Expand All @@ -12,9 +14,22 @@
&nbsp;
&nbsp;
☎️
<a href="https://cal.frontapp.com/autoblocks/adam/autoblocks-engineering/">Meet with Autoblocks Engineering</a>
🏠
<a href="https://www.autoblocks.ai/">Home</a>
</p>
<!-- banner end -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks **local testing API key** from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_API_KEY=<your-api-key>
```

## Setup

Expand Down Expand Up @@ -56,22 +71,6 @@ poetry install

## Run Autoblocks tests

### Set your Autoblocks API key

Retrieve your **local testing API key** from the [settings page](https://app.autoblocks.ai/settings/api-keys) and set it as an environment variable:

```bash
export AUTOBLOCKS_API_KEY=...
```

### Set your OpenAI API key

```bash
export OPENAI_API_KEY=...
```

### Run the tests

```bash
npx autoblocks testing exec -m "my first run" -- poetry run start
```
Expand Down
5 changes: 5 additions & 0 deletions Python/testing-sdk/my_project/run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import dotenv

from my_project.test_suites import flashcard_generator
from my_project.test_suites import study_guide_outline


dotenv.load_dotenv(".env")


def run():
# Autoblocks handles running these tests asynchronously behind the scenes
# in a dedicated event loop, so no need to attempt to add any concurrency
Expand Down
16 changes: 15 additions & 1 deletion Python/testing-sdk/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Python/testing-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ packages = [{include = "my_project"}]
python = "^3.11"
autoblocksai = ">=0.0.27"
openai = "^1.0.0"
python-dotenv = "^1.0.1"

[tool.poetry.scripts]
# This will execute the run() function in my_project/run.py
Expand Down

0 comments on commit 4d8464a

Please sign in to comment.