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

Simplify group usage in poetry #41

Merged
merged 12 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion .github/workflows/pytest_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
poetry config virtualenvs.in-project true
- name: Install dependencies with Poetry
run: |
poetry install --with api
poetry install
- name: Run tests with coverage using Poetry
run: >
poetry run pytest tests --cov=./ --cov-report=term
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Report
on:
workflow_dispatch: null
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies with Poetry
run: |
poetry install
- name: Run report
run: >
MOCK_TA1=FALSE poetry run poe report
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export LANG
# Initializes submodules and copies environment file sample to env file.
.PHONY:init
init:.env
poetry install --with api
poetry install
poetry run pre-commit install
git submodule update --init;

Expand Down
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY --from=tmp / /
WORKDIR /
RUN pip install --no-cache-dir poetry==1.5.1
RUN poetry config virtualenvs.create false && \
poetry install --no-root --no-cache --with api
poetry install --no-root --no-cache

COPY api knowledge-middleware/api
COPY lib knowledge-middleware/lib
Expand Down
5 changes: 4 additions & 1 deletion env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ MIT_TR_URL=http://mit-tr.staging.terarium.ai
LOG_LEVEL=INFO
MOCK_TA1=True
MOCK_TDSt=True
OPENAI_API_KEY=foo
OPENAI_API_KEY=foo
fivegrant marked this conversation as resolved.
Show resolved Hide resolved
AWS_ACCESS_KEY_ID=NA
AWS_SECRET_ACCESS_KEY=NA
BUCKET=NA
3 changes: 3 additions & 0 deletions lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Settings(BaseSettings):
TDS_URL: str = "http://tds:15"
OPENAI_API_KEY: str = "foo"
LOG_LEVEL: str = "INFO"
AWS_ACCESS_KEY_ID: str = "NA"
AWS_SECRET_ACCESS_KEY: str = "NA"
BUCKET: str = "NA"


settings = Settings()
1,047 changes: 257 additions & 790 deletions poetry.lock

Large diffs are not rendered by default.

19 changes: 4 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,25 @@ python-multipart = "^0.0.6"
pandas = "^2.0.3"
requests = "^2.31.0"
pydantic-settings = "^2.0.3"
streamlit = "^1.26.0"


[tool.poetry.group.api]
optional = true

[tool.poetry.group.api.dependencies]
uvicorn = "^0.22.0"
fastapi = "^0.100.0"
pypdf = "^3.12.0"
boto3 = "^1.28.44"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
httpx = "^0.24.1"
fakeredis = "^2.18.0"
pytest-cov = "^4.1.0"
jsonschema = "^4.19.0"
service-test-tools = {git = "https://github.com/jataware/service-test-tools"}
yamllint = "^1.32.0"
poethepoet = "^0.22.0"
requests-mock = "^1.11.0"
pyyaml = "^6.0.1"
pre-commit = "^3.3.3"
pytest-json-report = "^1.5.0"


[tool.poetry.scripts]
status-test = "tests.report:test"
gen-report = "tests.report:report"

[tool.poe.tasks]
_test = "pytest --json-report --json-report-file=tests/output/tests.json"
_test = "status-test"
_report = "gen-report"
report.sequence = ["_test", "_report"]
report.ignore_fail = true
Expand Down
17 changes: 15 additions & 2 deletions tests/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
from collections import defaultdict

import yaml
import pytest
import boto3

from lib.settings import settings

def test(output_file="tests/output/tests.json"):
pytest.main(["--json-report", f"--json-report-file={output_file}"])


def report():
# TODO: Make this into a predefined struct
Expand Down Expand Up @@ -42,9 +50,14 @@ def add_case(testobj):
report[scenario]["description"] = spec["description"]

timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
filename = f"tests/output/report_{timestamp}.json"
with open(filename, "w") as file:
filename = f"report_{timestamp}.json"
fullpath = os.path.join("tests/output", "filename")
fivegrant marked this conversation as resolved.
Show resolved Hide resolved
with open(fullpath, "w") as file:
json.dump(report, file, indent=2)

s3 = boto3.client("s3")
full_handle = os.path.join("ta1", filename)
s3.upload_file(fullpath, settings.BUCKET, full_handle)

if __name__ == "__main__":
report()