From ed115ea17c8d70c72312d9f7f0bb29d6a2702770 Mon Sep 17 00:00:00 2001 From: Jack Michaud Date: Mon, 2 Jan 2023 21:13:20 +0000 Subject: [PATCH] refactor: move OasstApiClient into oasst-shared (#287) * refactor: move api_client into oasst-shared * refactor: move contract tests into oasst-shared * fix: use new OasstApiClient imports in discord bot --- .github/workflows/test-api-contract.yaml | 11 +++-------- discord-bot/bot/bot.py | 2 +- discord-bot/bot/extensions/work.py | 2 +- .../bot => oasst-shared/oasst_shared}/api_client.py | 0 {discord-bot => oasst-shared}/requirements.dev.txt | 0 .../tests/test_oasst_api_client.py | 2 +- .../test.sh | 2 +- 7 files changed, 7 insertions(+), 12 deletions(-) rename {discord-bot/bot => oasst-shared/oasst_shared}/api_client.py (100%) rename {discord-bot => oasst-shared}/requirements.dev.txt (100%) rename {discord-bot => oasst-shared}/tests/test_oasst_api_client.py (97%) rename scripts/{discord-bot-development => oasst-shared-development}/test.sh (76%) diff --git a/.github/workflows/test-api-contract.yaml b/.github/workflows/test-api-contract.yaml index e75e5375..3707f4de 100644 --- a/.github/workflows/test-api-contract.yaml +++ b/.github/workflows/test-api-contract.yaml @@ -18,18 +18,13 @@ jobs: - run: cd oasst-shared && pip install -e . + - run: cd oasst-shared && pip install -r requirements.dev.txt + - run: cd backend && pip install -r requirements.txt - - run: cd discord-bot && pip install -r requirements.txt - - - run: cd discord-bot && pip install -r requirements.dev.txt - - run: ./scripts/backend-development/start-mock-server.sh - # runs the contract tests. currently the api client is - # found in the discord bot code, but this should be updated - # once the client moves into oasst-shared. - name: Run contract tests - run: ./scripts/discord-bot-development/test.sh + run: ./scripts/oasst-shared-development/test.sh - run: ./scripts/backend-development/stop-mock-server.sh diff --git a/discord-bot/bot/bot.py b/discord-bot/bot/bot.py index 35a3fb23..df3c5f2f 100644 --- a/discord-bot/bot/bot.py +++ b/discord-bot/bot/bot.py @@ -5,9 +5,9 @@ import aiosqlite import hikari import lightbulb import miru -from bot.api_client import OasstApiClient from bot.settings import Settings from bot.utils import EMPTY, mention +from oasst_shared.api_client import OasstApiClient settings = Settings() diff --git a/discord-bot/bot/extensions/work.py b/discord-bot/bot/extensions/work.py index 767e05ac..19802c64 100644 --- a/discord-bot/bot/extensions/work.py +++ b/discord-bot/bot/extensions/work.py @@ -8,10 +8,10 @@ import lightbulb import lightbulb.decorators import miru from aiosqlite import Connection -from bot.api_client import OasstApiClient, TaskType from bot.db.schemas import GuildSettings from bot.utils import EMPTY from loguru import logger +from oasst_shared.api_client import OasstApiClient, TaskType from oasst_shared.schemas import protocol as protocol_schema from oasst_shared.schemas.protocol import TaskRequestType diff --git a/discord-bot/bot/api_client.py b/oasst-shared/oasst_shared/api_client.py similarity index 100% rename from discord-bot/bot/api_client.py rename to oasst-shared/oasst_shared/api_client.py diff --git a/discord-bot/requirements.dev.txt b/oasst-shared/requirements.dev.txt similarity index 100% rename from discord-bot/requirements.dev.txt rename to oasst-shared/requirements.dev.txt diff --git a/discord-bot/tests/test_oasst_api_client.py b/oasst-shared/tests/test_oasst_api_client.py similarity index 97% rename from discord-bot/tests/test_oasst_api_client.py rename to oasst-shared/tests/test_oasst_api_client.py index 9b0ff383..be757e8f 100644 --- a/discord-bot/tests/test_oasst_api_client.py +++ b/oasst-shared/tests/test_oasst_api_client.py @@ -1,7 +1,7 @@ from uuid import uuid4 import pytest -from bot.api_client import OasstApiClient +from oasst_shared.api_client import OasstApiClient from oasst_shared.schemas import protocol as protocol_schema diff --git a/scripts/discord-bot-development/test.sh b/scripts/oasst-shared-development/test.sh similarity index 76% rename from scripts/discord-bot-development/test.sh rename to scripts/oasst-shared-development/test.sh index a45adf00..e9324196 100755 --- a/scripts/discord-bot-development/test.sh +++ b/scripts/oasst-shared-development/test.sh @@ -2,7 +2,7 @@ parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) # switch to backend directory -pushd "$parent_path/../../discord-bot" +pushd "$parent_path/../../oasst-shared" pytest .