Skip to content

Commit

Permalink
🎨 Pull testuser API keys from AWS secrets (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf authored Jan 6, 2024
1 parent 1bd25e9 commit 9cb4aa2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
ssh-key: ${{ secrets.READ_LNDOCS }}
path: lndocs
ref: main
- name: Setup Python
uses: actions/setup-python@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Cache pre-commit
Expand All @@ -39,8 +38,11 @@ jobs:
path: |
~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- run: |
python -m pip install --upgrade pip
pip install nox
- run: pip install nox
- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- run: nox -s lint
- run: nox -s build
30 changes: 23 additions & 7 deletions laminci/nox.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
from pathlib import Path
from typing import Dict, Optional
Expand All @@ -9,20 +10,35 @@
from ._env import get_package_name


def login_testuser1(session: Session, env: Optional[Dict[str, str]] = None):
def _login_lamin_user(user_email: str, env: Optional[Dict[str, str]] = None):
import boto3
import lamindb_setup as ln_setup

if env is not None:
os.environ.update(env)
ln_setup.login("[email protected]", key="cEvcwMJFX4OwbsYVaMt2Os6GxxGgDUlBGILs2RyS")
session = boto3.session.Session()
client = session.client(
service_name="secretsmanager",
region_name="us-east-1",
)
arn = (
"arn:aws:secretsmanager:us-east-1:586130067823:secret:laminlabs-internal-sZj1MU"
)
secrets = json.loads(client.get_secret_value(SecretId=arn)["SecretString"])
if user_email == "[email protected]":
ln_setup.login(user_email, key=secrets["LAMIN_TESTUSER1_API_KEY"])
elif user_email == "[email protected]":
ln_setup.login(user_email, key=secrets["LAMIN_TESTUSER2_API_KEY"])
else:
raise NotImplementedError


def login_testuser2(session: Session, env: Optional[Dict[str, str]] = None):
import lamindb_setup as ln_setup
def login_testuser1(session: Session, env: Optional[Dict[str, str]] = None):
_login_lamin_user("[email protected]", env=env)

if env is not None:
os.environ.update(env)
ln_setup.login("[email protected]", key="goeoNJKE61ygbz1vhaCVynGERaRrlviPBVQsjkhz")

def login_testuser2(session: Session, env: Optional[Dict[str, str]] = None):
_login_lamin_user("[email protected]", env=env)


def run_pre_commit(session: Session):
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ dev = [
"pre-commit",
"pytest>=6.0",
"pytest-cov",
"boto3",
"lamindb_setup",
]

[project.scripts]
Expand Down
5 changes: 5 additions & 0 deletions tests/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from laminci.nox import _login_lamin_user


def test_login_testuser1():
_login_lamin_user("[email protected]")

0 comments on commit 9cb4aa2

Please sign in to comment.