From 54da714471593513f47dee519544b01c593a49b2 Mon Sep 17 00:00:00 2001 From: Elijah Williams Date: Tue, 12 Nov 2024 15:39:56 -0700 Subject: [PATCH 1/3] remove spec work --- .vscode/settings.json | 3 +- api/api.yaml | 191 ------ api/defs/api_base.yaml | 8 - .../schemas/CloudConfiguration.yaml | 17 - .../schemas/CloudConfigurationAws.yaml | 17 - .../CloudConfigurationAwsInstanceProfile.yaml | 4 - .../schemas/CloudConfigurationAwsKey.yaml | 10 - .../CloudConfigurationCreateRequest.yaml | 13 - .../schemas/CloudConfigurationList.yaml | 9 - .../CloudConfigurationUpdateRequest.yaml | 13 - api/defs/paths/cloud.yaml | 89 --- api/generate.sh | 101 ---- api/generate_watch.sh | 5 - pybackend/.gitignore | 162 ----- pybackend/README.md | 1 - pybackend/pdm.lock | 244 -------- pybackend/pyproject.toml | 27 - pybackend/src/__init__.py | 0 pybackend/src/migration/__init__.py | 0 pybackend/src/migration/datastore.py | 183 ------ pybackend/src/migration/migrator.py | 106 ---- .../migration/sqlite/1_cloud_config.down.sql | 1 - .../migration/sqlite/1_cloud_config.up.sql | 4 - pybackend/src/openapi_server/__init__.py | 0 pybackend/src/openapi_server/apis/__init__.py | 0 .../openapi_server/apis/config_cloud_api.py | 123 ---- .../apis/config_cloud_api_base.py | 51 -- pybackend/src/openapi_server/main.py | 25 - .../src/openapi_server/models/__init__.py | 0 .../models/cloud_configuration.py | 98 --- .../models/cloud_configuration_aws.py | 94 --- .../models/cloud_configuration_aws_aws.py | 96 --- .../cloud_configuration_aws_aws_type.py | 148 ----- ...loud_configuration_aws_instance_profile.py | 44 -- .../models/cloud_configuration_aws_key.py | 92 --- .../cloud_configuration_configuration.py | 134 ----- .../cloud_configuration_create_request.py | 96 --- .../models/cloud_configuration_list.py | 98 --- .../cloud_configuration_update_request.py | 96 --- .../src/openapi_server/models/extra_models.py | 8 - pybackend/src/openapi_server/models/object.py | 117 ---- pybackend/src/openapi_server/security_api.py | 20 - pybackend/tests/__init__.py | 0 pybackend/tests/migration/test_sqlite.py | 59 -- ui/package.json | 1 - ui/pnpm-lock.yaml | 30 - ui/src/services/api/api.ts | 565 ------------------ ui/src/services/api/base.ts | 85 --- ui/src/services/api/common.ts | 149 ----- ui/src/services/api/configuration.ts | 109 ---- ui/src/services/api_config.ts | 10 - 51 files changed, 1 insertion(+), 3555 deletions(-) delete mode 100644 api/api.yaml delete mode 100644 api/defs/api_base.yaml delete mode 100644 api/defs/components/schemas/CloudConfiguration.yaml delete mode 100644 api/defs/components/schemas/CloudConfigurationAws.yaml delete mode 100644 api/defs/components/schemas/CloudConfigurationAwsInstanceProfile.yaml delete mode 100644 api/defs/components/schemas/CloudConfigurationAwsKey.yaml delete mode 100644 api/defs/components/schemas/CloudConfigurationCreateRequest.yaml delete mode 100644 api/defs/components/schemas/CloudConfigurationList.yaml delete mode 100644 api/defs/components/schemas/CloudConfigurationUpdateRequest.yaml delete mode 100644 api/defs/paths/cloud.yaml delete mode 100755 api/generate.sh delete mode 100755 api/generate_watch.sh delete mode 100644 pybackend/.gitignore delete mode 100644 pybackend/README.md delete mode 100644 pybackend/pdm.lock delete mode 100644 pybackend/pyproject.toml delete mode 100644 pybackend/src/__init__.py delete mode 100644 pybackend/src/migration/__init__.py delete mode 100644 pybackend/src/migration/datastore.py delete mode 100644 pybackend/src/migration/migrator.py delete mode 100644 pybackend/src/migration/sqlite/1_cloud_config.down.sql delete mode 100644 pybackend/src/migration/sqlite/1_cloud_config.up.sql delete mode 100644 pybackend/src/openapi_server/__init__.py delete mode 100644 pybackend/src/openapi_server/apis/__init__.py delete mode 100644 pybackend/src/openapi_server/apis/config_cloud_api.py delete mode 100644 pybackend/src/openapi_server/apis/config_cloud_api_base.py delete mode 100644 pybackend/src/openapi_server/main.py delete mode 100644 pybackend/src/openapi_server/models/__init__.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_aws.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_aws_aws.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_aws_aws_type.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_aws_instance_profile.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_aws_key.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_configuration.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_create_request.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_list.py delete mode 100644 pybackend/src/openapi_server/models/cloud_configuration_update_request.py delete mode 100644 pybackend/src/openapi_server/models/extra_models.py delete mode 100644 pybackend/src/openapi_server/models/object.py delete mode 100644 pybackend/src/openapi_server/security_api.py delete mode 100644 pybackend/tests/__init__.py delete mode 100644 pybackend/tests/migration/test_sqlite.py delete mode 100644 ui/src/services/api/api.ts delete mode 100644 ui/src/services/api/base.ts delete mode 100644 ui/src/services/api/common.ts delete mode 100644 ui/src/services/api/configuration.ts delete mode 100644 ui/src/services/api_config.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 113f5cf5f..050505ce7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,3 @@ { - "java.configuration.updateBuildConfiguration": "interactive", - "python.analysis.extraPaths": ["./pybackend"] + "java.configuration.updateBuildConfiguration": "interactive" } diff --git a/api/api.yaml b/api/api.yaml deleted file mode 100644 index 264df856c..000000000 --- a/api/api.yaml +++ /dev/null @@ -1,191 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: RAG Studio API - license: - name: MIT -servers: - - url: http://localhost:8000/api/v1 -paths: - /configurations/cloud: - get: - summary: List cloud configurations - operationId: listCloudConfigurations - tags: - - config_cloud - responses: - '200': - description: List of clouds - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfigurationList' - post: - summary: Create a cloud configuration - operationId: createCloudConfiguration - tags: - - config_cloud - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfigurationCreateRequest' - responses: - '200': - description: Cloud configuration - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfiguration' - - /configurations/cloud/{id}: - get: - summary: Get a cloud configuration - operationId: getCloudConfiguration - tags: - - config_cloud - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: Cloud configuration - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfiguration' - put: - summary: Update a cloud configuration - operationId: updateCloudConfiguration - tags: - - config_cloud - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfigurationUpdateRequest' - responses: - '200': - description: Cloud configuration - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfiguration' - delete: - summary: Delete a cloud configuration - operationId: deleteCloudConfiguration - tags: - - config_cloud - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: Cloud configuration deleted - -components: - schemas: - CloudConfiguration: - type: object - required: - - id - - name - - configuration - properties: - id: - type: string - description: Cloud configuration ID - name: - type: string - description: Cloud configuration name - configuration: - type: object - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAws' - - CloudConfigurationAws: - type: object - required: - - aws - properties: - aws: - type: object - required: - - region - - type - properties: - region: - type: string - type: - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAwsInstanceProfile' - - $ref: '#/components/schemas/CloudConfigurationAwsKey' - - CloudConfigurationAwsInstanceProfile: - type: string - enum: - - instance_profile - - CloudConfigurationAwsKey: - type: object - required: - - access_key_id - - secret_access_key - properties: - access_key_id: - type: string - secret_access_key: - type: string - - CloudConfigurationCreateRequest: - type: object - required: - - name - - configuration - properties: - name: - type: string - description: Cloud configuration name - configuration: - type: object - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAws' - - CloudConfigurationList: - type: object - required: - - items - properties: - items: - type: array - items: - $ref: "#/components/schemas/CloudConfiguration" - - CloudConfigurationUpdateRequest: - type: object - required: - - name - - configuration - properties: - name: - type: string - description: Cloud configuration name - configuration: - type: object - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAws' - diff --git a/api/defs/api_base.yaml b/api/defs/api_base.yaml deleted file mode 100644 index 0d5c87b1d..000000000 --- a/api/defs/api_base.yaml +++ /dev/null @@ -1,8 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: RAG Studio API - license: - name: MIT -servers: - - url: http://localhost:8000/api/v1 diff --git a/api/defs/components/schemas/CloudConfiguration.yaml b/api/defs/components/schemas/CloudConfiguration.yaml deleted file mode 100644 index cf1c291bf..000000000 --- a/api/defs/components/schemas/CloudConfiguration.yaml +++ /dev/null @@ -1,17 +0,0 @@ -CloudConfiguration: - type: object - required: - - id - - name - - configuration - properties: - id: - type: string - description: Cloud configuration ID - name: - type: string - description: Cloud configuration name - configuration: - type: object - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAws' diff --git a/api/defs/components/schemas/CloudConfigurationAws.yaml b/api/defs/components/schemas/CloudConfigurationAws.yaml deleted file mode 100644 index f535f5227..000000000 --- a/api/defs/components/schemas/CloudConfigurationAws.yaml +++ /dev/null @@ -1,17 +0,0 @@ -CloudConfigurationAws: - type: object - required: - - aws - properties: - aws: - type: object - required: - - region - - type - properties: - region: - type: string - type: - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAwsInstanceProfile' - - $ref: '#/components/schemas/CloudConfigurationAwsKey' diff --git a/api/defs/components/schemas/CloudConfigurationAwsInstanceProfile.yaml b/api/defs/components/schemas/CloudConfigurationAwsInstanceProfile.yaml deleted file mode 100644 index 2b4e18927..000000000 --- a/api/defs/components/schemas/CloudConfigurationAwsInstanceProfile.yaml +++ /dev/null @@ -1,4 +0,0 @@ -CloudConfigurationAwsInstanceProfile: - type: string - enum: - - instance_profile diff --git a/api/defs/components/schemas/CloudConfigurationAwsKey.yaml b/api/defs/components/schemas/CloudConfigurationAwsKey.yaml deleted file mode 100644 index b9e3db9d9..000000000 --- a/api/defs/components/schemas/CloudConfigurationAwsKey.yaml +++ /dev/null @@ -1,10 +0,0 @@ -CloudConfigurationAwsKey: - type: object - required: - - access_key_id - - secret_access_key - properties: - access_key_id: - type: string - secret_access_key: - type: string diff --git a/api/defs/components/schemas/CloudConfigurationCreateRequest.yaml b/api/defs/components/schemas/CloudConfigurationCreateRequest.yaml deleted file mode 100644 index ab5ccd2fe..000000000 --- a/api/defs/components/schemas/CloudConfigurationCreateRequest.yaml +++ /dev/null @@ -1,13 +0,0 @@ -CloudConfigurationCreateRequest: - type: object - required: - - name - - configuration - properties: - name: - type: string - description: Cloud configuration name - configuration: - type: object - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAws' diff --git a/api/defs/components/schemas/CloudConfigurationList.yaml b/api/defs/components/schemas/CloudConfigurationList.yaml deleted file mode 100644 index acf07af26..000000000 --- a/api/defs/components/schemas/CloudConfigurationList.yaml +++ /dev/null @@ -1,9 +0,0 @@ -CloudConfigurationList: - type: object - required: - - items - properties: - items: - type: array - items: - $ref: "#/components/schemas/CloudConfiguration" diff --git a/api/defs/components/schemas/CloudConfigurationUpdateRequest.yaml b/api/defs/components/schemas/CloudConfigurationUpdateRequest.yaml deleted file mode 100644 index fc9a36607..000000000 --- a/api/defs/components/schemas/CloudConfigurationUpdateRequest.yaml +++ /dev/null @@ -1,13 +0,0 @@ -CloudConfigurationUpdateRequest: - type: object - required: - - name - - configuration - properties: - name: - type: string - description: Cloud configuration name - configuration: - type: object - oneOf: - - $ref: '#/components/schemas/CloudConfigurationAws' diff --git a/api/defs/paths/cloud.yaml b/api/defs/paths/cloud.yaml deleted file mode 100644 index e2f7ebb08..000000000 --- a/api/defs/paths/cloud.yaml +++ /dev/null @@ -1,89 +0,0 @@ -/configurations/cloud: - get: - summary: List cloud configurations - operationId: listCloudConfigurations - tags: - - config_cloud - responses: - '200': - description: List of clouds - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfigurationList' - post: - summary: Create a cloud configuration - operationId: createCloudConfiguration - tags: - - config_cloud - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfigurationCreateRequest' - responses: - '200': - description: Cloud configuration - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfiguration' - -/configurations/cloud/{id}: - get: - summary: Get a cloud configuration - operationId: getCloudConfiguration - tags: - - config_cloud - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: Cloud configuration - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfiguration' - put: - summary: Update a cloud configuration - operationId: updateCloudConfiguration - tags: - - config_cloud - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfigurationUpdateRequest' - responses: - '200': - description: Cloud configuration - content: - application/json: - schema: - $ref: '#/components/schemas/CloudConfiguration' - delete: - summary: Delete a cloud configuration - operationId: deleteCloudConfiguration - tags: - - config_cloud - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: Cloud configuration deleted diff --git a/api/generate.sh b/api/generate.sh deleted file mode 100755 index df6e0528c..000000000 --- a/api/generate.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -# Merge the base API spec -cat defs/api_base.yaml > api.yaml - -# Add the paths section -echo 'paths:' >> api.yaml -for file in defs/paths/*.yaml; do - echo "Adding $file to api.yaml" - cat "$file" | sed 's/^/ /' >> api.yaml - echo '' >> api.yaml -done - - -# Add each component file to the API spec, with the proper indentation -echo 'components:' >> api.yaml -echo ' schemas:' >> api.yaml -for file in defs/components/schemas/*.yaml; do - echo "Adding $file to api.yaml" - cat "$file" | sed 's/^/ /' >> api.yaml - echo '' >> api.yaml -done - -echo "Generating API client" -openapi-generator-cli generate -i api.yaml -g typescript-axios -o typescript-client -rm openapitools.json -mkdir -p ../ui/src/services/api/ -mv typescript-client/api.ts ../ui/src/services/api/api.ts -mv typescript-client/base.ts ../ui/src/services/api/base.ts -mv typescript-client/common.ts ../ui/src/services/api/common.ts -mv typescript-client/configuration.ts ../ui/src/services/api/configuration.ts -for f in ../ui/src/services/api/*.ts; do - echo "Fixing $f" - # Remove the first line - sed -i'.bak' '1d' "$f" - rm "${f}.bak" -done -rm -rf typescript-client - -echo "Generating FastAPI server" -openapi-generator-cli generate -i api.yaml -g python-fastapi -o fastapi-server -# For each file in the apis, fix the "file" representation -for f in fastapi-server/src/openapi_server/apis/*.py; do - echo "Fixing $f" - # Import FileResponse above "from fastapi import" - sed -i'.bak' 's/from fastapi import/from fastapi.responses import FileResponse\nfrom fastapi import/g' "$f" - rm "${f}.bak" - # Import File and UploadFile above "from fastapi import" - sed -i'.bak' 's/from fastapi import/from fastapi import File, UploadFile\nfrom fastapi import/g' "$f" - rm "${f}.bak" - # Import FilwResponse below "from typing import ClassVar, Dict, List, Tuple" - sed -i'.bak' 's/from typing import ClassVar, Dict, List, Tuple/from typing import ClassVar, Dict, List, Tuple\nfrom fastapi.responses import FileResponse/g' "$f" - rm "${f}.bak" - # Import File and UploadFile below "from typing import ClassVar, Dict, List, Tuple" - sed -i'.bak' 's/from typing import ClassVar, Dict, List, Tuple/from typing import ClassVar, Dict, List, Tuple\nfrom fastapi import File, UploadFile/g' "$f" - rm "${f}.bak" - # Replace returns like "-> file" with "-> FileResponse" - sed -i'.bak' 's/-> file/-> FileResponse/g' "$f" - rm "${f}.bak" - # Replace models like '"model": file' with '"model": FileResponse' - sed -i'.bak' 's/"model": file/"model": FileResponse/g' "$f" - rm "${f}.bak" - # Replace "file: str = Form(None, " with "file: UploadFile = File(..." - sed -i'.bak' 's/file: str = Form(None,/file: UploadFile = File(...,/g' "$f" - rm "${f}.bak" - # Replace "file: str" with "file: UploadFile" - sed -i'.bak' 's/file: str/file: UploadFile/g' "$f" - rm "${f}.bak" - # Use sed to search for responses containing "model": FileResponse and replace it with response_class since FileResponse is not a valid type in FastAPI - sed -i'.bak' '/responses={/{N;N;s/ responses={\n 200: {"model": FileResponse,.*\n },/ response_class=FileResponse,/;}' "$f" - rm "${f}.bak" - # Add prefix to the routes - sed -i'.bak' 's,router = APIRouter(),router = APIRouter(prefix="/api/v1"),g' "$f" - rm "${f}.bak" - # Remove async/await from the routes - sed -i'.bak' 's/async //g' "$f" - rm "${f}.bak" - sed -i'.bak' 's/await //g' "$f" - rm "${f}.bak" -done -for f in fastapi-server/src/openapi_server/models/*.py; do - echo "Fixing $f" - # Replace "import object" with "import ObjectModel" - sed -i'.bak' 's/import object/import ObjectModel/g' "$f" - rm "${f}.bak" - # Replace "class ...(object)" with "class ...(ObjectModel)" - sed -i'.bak' 's/class \([^ ]*\)(object)/class \1(ObjectModel)/g' "$f" - rm "${f}.bak" -done - -rm openapitools.json -mkdir -p ../pybackend/src/openapi_server/ -rm -rf fastapi-server/src/openapi_server/impl -rm -rf ../pybackend/src/openapi_server/apis -rm -rf ../pybackend/src/openapi_server/models -mv fastapi-server/src/openapi_server/* ../pybackend/src/openapi_server/ -rm -rf fastapi-server -git checkout -- ../pybackend/src/openapi_server/models/object.py - diff --git a/api/generate_watch.sh b/api/generate_watch.sh deleted file mode 100755 index ada6e1fe3..000000000 --- a/api/generate_watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -fswatch -o ./defs | xargs -n1 ./generate.sh \ No newline at end of file diff --git a/pybackend/.gitignore b/pybackend/.gitignore deleted file mode 100644 index 3a8816c9e..000000000 --- a/pybackend/.gitignore +++ /dev/null @@ -1,162 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm-project.org/#use-with-ide -.pdm.toml -.pdm-python -.pdm-build/ - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/pybackend/README.md b/pybackend/README.md deleted file mode 100644 index 1527820e1..000000000 --- a/pybackend/README.md +++ /dev/null @@ -1 +0,0 @@ -# pybackend diff --git a/pybackend/pdm.lock b/pybackend/pdm.lock deleted file mode 100644 index 6620f7030..000000000 --- a/pybackend/pdm.lock +++ /dev/null @@ -1,244 +0,0 @@ -# This file is @generated by PDM. -# It is not intended for manual editing. - -[metadata] -groups = ["default", "dev"] -strategy = ["inherit_metadata"] -lock_version = "4.5.0" -content_hash = "sha256:fb2ee325cf49f85df5c43b6c75818240ce03d4cb581eed8686c3ccad7fa83647" - -[[metadata.targets]] -requires_python = "==3.10.*" - -[[package]] -name = "annotated-types" -version = "0.7.0" -requires_python = ">=3.8" -summary = "Reusable constraint types to use with typing.Annotated" -groups = ["default"] -dependencies = [ - "typing-extensions>=4.0.0; python_version < \"3.9\"", -] -files = [ - {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, - {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, -] - -[[package]] -name = "anyio" -version = "4.6.2.post1" -requires_python = ">=3.9" -summary = "High level compatibility layer for multiple asynchronous event loop implementations" -groups = ["default"] -dependencies = [ - "exceptiongroup>=1.0.2; python_version < \"3.11\"", - "idna>=2.8", - "sniffio>=1.1", - "typing-extensions>=4.1; python_version < \"3.11\"", -] -files = [ - {file = "anyio-4.6.2.post1-py3-none-any.whl", hash = "sha256:6d170c36fba3bdd840c73d3868c1e777e33676a69c3a72cf0a0d5d6d8009b61d"}, - {file = "anyio-4.6.2.post1.tar.gz", hash = "sha256:4c8bc31ccdb51c7f7bd251f51c609e038d63e34219b44aa86e47576389880b4c"}, -] - -[[package]] -name = "colorama" -version = "0.4.6" -requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -summary = "Cross-platform colored terminal text." -groups = ["dev"] -marker = "sys_platform == \"win32\"" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - -[[package]] -name = "exceptiongroup" -version = "1.2.2" -requires_python = ">=3.7" -summary = "Backport of PEP 654 (exception groups)" -groups = ["default", "dev"] -marker = "python_version < \"3.11\"" -files = [ - {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, - {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, -] - -[[package]] -name = "fastapi" -version = "0.115.4" -requires_python = ">=3.8" -summary = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" -groups = ["default"] -dependencies = [ - "pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4", - "starlette<0.42.0,>=0.40.0", - "typing-extensions>=4.8.0", -] -files = [ - {file = "fastapi-0.115.4-py3-none-any.whl", hash = "sha256:0b504a063ffb3cf96a5e27dc1bc32c80ca743a2528574f9cdc77daa2d31b4742"}, - {file = "fastapi-0.115.4.tar.gz", hash = "sha256:db653475586b091cb8b2fec2ac54a680ac6a158e07406e1abae31679e8826349"}, -] - -[[package]] -name = "idna" -version = "3.10" -requires_python = ">=3.6" -summary = "Internationalized Domain Names in Applications (IDNA)" -groups = ["default"] -files = [ - {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, - {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, -] - -[[package]] -name = "iniconfig" -version = "2.0.0" -requires_python = ">=3.7" -summary = "brain-dead simple config-ini parsing" -groups = ["dev"] -files = [ - {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, - {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, -] - -[[package]] -name = "packaging" -version = "24.1" -requires_python = ">=3.8" -summary = "Core utilities for Python packages" -groups = ["dev"] -files = [ - {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, - {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, -] - -[[package]] -name = "pluggy" -version = "1.5.0" -requires_python = ">=3.8" -summary = "plugin and hook calling mechanisms for python" -groups = ["dev"] -files = [ - {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, - {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, -] - -[[package]] -name = "pydantic" -version = "2.9.2" -requires_python = ">=3.8" -summary = "Data validation using Python type hints" -groups = ["default"] -dependencies = [ - "annotated-types>=0.6.0", - "pydantic-core==2.23.4", - "typing-extensions>=4.12.2; python_version >= \"3.13\"", - "typing-extensions>=4.6.1; python_version < \"3.13\"", -] -files = [ - {file = "pydantic-2.9.2-py3-none-any.whl", hash = "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12"}, - {file = "pydantic-2.9.2.tar.gz", hash = "sha256:d155cef71265d1e9807ed1c32b4c8deec042a44a50a4188b25ac67ecd81a9c0f"}, -] - -[[package]] -name = "pydantic-core" -version = "2.23.4" -requires_python = ">=3.8" -summary = "Core functionality for Pydantic validation and serialization" -groups = ["default"] -dependencies = [ - "typing-extensions!=4.7.0,>=4.6.0", -] -files = [ - {file = "pydantic_core-2.23.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:b10bd51f823d891193d4717448fab065733958bdb6a6b351967bd349d48d5c9b"}, - {file = "pydantic_core-2.23.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4fc714bdbfb534f94034efaa6eadd74e5b93c8fa6315565a222f7b6f42ca1166"}, - {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63e46b3169866bd62849936de036f901a9356e36376079b05efa83caeaa02ceb"}, - {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed1a53de42fbe34853ba90513cea21673481cd81ed1be739f7f2efb931b24916"}, - {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cfdd16ab5e59fc31b5e906d1a3f666571abc367598e3e02c83403acabc092e07"}, - {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:255a8ef062cbf6674450e668482456abac99a5583bbafb73f9ad469540a3a232"}, - {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a7cd62e831afe623fbb7aabbb4fe583212115b3ef38a9f6b71869ba644624a2"}, - {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f09e2ff1f17c2b51f2bc76d1cc33da96298f0a036a137f5440ab3ec5360b624f"}, - {file = "pydantic_core-2.23.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e38e63e6f3d1cec5a27e0afe90a085af8b6806ee208b33030e65b6516353f1a3"}, - {file = "pydantic_core-2.23.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0dbd8dbed2085ed23b5c04afa29d8fd2771674223135dc9bc937f3c09284d071"}, - {file = "pydantic_core-2.23.4-cp310-none-win32.whl", hash = "sha256:6531b7ca5f951d663c339002e91aaebda765ec7d61b7d1e3991051906ddde119"}, - {file = "pydantic_core-2.23.4-cp310-none-win_amd64.whl", hash = "sha256:7c9129eb40958b3d4500fa2467e6a83356b3b61bfff1b414c7361d9220f9ae8f"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:f455ee30a9d61d3e1a15abd5068827773d6e4dc513e795f380cdd59932c782d5"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1e90d2e3bd2c3863d48525d297cd143fe541be8bbf6f579504b9712cb6b643ec"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e203fdf807ac7e12ab59ca2bfcabb38c7cf0b33c41efeb00f8e5da1d86af480"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e08277a400de01bc72436a0ccd02bdf596631411f592ad985dcee21445bd0068"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f220b0eea5965dec25480b6333c788fb72ce5f9129e8759ef876a1d805d00801"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d06b0c8da4f16d1d1e352134427cb194a0a6e19ad5db9161bf32b2113409e728"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ba1a0996f6c2773bd83e63f18914c1de3c9dd26d55f4ac302a7efe93fb8e7433"}, - {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:9a5bce9d23aac8f0cf0836ecfc033896aa8443b501c58d0602dbfd5bd5b37753"}, - {file = "pydantic_core-2.23.4.tar.gz", hash = "sha256:2584f7cf844ac4d970fba483a717dbe10c1c1c96a969bf65d61ffe94df1b2863"}, -] - -[[package]] -name = "pytest" -version = "8.3.3" -requires_python = ">=3.8" -summary = "pytest: simple powerful testing with Python" -groups = ["dev"] -dependencies = [ - "colorama; sys_platform == \"win32\"", - "exceptiongroup>=1.0.0rc8; python_version < \"3.11\"", - "iniconfig", - "packaging", - "pluggy<2,>=1.5", - "tomli>=1; python_version < \"3.11\"", -] -files = [ - {file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"}, - {file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"}, -] - -[[package]] -name = "sniffio" -version = "1.3.1" -requires_python = ">=3.7" -summary = "Sniff out which async library your code is running under" -groups = ["default"] -files = [ - {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, - {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, -] - -[[package]] -name = "starlette" -version = "0.41.2" -requires_python = ">=3.8" -summary = "The little ASGI library that shines." -groups = ["default"] -dependencies = [ - "anyio<5,>=3.4.0", - "typing-extensions>=3.10.0; python_version < \"3.10\"", -] -files = [ - {file = "starlette-0.41.2-py3-none-any.whl", hash = "sha256:fbc189474b4731cf30fcef52f18a8d070e3f3b46c6a04c97579e85e6ffca942d"}, - {file = "starlette-0.41.2.tar.gz", hash = "sha256:9834fd799d1a87fd346deb76158668cfa0b0d56f85caefe8268e2d97c3468b62"}, -] - -[[package]] -name = "tomli" -version = "2.0.2" -requires_python = ">=3.8" -summary = "A lil' TOML parser" -groups = ["dev"] -marker = "python_version < \"3.11\"" -files = [ - {file = "tomli-2.0.2-py3-none-any.whl", hash = "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38"}, - {file = "tomli-2.0.2.tar.gz", hash = "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed"}, -] - -[[package]] -name = "typing-extensions" -version = "4.12.2" -requires_python = ">=3.8" -summary = "Backported and Experimental Type Hints for Python 3.8+" -groups = ["default"] -files = [ - {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, - {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, -] diff --git a/pybackend/pyproject.toml b/pybackend/pyproject.toml deleted file mode 100644 index aa5ecee4d..000000000 --- a/pybackend/pyproject.toml +++ /dev/null @@ -1,27 +0,0 @@ -[project] -name = "pybackend" -version = "0.1.0" -description = "Default template for PDM package" -authors = [ - {name = "Conrado", email = "csilvamiranda@cloudera.com"}, -] -dependencies = ["pydantic>=2.9.2", "fastapi>=0.115.4"] -requires-python = "==3.10.*" -readme = "README.md" -license = {text = "TBD"} - - -[tool.pdm] -distribution = false - -[dependency-groups] -dev = ["pytest>=8.3.3"] - -[tool.pytest.ini_options] -pythonpath = [ - "." -] -log_cli = true -log_cli_level = "DEBUG" -log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)" -log_cli_date_format = "%Y-%m-%d %H:%M:%S" diff --git a/pybackend/src/__init__.py b/pybackend/src/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pybackend/src/migration/__init__.py b/pybackend/src/migration/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pybackend/src/migration/datastore.py b/pybackend/src/migration/datastore.py deleted file mode 100644 index be8085b4d..000000000 --- a/pybackend/src/migration/datastore.py +++ /dev/null @@ -1,183 +0,0 @@ -import re -import sqlite3 -from abc import ABC, abstractmethod -from dataclasses import dataclass -from pathlib import Path -from sqlite3 import Connection -from typing import List - -MIGRATION_STATE_TABLE = "migration_state" -MIGRATION_CONTENT_TABLE = "migration_content" - -NAME_REGEX = re.compile(r"^(\d+)_[a-zA-Z0-9_-]+\.(up|down)\.sql$") - - -class MigrationContent: - name: str - id: int - up: bool - content: str - - def __init__(self, name: str, content: str): - self.name = name - self.content = content - match = NAME_REGEX.match(name) - if match: - self.id = int(match.group(1)) - self.up = match.group(2) == "up" - else: - raise ValueError(f"Invalid migration name: {name}") - - def __eq__(self, other: "MigrationContent"): - return self.name == other.name and self.content == other.content - - def __lt__(self, other: "MigrationContent"): - if self.id != other.id: - return self.id < other.id - return self.up < other.up - - def __repr__(self): - return f"MigrationContent(name={self.name}, id={self.id}, up={self.up})" - - -@dataclass -class MigrationState: - version: int - dirty: bool - - -class Datastore(ABC): - """Abstract base class for datastore migrations.""" - - @abstractmethod - def ensure_migration_state_table_exists(self): - """ - Ensure the migration table exists. - """ - pass - - @abstractmethod - def get_migration_state(self) -> MigrationState: - """Get the migration state.""" - pass - - @abstractmethod - def update_migration_state(self, state: MigrationState): - """Update the migration state.""" - pass - - @abstractmethod - def ensure_migration_content_table_exists(self): - """ - Ensure the migration content table exists. - """ - pass - - @abstractmethod - def get_migrations_from_db(self) -> List[MigrationContent]: - """Get all migrations from the database.""" - pass - - @abstractmethod - def get_migrations_from_disk(self) -> List[MigrationContent]: - """Get all migrations from the disk.""" - pass - - @abstractmethod - def update_migrations(self, migrations: List[MigrationContent]): - """Update the migrations.""" - pass - - @abstractmethod - def execute_migration(self, migration: MigrationContent): - """Execute a migration.""" - pass - - -class SQLiteDatastore(Datastore): - """Datastore implementation using SQLite.""" - - def __init__(self, connection: Connection): - self.connection = connection - - def ensure_migration_state_table_exists(self): - """Create migration_state table if it doesn't exist.""" - self.connection.execute( - f""" - CREATE TABLE IF NOT EXISTS {MIGRATION_STATE_TABLE} ( - key INTEGER PRIMARY KEY, - version INTEGER NOT NULL, - dirty INTEGER NOT NULL CHECK (dirty IN (0, 1)) - ) - """ - ) - self.connection.commit() - # If the table is empty, insert the initial row with (0, false) - try: - self.connection.execute( - f"INSERT INTO {MIGRATION_STATE_TABLE} (key, version, dirty) VALUES (0, 0, 0)" - ) - self.connection.commit() - except sqlite3.IntegrityError: - # Ignore integrity error if the row already exists, so we don't have to initialize - pass - - def get_migration_state(self) -> MigrationState: - cursor = self.connection.execute( - f"SELECT version, dirty FROM {MIGRATION_STATE_TABLE} WHERE key = 0" - ) - return MigrationState(*cursor.fetchone()) - - def update_migration_state(self, state: MigrationState): - self.connection.execute( - f"INSERT OR REPLACE INTO {MIGRATION_STATE_TABLE} (key, version, dirty) VALUES (0, ?, ?)", - (state.version, state.dirty), - ) - self.connection.commit() - - def ensure_migration_content_table_exists(self): - """Create migration_content table if it doesn't exist.""" - self.connection.execute( - f""" - CREATE TABLE IF NOT EXISTS {MIGRATION_CONTENT_TABLE} ( - name TEXT NOT NULL PRIMARY KEY, - content TEXT NOT NULL - ) - """ - ) - self.connection.commit() - - def get_migrations_from_db(self) -> List[MigrationContent]: - """Get all migrations from the database.""" - cursor = self.connection.execute( - f"SELECT name, content FROM {MIGRATION_CONTENT_TABLE}" - ) - return list( - sorted([MigrationContent(name, content) for name, content in cursor]) - ) - - def get_migrations_from_disk(self) -> List[MigrationContent]: - """Get all migrations from the disk.""" - folder = Path(__file__).parent / "sqlite" - migrations = [] - for file in folder.glob("*.sql"): - with open(file, "r") as f: - migrations.append(MigrationContent(file.name, f.read())) - return list(sorted(migrations)) - - def update_migrations(self, migrations: List[MigrationContent]): - """Update the migrations.""" - migration_tuples = [(m.name, m.content) for m in migrations] - - self.connection.executemany( - f"INSERT OR REPLACE INTO {MIGRATION_CONTENT_TABLE} (name, content) VALUES (?, ?)", - migration_tuples, - ) - self.connection.commit() - - def execute_migration(self, migration: MigrationContent): - """Execute a migration.""" - sql = migration.content.strip() - if sql: - self.connection.execute(sql) - self.connection.commit() diff --git a/pybackend/src/migration/migrator.py b/pybackend/src/migration/migrator.py deleted file mode 100644 index 184408764..000000000 --- a/pybackend/src/migration/migrator.py +++ /dev/null @@ -1,106 +0,0 @@ -import logging -from sqlite3 import Connection -from typing import List, Optional - -from src.migration.datastore import Datastore, MigrationContent, MigrationState - -logger = logging.getLogger(__name__) - - -class Migrator: - def __init__(self, datastore: Datastore): - self.datastore = datastore - datastore.ensure_migration_content_table_exists() - datastore.ensure_migration_state_table_exists() - - def perform_migration(self, desired_version: Optional[int] = None): - self._update_migrations() - - state = self.datastore.get_migration_state() - logger.info("Current migration state version: %s", state.version) - if state.dirty: - logger.warning("Database is in a dirty state. Cleaning up.") - state = self._clean_up_dirty_database(state) - - last_migration_in_disk = max( - map(lambda x: x.id, self.datastore.get_migrations_from_disk()) - ) - logger.info("Last migration in disk: %s", last_migration_in_disk) - - if desired_version is None: - desired_version = last_migration_in_disk - - logger.info("Desired migration version: %s", desired_version) - - if desired_version != state.version: - migrations_to_perform = self._gather_migrations_to_perform( - state.version, desired_version - ) - logger.debug("Migrations to perform: %s", migrations_to_perform) - for migration in migrations_to_perform: - # Ensure we do one migration step at a time - assert migration.up == (state.version < desired_version) - assert abs(migration.id - state.version) <= 1 - - logger.info("Executing migration: %s", migration.name) - - state.version = migration.id if migration.up else migration.id - 1 - state.dirty = True - self.datastore.update_migration_state(state) - logger.debug("Migration state updated: %s", state) - - self.datastore.execute_migration(migration) - logger.debug("Migration executed: %s", migration.name) - - state.dirty = False - self.datastore.update_migration_state(state) - logger.debug("Migration state updated: %s", state) - - logger.info("Database migrations completed successfully.") - - def _update_migrations(self): - migrations = self.datastore.get_migrations_from_disk() - self.datastore.update_migrations(migrations) - - def _clean_up_dirty_database(self, state: MigrationState) -> MigrationState: - if state.version <= 1: - raise RuntimeError( - "Database is in a dirty state at version " - + state.version - + ". Bailing out until dropping the database is implemented." - ) - # We assume if a migration failed, that it wasn't applied, so it should be safe - # to simply revert the number and unset the dirty flag. - new_state = MigrationState(state.version - 1, False) - self.datastore.update_migration_state(new_state) - return new_state - - def _gather_migrations_to_perform( - self, from_version: int, to_version: int - ) -> List[MigrationContent]: - # Load migrations from db since we might need to do a rollback from a future version - migrations_from_db = self.datastore.get_migrations_from_db() - if from_version < to_version: - # We need to perform the update migrations - return list( - sorted( - filter( - lambda x: x.id > from_version and x.id <= to_version and x.up, - migrations_from_db, - ), - key=lambda x: x.id, - ) - ) - else: - # We need to perform the rollback migrations - return list( - sorted( - filter( - lambda x: x.id <= from_version - and x.id > to_version - and not x.up, - migrations_from_db, - ), - key=lambda x: -x.id, - ) - ) diff --git a/pybackend/src/migration/sqlite/1_cloud_config.down.sql b/pybackend/src/migration/sqlite/1_cloud_config.down.sql deleted file mode 100644 index 7b09895a4..000000000 --- a/pybackend/src/migration/sqlite/1_cloud_config.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE cloud_config; diff --git a/pybackend/src/migration/sqlite/1_cloud_config.up.sql b/pybackend/src/migration/sqlite/1_cloud_config.up.sql deleted file mode 100644 index 9fddb0985..000000000 --- a/pybackend/src/migration/sqlite/1_cloud_config.up.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE cloud_config ( - id VARCHAR(255) PRIMARY KEY, - config_data BLOB NOT NULL -); diff --git a/pybackend/src/openapi_server/__init__.py b/pybackend/src/openapi_server/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pybackend/src/openapi_server/apis/__init__.py b/pybackend/src/openapi_server/apis/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pybackend/src/openapi_server/apis/config_cloud_api.py b/pybackend/src/openapi_server/apis/config_cloud_api.py deleted file mode 100644 index bb6a7b0ca..000000000 --- a/pybackend/src/openapi_server/apis/config_cloud_api.py +++ /dev/null @@ -1,123 +0,0 @@ -# coding: utf-8 - -from typing import Dict, List # noqa: F401 -import importlib -import pkgutil - -from openapi_server.apis.config_cloud_api_base import BaseConfigCloudApi -import openapi_server.impl - -from fastapi.responses import FileResponse -from fastapi import File, UploadFile -from fastapi import ( # noqa: F401 - APIRouter, - Body, - Cookie, - Depends, - Form, - Header, - HTTPException, - Path, - Query, - Response, - Security, - status, -) - -from openapi_server.models.extra_models import TokenModel # noqa: F401 -from openapi_server.models.cloud_configuration import CloudConfiguration -from openapi_server.models.cloud_configuration_create_request import CloudConfigurationCreateRequest -from openapi_server.models.cloud_configuration_list import CloudConfigurationList -from openapi_server.models.cloud_configuration_update_request import CloudConfigurationUpdateRequest - - -router = APIRouter(prefix="/api/v1") - -ns_pkg = openapi_server.impl -for _, name, _ in pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + "."): - importlib.import_module(name) - - -@router.post( - "/configurations/cloud", - responses={ - 200: {"model": CloudConfiguration, "description": "Cloud configuration"}, - }, - tags=["config_cloud"], - summary="Create a cloud configuration", - response_model_by_alias=True, -) -def create_cloud_configuration( - cloud_configuration_create_request: CloudConfigurationCreateRequest = Body(None, description=""), -) -> CloudConfiguration: - if not BaseConfigCloudApi.subclasses: - raise HTTPException(status_code=500, detail="Not implemented") - return BaseConfigCloudApi.subclasses[0]().create_cloud_configuration(cloud_configuration_create_request) - - -@router.delete( - "/configurations/cloud/{id}", - responses={ - 200: {"description": "Cloud configuration deleted"}, - }, - tags=["config_cloud"], - summary="Delete a cloud configuration", - response_model_by_alias=True, -) -def delete_cloud_configuration( - id: str = Path(..., description=""), -) -> None: - if not BaseConfigCloudApi.subclasses: - raise HTTPException(status_code=500, detail="Not implemented") - return BaseConfigCloudApi.subclasses[0]().delete_cloud_configuration(id) - - -@router.get( - "/configurations/cloud/{id}", - responses={ - 200: {"model": CloudConfiguration, "description": "Cloud configuration"}, - }, - tags=["config_cloud"], - summary="Get a cloud configuration", - response_model_by_alias=True, -) -def get_cloud_configuration( - id: str = Path(..., description=""), -) -> CloudConfiguration: - if not BaseConfigCloudApi.subclasses: - raise HTTPException(status_code=500, detail="Not implemented") - return BaseConfigCloudApi.subclasses[0]().get_cloud_configuration(id) - - -@router.get( - "/configurations/cloud", - responses={ - 200: {"model": CloudConfigurationList, "description": "List of clouds"}, - }, - tags=["config_cloud"], - summary="List cloud configurations", - response_model_by_alias=True, -) -def list_cloud_configurations( -) -> CloudConfigurationList: - if not BaseConfigCloudApi.subclasses: - raise HTTPException(status_code=500, detail="Not implemented") - return BaseConfigCloudApi.subclasses[0]().list_cloud_configurations() - - -@router.put( - "/configurations/cloud/{id}", - responses={ - 200: {"model": CloudConfiguration, "description": "Cloud configuration"}, - }, - tags=["config_cloud"], - summary="Update a cloud configuration", - response_model_by_alias=True, -) -def update_cloud_configuration( - id: str = Path(..., description=""), - cloud_configuration_update_request: CloudConfigurationUpdateRequest = Body(None, description=""), -) -> CloudConfiguration: - if not BaseConfigCloudApi.subclasses: - raise HTTPException(status_code=500, detail="Not implemented") - return BaseConfigCloudApi.subclasses[0]().update_cloud_configuration(id, cloud_configuration_update_request) diff --git a/pybackend/src/openapi_server/apis/config_cloud_api_base.py b/pybackend/src/openapi_server/apis/config_cloud_api_base.py deleted file mode 100644 index 2ee631c09..000000000 --- a/pybackend/src/openapi_server/apis/config_cloud_api_base.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding: utf-8 - -from typing import ClassVar, Dict, List, Tuple -from fastapi import File, UploadFile -from fastapi.responses import FileResponse # noqa: F401 - -from openapi_server.models.cloud_configuration import CloudConfiguration -from openapi_server.models.cloud_configuration_create_request import CloudConfigurationCreateRequest -from openapi_server.models.cloud_configuration_list import CloudConfigurationList -from openapi_server.models.cloud_configuration_update_request import CloudConfigurationUpdateRequest - - -class BaseConfigCloudApi: - subclasses: ClassVar[Tuple] = () - - def __init_subclass__(cls, **kwargs): - super().__init_subclass__(**kwargs) - BaseConfigCloudApi.subclasses = BaseConfigCloudApi.subclasses + (cls,) - def create_cloud_configuration( - self, - cloud_configuration_create_request: CloudConfigurationCreateRequest, - ) -> CloudConfiguration: - ... - - - def delete_cloud_configuration( - self, - id: str, - ) -> None: - ... - - - def get_cloud_configuration( - self, - id: str, - ) -> CloudConfiguration: - ... - - - def list_cloud_configurations( - self, - ) -> CloudConfigurationList: - ... - - - def update_cloud_configuration( - self, - id: str, - cloud_configuration_update_request: CloudConfigurationUpdateRequest, - ) -> CloudConfiguration: - ... diff --git a/pybackend/src/openapi_server/main.py b/pybackend/src/openapi_server/main.py deleted file mode 100644 index 299c5985e..000000000 --- a/pybackend/src/openapi_server/main.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from fastapi import FastAPI - -from openapi_server.apis.config_cloud_api import router as ConfigCloudApiRouter - -app = FastAPI( - title="RAG Studio API", - description="No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)", - version="1.0.0", -) - -app.include_router(ConfigCloudApiRouter) diff --git a/pybackend/src/openapi_server/models/__init__.py b/pybackend/src/openapi_server/models/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pybackend/src/openapi_server/models/cloud_configuration.py b/pybackend/src/openapi_server/models/cloud_configuration.py deleted file mode 100644 index dd23dbb8b..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List -from openapi_server.models.cloud_configuration_configuration import CloudConfigurationConfiguration -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfiguration(BaseModel): - """ - CloudConfiguration - """ # noqa: E501 - id: StrictStr = Field(description="Cloud configuration ID") - name: StrictStr = Field(description="Cloud configuration name") - configuration: CloudConfigurationConfiguration - __properties: ClassVar[List[str]] = ["id", "name", "configuration"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfiguration from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of configuration - if self.configuration: - _dict['configuration'] = self.configuration.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfiguration from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name"), - "configuration": CloudConfigurationConfiguration.from_dict(obj.get("configuration")) if obj.get("configuration") is not None else None - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_aws.py b/pybackend/src/openapi_server/models/cloud_configuration_aws.py deleted file mode 100644 index 5dffa925d..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_aws.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List -from openapi_server.models.cloud_configuration_aws_aws import CloudConfigurationAwsAws -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfigurationAws(BaseModel): - """ - CloudConfigurationAws - """ # noqa: E501 - aws: CloudConfigurationAwsAws - __properties: ClassVar[List[str]] = ["aws"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationAws from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of aws - if self.aws: - _dict['aws'] = self.aws.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfigurationAws from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "aws": CloudConfigurationAwsAws.from_dict(obj.get("aws")) if obj.get("aws") is not None else None - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_aws_aws.py b/pybackend/src/openapi_server/models/cloud_configuration_aws_aws.py deleted file mode 100644 index a0232b789..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_aws_aws.py +++ /dev/null @@ -1,96 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from openapi_server.models.cloud_configuration_aws_aws_type import CloudConfigurationAwsAwsType -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfigurationAwsAws(BaseModel): - """ - CloudConfigurationAwsAws - """ # noqa: E501 - region: StrictStr - type: CloudConfigurationAwsAwsType - __properties: ClassVar[List[str]] = ["region", "type"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationAwsAws from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of type - if self.type: - _dict['type'] = self.type.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfigurationAwsAws from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "region": obj.get("region"), - "type": CloudConfigurationAwsAwsType.from_dict(obj.get("type")) if obj.get("type") is not None else None - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_aws_aws_type.py b/pybackend/src/openapi_server/models/cloud_configuration_aws_aws_type.py deleted file mode 100644 index 1409ffeec..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_aws_aws_type.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -from inspect import getfullargspec -import json -import pprint -import re # noqa: F401 - - - -from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator -from typing import Any, List, Optional -from openapi_server.models.cloud_configuration_aws_instance_profile import CloudConfigurationAwsInstanceProfile -from openapi_server.models.cloud_configuration_aws_key import CloudConfigurationAwsKey -from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict -from typing_extensions import Literal -from pydantic import StrictStr, Field -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -CLOUDCONFIGURATIONAWSAWSTYPE_ONE_OF_SCHEMAS = ["CloudConfigurationAwsInstanceProfile", "CloudConfigurationAwsKey"] - -class CloudConfigurationAwsAwsType(BaseModel): - """ - CloudConfigurationAwsAwsType - """ - # data type: CloudConfigurationAwsInstanceProfile - oneof_schema_1_validator: Optional[CloudConfigurationAwsInstanceProfile] = None - # data type: CloudConfigurationAwsKey - oneof_schema_2_validator: Optional[CloudConfigurationAwsKey] = None - actual_instance: Optional[Union[CloudConfigurationAwsInstanceProfile, CloudConfigurationAwsKey]] = None - one_of_schemas: List[str] = Literal["CloudConfigurationAwsInstanceProfile", "CloudConfigurationAwsKey"] - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = CloudConfigurationAwsAwsType.model_construct() - error_messages = [] - match = 0 - # validate data type: CloudConfigurationAwsInstanceProfile - if not isinstance(v, CloudConfigurationAwsInstanceProfile): - error_messages.append(f"Error! Input type `{type(v)}` is not `CloudConfigurationAwsInstanceProfile`") - else: - match += 1 - # validate data type: CloudConfigurationAwsKey - if not isinstance(v, CloudConfigurationAwsKey): - error_messages.append(f"Error! Input type `{type(v)}` is not `CloudConfigurationAwsKey`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in CloudConfigurationAwsAwsType with oneOf schemas: CloudConfigurationAwsInstanceProfile, CloudConfigurationAwsKey. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in CloudConfigurationAwsAwsType with oneOf schemas: CloudConfigurationAwsInstanceProfile, CloudConfigurationAwsKey. Details: " + ", ".join(error_messages)) - else: - return v - - @classmethod - def from_dict(cls, obj: dict) -> Self: - return cls.from_json(json.dumps(obj)) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into CloudConfigurationAwsInstanceProfile - try: - instance.actual_instance = CloudConfigurationAwsInstanceProfile.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into CloudConfigurationAwsKey - try: - instance.actual_instance = CloudConfigurationAwsKey.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into CloudConfigurationAwsAwsType with oneOf schemas: CloudConfigurationAwsInstanceProfile, CloudConfigurationAwsKey. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into CloudConfigurationAwsAwsType with oneOf schemas: CloudConfigurationAwsInstanceProfile, CloudConfigurationAwsKey. Details: " + ", ".join(error_messages)) - else: - return instance - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Dict: - """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_aws_instance_profile.py b/pybackend/src/openapi_server/models/cloud_configuration_aws_instance_profile.py deleted file mode 100644 index 455d4ad90..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_aws_instance_profile.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import json -import pprint -import re # noqa: F401 -from enum import Enum - - - -try: - from typing import Self -except ImportError: - from typing_extensions import Self - - -class CloudConfigurationAwsInstanceProfile(str, Enum): - """ - CloudConfigurationAwsInstanceProfile - """ - - """ - allowed enum values - """ - INSTANCE_PROFILE = 'instance_profile' - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationAwsInstanceProfile from a JSON string""" - return cls(json.loads(json_str)) - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_aws_key.py b/pybackend/src/openapi_server/models/cloud_configuration_aws_key.py deleted file mode 100644 index f19894bee..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_aws_key.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfigurationAwsKey(BaseModel): - """ - CloudConfigurationAwsKey - """ # noqa: E501 - access_key_id: StrictStr - secret_access_key: StrictStr - __properties: ClassVar[List[str]] = ["access_key_id", "secret_access_key"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationAwsKey from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfigurationAwsKey from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "access_key_id": obj.get("access_key_id"), - "secret_access_key": obj.get("secret_access_key") - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_configuration.py b/pybackend/src/openapi_server/models/cloud_configuration_configuration.py deleted file mode 100644 index a4f219f72..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_configuration.py +++ /dev/null @@ -1,134 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -from inspect import getfullargspec -import json -import pprint -import re # noqa: F401 - - - -from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator -from typing import Any, List, Optional -from openapi_server.models.cloud_configuration_aws import CloudConfigurationAws -from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict -from typing_extensions import Literal -from pydantic import StrictStr, Field -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -CLOUDCONFIGURATIONCONFIGURATION_ONE_OF_SCHEMAS = ["CloudConfigurationAws"] - -class CloudConfigurationConfiguration(BaseModel): - """ - CloudConfigurationConfiguration - """ - # data type: CloudConfigurationAws - oneof_schema_1_validator: Optional[CloudConfigurationAws] = None - actual_instance: Optional[Union[CloudConfigurationAws]] = None - one_of_schemas: List[str] = Literal["CloudConfigurationAws"] - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = CloudConfigurationConfiguration.model_construct() - error_messages = [] - match = 0 - # validate data type: CloudConfigurationAws - if not isinstance(v, CloudConfigurationAws): - error_messages.append(f"Error! Input type `{type(v)}` is not `CloudConfigurationAws`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in CloudConfigurationConfiguration with oneOf schemas: CloudConfigurationAws. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in CloudConfigurationConfiguration with oneOf schemas: CloudConfigurationAws. Details: " + ", ".join(error_messages)) - else: - return v - - @classmethod - def from_dict(cls, obj: dict) -> Self: - return cls.from_json(json.dumps(obj)) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into CloudConfigurationAws - try: - instance.actual_instance = CloudConfigurationAws.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into CloudConfigurationConfiguration with oneOf schemas: CloudConfigurationAws. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into CloudConfigurationConfiguration with oneOf schemas: CloudConfigurationAws. Details: " + ", ".join(error_messages)) - else: - return instance - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Dict: - """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_create_request.py b/pybackend/src/openapi_server/models/cloud_configuration_create_request.py deleted file mode 100644 index 2f793c5ce..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_create_request.py +++ /dev/null @@ -1,96 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List -from openapi_server.models.cloud_configuration_configuration import CloudConfigurationConfiguration -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfigurationCreateRequest(BaseModel): - """ - CloudConfigurationCreateRequest - """ # noqa: E501 - name: StrictStr = Field(description="Cloud configuration name") - configuration: CloudConfigurationConfiguration - __properties: ClassVar[List[str]] = ["name", "configuration"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationCreateRequest from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of configuration - if self.configuration: - _dict['configuration'] = self.configuration.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfigurationCreateRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "configuration": CloudConfigurationConfiguration.from_dict(obj.get("configuration")) if obj.get("configuration") is not None else None - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_list.py b/pybackend/src/openapi_server/models/cloud_configuration_list.py deleted file mode 100644 index 2fc649388..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_list.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List -from openapi_server.models.cloud_configuration import CloudConfiguration -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfigurationList(BaseModel): - """ - CloudConfigurationList - """ # noqa: E501 - items: List[CloudConfiguration] - __properties: ClassVar[List[str]] = ["items"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationList from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in items (list) - _items = [] - if self.items: - for _item in self.items: - if _item: - _items.append(_item.to_dict()) - _dict['items'] = _items - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfigurationList from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "items": [CloudConfiguration.from_dict(_item) for _item in obj.get("items")] if obj.get("items") is not None else None - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/cloud_configuration_update_request.py b/pybackend/src/openapi_server/models/cloud_configuration_update_request.py deleted file mode 100644 index 9d72060d1..000000000 --- a/pybackend/src/openapi_server/models/cloud_configuration_update_request.py +++ /dev/null @@ -1,96 +0,0 @@ -# coding: utf-8 - -""" - RAG Studio API - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - - -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List -from openapi_server.models.cloud_configuration_configuration import CloudConfigurationConfiguration -try: - from typing import Self -except ImportError: - from typing_extensions import Self - -class CloudConfigurationUpdateRequest(BaseModel): - """ - CloudConfigurationUpdateRequest - """ # noqa: E501 - name: StrictStr = Field(description="Cloud configuration name") - configuration: CloudConfigurationConfiguration - __properties: ClassVar[List[str]] = ["name", "configuration"] - - model_config = { - "populate_by_name": True, - "validate_assignment": True, - "protected_namespaces": (), - } - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of CloudConfigurationUpdateRequest from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - }, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of configuration - if self.configuration: - _dict['configuration'] = self.configuration.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of CloudConfigurationUpdateRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "configuration": CloudConfigurationConfiguration.from_dict(obj.get("configuration")) if obj.get("configuration") is not None else None - }) - return _obj - - diff --git a/pybackend/src/openapi_server/models/extra_models.py b/pybackend/src/openapi_server/models/extra_models.py deleted file mode 100644 index a3a283fb8..000000000 --- a/pybackend/src/openapi_server/models/extra_models.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding: utf-8 - -from pydantic import BaseModel - -class TokenModel(BaseModel): - """Defines a token model.""" - - sub: str diff --git a/pybackend/src/openapi_server/models/object.py b/pybackend/src/openapi_server/models/object.py deleted file mode 100644 index 6e16b1c20..000000000 --- a/pybackend/src/openapi_server/models/object.py +++ /dev/null @@ -1,117 +0,0 @@ -import json -import pprint -from typing import Any, ClassVar, Dict, List -from pydantic.json import pydantic_encoder -from pydantic import BaseModel, Extra, model_serializer - - -class ObjectModel(BaseModel): - """ - Base model class that supports additional properties. - """ - - # additional_properties: Dict[str, Any] = {} - - class Config: - populate_by_name = True - validate_assignment = True - extra = "forbid" # Prevent unknown fields from being added to the model - - def _valid_fields(self): - return { - k: v for k, v in self.__fields__.items() if k != "additional_properties" - } - - def __init__(self, **data: Any): - # Extract known fields and handle additional properties - known_fields = {key: data[key] for key in self._valid_fields() if key in data} - additional_props = { - key: value for key, value in data.items() if key not in self._valid_fields() - } - - # Initialize the known fields using the BaseModel's init - super().__init__(**known_fields) - - # Store the additional properties - self.additional_properties = additional_props - - def __setattr__(self, name, value): - """Override __setattr__ to store unknown attributes in additional_properties.""" - if name in self._valid_fields() or name == "additional_properties": - super().__setattr__(name, value) - else: - self.additional_properties[name] = value - - def to_str(self) -> str: - """Returns the string representation of the model using alias.""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias.""" - return json.dumps(self.to_dict()) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - This method also includes additional properties. - """ - _dict = self.model_dump( - by_alias=True, - exclude={ - "additional_properties", - }, - exclude_none=True, - ) - # Include additional properties in the output dictionary - if self.additional_properties: - _dict.update(self.additional_properties) - return _dict - - @classmethod - def from_json(cls, json_str: str) -> "ObjectModel": - """Create an instance of ObjectModel from a JSON string.""" - return cls.from_dict(json.loads(json_str)) - - @classmethod - def from_dict(cls, obj: Dict) -> "ObjectModel": - """Create an instance of ObjectModel from a dict.""" - if obj is None: - return None - - # Extract known fields dynamically from _valid_fields() - known_fields = {key: obj[key] for key in cls._valid_fields() if key in obj} - - # Create an instance of the model with known fields - instance = cls(**known_fields) - - # Store additional fields in additional_properties - additional_props = { - key: value for key, value in obj.items() if key not in cls._valid_fields() - } - instance.additional_properties = additional_props - - return instance - - def dict(self, *args, **kwargs) -> Dict[str, Any]: - """Override dict to merge additional_properties""" - _dict = super().dict(*args, **kwargs) - if self.additional_properties: - _dict.update(self.additional_properties) - return _dict - - def json(self, *args, **kwargs) -> str: - """Override json to merge additional_properties""" - _dict = self.to_dict() - return json.dumps(_dict, default=pydantic_encoder, *args, **kwargs) - - @model_serializer - def ser_model(self): - _dict = {} - for key in self._valid_fields(): - val = getattr(self, key) - if isinstance(val, BaseModel): - _dict[key] = val.model_dump() - else: - _dict[key] = val - if self.additional_properties: - _dict.update(self.additional_properties) - return _dict diff --git a/pybackend/src/openapi_server/security_api.py b/pybackend/src/openapi_server/security_api.py deleted file mode 100644 index cefa267f8..000000000 --- a/pybackend/src/openapi_server/security_api.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding: utf-8 - -from typing import List - -from fastapi import Depends, Security # noqa: F401 -from fastapi.openapi.models import OAuthFlowImplicit, OAuthFlows # noqa: F401 -from fastapi.security import ( # noqa: F401 - HTTPAuthorizationCredentials, - HTTPBasic, - HTTPBasicCredentials, - HTTPBearer, - OAuth2, - OAuth2AuthorizationCodeBearer, - OAuth2PasswordBearer, - SecurityScopes, -) -from fastapi.security.api_key import APIKeyCookie, APIKeyHeader, APIKeyQuery # noqa: F401 - -from openapi_server.models.extra_models import TokenModel - diff --git a/pybackend/tests/__init__.py b/pybackend/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/pybackend/tests/migration/test_sqlite.py b/pybackend/tests/migration/test_sqlite.py deleted file mode 100644 index b1bd6e94e..000000000 --- a/pybackend/tests/migration/test_sqlite.py +++ /dev/null @@ -1,59 +0,0 @@ -import sqlite3 - -import pytest -from src.migration.datastore import SQLiteDatastore -from src.migration.migrator import Migrator - - -@pytest.fixture -def sqlite_connection(): - """Create a SQLite in-memory database connection for testing.""" - connection = sqlite3.connect(":memory:") - yield connection - connection.close() - - -@pytest.fixture -def sqlite_datastore(sqlite_connection: sqlite3.Connection): - """Create a SQLDatastore instance with an in-memory SQLite database.""" - datastore = SQLiteDatastore(sqlite_connection) - return datastore - - -@pytest.fixture -def migrator(sqlite_datastore: SQLiteDatastore): - return Migrator(sqlite_datastore) - - -def test_sqlite_migration_content(sqlite_datastore: SQLiteDatastore): - sqlite_datastore.ensure_migration_state_table_exists() - sqlite_datastore.ensure_migration_content_table_exists() - - migrations_from_db = sqlite_datastore.get_migrations_from_db() - migrations_from_disk = sqlite_datastore.get_migrations_from_disk() - assert len(migrations_from_db) == 0 - - migrator = Migrator(sqlite_datastore) - migrator.perform_migration() - - migrations_from_db = sqlite_datastore.get_migrations_from_db() - assert migrations_from_db == migrations_from_disk - - -def test_sqlite_migration_up_down( - sqlite_datastore: SQLiteDatastore, - migrator: Migrator, -): - migrator.perform_migration() - - state = sqlite_datastore.get_migration_state() - migrations_in_disk = sqlite_datastore.get_migrations_from_disk() - - assert not state.dirty - assert state.version == len(migrations_in_disk) // 2 - - migrator.perform_migration(desired_version=0) - - state = sqlite_datastore.get_migration_state() - assert state.version == 0 - assert not state.dirty diff --git a/ui/package.json b/ui/package.json index 5521bbac3..8c7d55524 100644 --- a/ui/package.json +++ b/ui/package.json @@ -20,7 +20,6 @@ "@tanstack/react-query-devtools": "^5.59.20", "@tanstack/react-router": "^1.81.4", "antd": "^5.22.0", - "axios": "^1.7.7", "date-fns": "^4.1.0", "lodash": "^4.17.21", "react": "^18.3.1", diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yaml index a58aff6b2..894ea04c3 100644 --- a/ui/pnpm-lock.yaml +++ b/ui/pnpm-lock.yaml @@ -23,9 +23,6 @@ importers: antd: specifier: ^5.22.0 version: 5.22.0(date-fns@4.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - axios: - specifier: ^1.7.7 - version: 1.7.7 date-fns: specifier: ^4.1.0 version: 4.1.0 @@ -1254,9 +1251,6 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} - axios@1.7.7: - resolution: {integrity: sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==} - babel-dead-code-elimination@1.0.6: resolution: {integrity: sha512-JxFi9qyRJpN0LjEbbjbN8g0ux71Qppn9R8Qe3k6QzHg2CaKsbUQtbn307LQGiDLGjV6JCtEFqfxzVig9MyDCHQ==} @@ -1681,15 +1675,6 @@ packages: flatted@3.3.1: resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} - follow-redirects@1.15.9: - resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==} - engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true - for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} @@ -2340,9 +2325,6 @@ packages: prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} - proxy-from-env@1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -4259,14 +4241,6 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 - axios@1.7.7: - dependencies: - follow-redirects: 1.15.9 - form-data: 4.0.1 - proxy-from-env: 1.1.0 - transitivePeerDependencies: - - debug - babel-dead-code-elimination@1.0.6: dependencies: '@babel/core': 7.26.0 @@ -4823,8 +4797,6 @@ snapshots: flatted@3.3.1: {} - follow-redirects@1.15.9: {} - for-each@0.3.3: dependencies: is-callable: 1.2.7 @@ -5464,8 +5436,6 @@ snapshots: object-assign: 4.1.1 react-is: 16.13.1 - proxy-from-env@1.1.0: {} - punycode@2.3.1: {} queue-microtask@1.2.3: {} diff --git a/ui/src/services/api/api.ts b/ui/src/services/api/api.ts deleted file mode 100644 index 6a884ba3d..000000000 --- a/ui/src/services/api/api.ts +++ /dev/null @@ -1,565 +0,0 @@ -/* eslint-disable */ -/** - * RAG Studio API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from './configuration'; -import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; -import type { RequestArgs } from './base'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; - -/** - * - * @export - * @interface CloudConfiguration - */ -export interface CloudConfiguration { - /** - * Cloud configuration ID - * @type {string} - * @memberof CloudConfiguration - */ - 'id': string; - /** - * Cloud configuration name - * @type {string} - * @memberof CloudConfiguration - */ - 'name': string; - /** - * - * @type {CloudConfigurationConfiguration} - * @memberof CloudConfiguration - */ - 'configuration': CloudConfigurationConfiguration; -} -/** - * - * @export - * @interface CloudConfigurationAws - */ -export interface CloudConfigurationAws { - /** - * - * @type {CloudConfigurationAwsAws} - * @memberof CloudConfigurationAws - */ - 'aws': CloudConfigurationAwsAws; -} -/** - * - * @export - * @interface CloudConfigurationAwsAws - */ -export interface CloudConfigurationAwsAws { - /** - * - * @type {string} - * @memberof CloudConfigurationAwsAws - */ - 'region': string; - /** - * - * @type {CloudConfigurationAwsAwsType} - * @memberof CloudConfigurationAwsAws - */ - 'type': CloudConfigurationAwsAwsType; -} -/** - * @type CloudConfigurationAwsAwsType - * @export - */ -export type CloudConfigurationAwsAwsType = CloudConfigurationAwsInstanceProfile | CloudConfigurationAwsKey; - -/** - * - * @export - * @enum {string} - */ - -export const CloudConfigurationAwsInstanceProfile = { - InstanceProfile: 'instance_profile' -} as const; - -export type CloudConfigurationAwsInstanceProfile = typeof CloudConfigurationAwsInstanceProfile[keyof typeof CloudConfigurationAwsInstanceProfile]; - - -/** - * - * @export - * @interface CloudConfigurationAwsKey - */ -export interface CloudConfigurationAwsKey { - /** - * - * @type {string} - * @memberof CloudConfigurationAwsKey - */ - 'access_key_id': string; - /** - * - * @type {string} - * @memberof CloudConfigurationAwsKey - */ - 'secret_access_key': string; -} -/** - * @type CloudConfigurationConfiguration - * @export - */ -export type CloudConfigurationConfiguration = CloudConfigurationAws; - -/** - * - * @export - * @interface CloudConfigurationCreateRequest - */ -export interface CloudConfigurationCreateRequest { - /** - * Cloud configuration name - * @type {string} - * @memberof CloudConfigurationCreateRequest - */ - 'name': string; - /** - * - * @type {CloudConfigurationConfiguration} - * @memberof CloudConfigurationCreateRequest - */ - 'configuration': CloudConfigurationConfiguration; -} -/** - * - * @export - * @interface CloudConfigurationList - */ -export interface CloudConfigurationList { - /** - * - * @type {Array} - * @memberof CloudConfigurationList - */ - 'items': Array; -} -/** - * - * @export - * @interface CloudConfigurationUpdateRequest - */ -export interface CloudConfigurationUpdateRequest { - /** - * Cloud configuration name - * @type {string} - * @memberof CloudConfigurationUpdateRequest - */ - 'name': string; - /** - * - * @type {CloudConfigurationConfiguration} - * @memberof CloudConfigurationUpdateRequest - */ - 'configuration': CloudConfigurationConfiguration; -} - -/** - * ConfigCloudApi - axios parameter creator - * @export - */ -export const ConfigCloudApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @summary Create a cloud configuration - * @param {CloudConfigurationCreateRequest} cloudConfigurationCreateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createCloudConfiguration: async (cloudConfigurationCreateRequest: CloudConfigurationCreateRequest, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'cloudConfigurationCreateRequest' is not null or undefined - assertParamExists('createCloudConfiguration', 'cloudConfigurationCreateRequest', cloudConfigurationCreateRequest) - const localVarPath = `/configurations/cloud`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(cloudConfigurationCreateRequest, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Delete a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deleteCloudConfiguration: async (id: string, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists('deleteCloudConfiguration', 'id', id) - const localVarPath = `/configurations/cloud/{id}` - .replace(`{${"id"}}`, encodeURIComponent(String(id))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Get a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getCloudConfiguration: async (id: string, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists('getCloudConfiguration', 'id', id) - const localVarPath = `/configurations/cloud/{id}` - .replace(`{${"id"}}`, encodeURIComponent(String(id))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary List cloud configurations - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - listCloudConfigurations: async (options: RawAxiosRequestConfig = {}): Promise => { - const localVarPath = `/configurations/cloud`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Update a cloud configuration - * @param {string} id - * @param {CloudConfigurationUpdateRequest} cloudConfigurationUpdateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - updateCloudConfiguration: async (id: string, cloudConfigurationUpdateRequest: CloudConfigurationUpdateRequest, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists('updateCloudConfiguration', 'id', id) - // verify required parameter 'cloudConfigurationUpdateRequest' is not null or undefined - assertParamExists('updateCloudConfiguration', 'cloudConfigurationUpdateRequest', cloudConfigurationUpdateRequest) - const localVarPath = `/configurations/cloud/{id}` - .replace(`{${"id"}}`, encodeURIComponent(String(id))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(cloudConfigurationUpdateRequest, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * ConfigCloudApi - functional programming interface - * @export - */ -export const ConfigCloudApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = ConfigCloudApiAxiosParamCreator(configuration) - return { - /** - * - * @summary Create a cloud configuration - * @param {CloudConfigurationCreateRequest} cloudConfigurationCreateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async createCloudConfiguration(cloudConfigurationCreateRequest: CloudConfigurationCreateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.createCloudConfiguration(cloudConfigurationCreateRequest, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['ConfigCloudApi.createCloudConfiguration']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, - /** - * - * @summary Delete a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async deleteCloudConfiguration(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.deleteCloudConfiguration(id, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['ConfigCloudApi.deleteCloudConfiguration']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, - /** - * - * @summary Get a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getCloudConfiguration(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getCloudConfiguration(id, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['ConfigCloudApi.getCloudConfiguration']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, - /** - * - * @summary List cloud configurations - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async listCloudConfigurations(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.listCloudConfigurations(options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['ConfigCloudApi.listCloudConfigurations']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, - /** - * - * @summary Update a cloud configuration - * @param {string} id - * @param {CloudConfigurationUpdateRequest} cloudConfigurationUpdateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async updateCloudConfiguration(id: string, cloudConfigurationUpdateRequest: CloudConfigurationUpdateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.updateCloudConfiguration(id, cloudConfigurationUpdateRequest, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['ConfigCloudApi.updateCloudConfiguration']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, - } -}; - -/** - * ConfigCloudApi - factory interface - * @export - */ -export const ConfigCloudApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = ConfigCloudApiFp(configuration) - return { - /** - * - * @summary Create a cloud configuration - * @param {CloudConfigurationCreateRequest} cloudConfigurationCreateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createCloudConfiguration(cloudConfigurationCreateRequest: CloudConfigurationCreateRequest, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.createCloudConfiguration(cloudConfigurationCreateRequest, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Delete a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deleteCloudConfiguration(id: string, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.deleteCloudConfiguration(id, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Get a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getCloudConfiguration(id: string, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.getCloudConfiguration(id, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary List cloud configurations - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - listCloudConfigurations(options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.listCloudConfigurations(options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Update a cloud configuration - * @param {string} id - * @param {CloudConfigurationUpdateRequest} cloudConfigurationUpdateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - updateCloudConfiguration(id: string, cloudConfigurationUpdateRequest: CloudConfigurationUpdateRequest, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.updateCloudConfiguration(id, cloudConfigurationUpdateRequest, options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * ConfigCloudApi - object-oriented interface - * @export - * @class ConfigCloudApi - * @extends {BaseAPI} - */ -export class ConfigCloudApi extends BaseAPI { - /** - * - * @summary Create a cloud configuration - * @param {CloudConfigurationCreateRequest} cloudConfigurationCreateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ConfigCloudApi - */ - public createCloudConfiguration(cloudConfigurationCreateRequest: CloudConfigurationCreateRequest, options?: RawAxiosRequestConfig) { - return ConfigCloudApiFp(this.configuration).createCloudConfiguration(cloudConfigurationCreateRequest, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Delete a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ConfigCloudApi - */ - public deleteCloudConfiguration(id: string, options?: RawAxiosRequestConfig) { - return ConfigCloudApiFp(this.configuration).deleteCloudConfiguration(id, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Get a cloud configuration - * @param {string} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ConfigCloudApi - */ - public getCloudConfiguration(id: string, options?: RawAxiosRequestConfig) { - return ConfigCloudApiFp(this.configuration).getCloudConfiguration(id, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary List cloud configurations - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ConfigCloudApi - */ - public listCloudConfigurations(options?: RawAxiosRequestConfig) { - return ConfigCloudApiFp(this.configuration).listCloudConfigurations(options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Update a cloud configuration - * @param {string} id - * @param {CloudConfigurationUpdateRequest} cloudConfigurationUpdateRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ConfigCloudApi - */ - public updateCloudConfiguration(id: string, cloudConfigurationUpdateRequest: CloudConfigurationUpdateRequest, options?: RawAxiosRequestConfig) { - return ConfigCloudApiFp(this.configuration).updateCloudConfiguration(id, cloudConfigurationUpdateRequest, options).then((request) => request(this.axios, this.basePath)); - } -} - - - diff --git a/ui/src/services/api/base.ts b/ui/src/services/api/base.ts deleted file mode 100644 index d6cea8c9d..000000000 --- a/ui/src/services/api/base.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* eslint-disable */ -/** - * RAG Studio API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from './configuration'; -// Some imports not used depending on template conditions -// @ts-ignore -import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; - -export const BASE_PATH = "http://localhost:8000/api/v1".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: RawAxiosRequestConfig; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath ?? basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - constructor(public field: string, msg?: string) { - super(msg); - this.name = "RequiredError" - } -} - -interface ServerMap { - [key: string]: { - url: string, - description: string, - }[]; -} - -/** - * - * @export - */ -export const operationServerMap: ServerMap = { -} diff --git a/ui/src/services/api/common.ts b/ui/src/services/api/common.ts deleted file mode 100644 index 11098477a..000000000 --- a/ui/src/services/api/common.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* eslint-disable */ -/** - * RAG Studio API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from "./configuration"; -import type { RequestArgs } from "./base"; -import type { AxiosInstance, AxiosResponse } from 'axios'; -import { RequiredError } from "./base"; - -/** - * - * @export - */ -export const DUMMY_BASE_URL = 'https://example.com' - -/** - * - * @throws {RequiredError} - * @export - */ -export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { - if (paramValue === null || paramValue === undefined) { - throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); - } -} - -/** - * - * @export - */ -export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? await configuration.apiKey(keyParamName) - : await configuration.apiKey; - object[keyParamName] = localVarApiKeyValue; - } -} - -/** - * - * @export - */ -export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { - if (configuration && (configuration.username || configuration.password)) { - object["auth"] = { username: configuration.username, password: configuration.password }; - } -} - -/** - * - * @export - */ -export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { - if (configuration && configuration.accessToken) { - const accessToken = typeof configuration.accessToken === 'function' - ? await configuration.accessToken() - : await configuration.accessToken; - object["Authorization"] = "Bearer " + accessToken; - } -} - -/** - * - * @export - */ -export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? await configuration.accessToken(name, scopes) - : await configuration.accessToken; - object["Authorization"] = "Bearer " + localVarAccessTokenValue; - } -} - -function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { - if (parameter == null) return; - if (typeof parameter === "object") { - if (Array.isArray(parameter)) { - (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); - } - else { - Object.keys(parameter).forEach(currentKey => - setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) - ); - } - } - else { - if (urlSearchParams.has(key)) { - urlSearchParams.append(key, parameter); - } - else { - urlSearchParams.set(key, parameter); - } - } -} - -/** - * - * @export - */ -export const setSearchParams = function (url: URL, ...objects: any[]) { - const searchParams = new URLSearchParams(url.search); - setFlattenedQueryParams(searchParams, objects); - url.search = searchParams.toString(); -} - -/** - * - * @export - */ -export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { - const nonString = typeof value !== 'string'; - const needsSerialization = nonString && configuration && configuration.isJsonMime - ? configuration.isJsonMime(requestOptions.headers['Content-Type']) - : nonString; - return needsSerialization - ? JSON.stringify(value !== undefined ? value : {}) - : (value || ""); -} - -/** - * - * @export - */ -export const toPathString = function (url: URL) { - return url.pathname + url.search + url.hash -} - -/** - * - * @export - */ -export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { - return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url}; - return axios.request(axiosRequestArgs); - }; -} diff --git a/ui/src/services/api/configuration.ts b/ui/src/services/api/configuration.ts deleted file mode 100644 index b0e731360..000000000 --- a/ui/src/services/api/configuration.ts +++ /dev/null @@ -1,109 +0,0 @@ -/* eslint-disable */ -/** - * RAG Studio API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export interface ConfigurationParameters { - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); - username?: string; - password?: string; - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); - basePath?: string; - serverIndex?: number; - baseOptions?: any; - formDataCtor?: new () => any; -} - -export class Configuration { - /** - * parameter for apiKey security - * @param name security name - * @memberof Configuration - */ - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - username?: string; - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - password?: string; - /** - * parameter for oauth2 security - * @param name security name - * @param scopes oauth2 scope - * @memberof Configuration - */ - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); - /** - * override base path - * - * @type {string} - * @memberof Configuration - */ - basePath?: string; - /** - * override server index - * - * @type {number} - * @memberof Configuration - */ - serverIndex?: number; - /** - * base options for axios calls - * - * @type {any} - * @memberof Configuration - */ - baseOptions?: any; - /** - * The FormData constructor that will be used to create multipart form data - * requests. You can inject this here so that execution environments that - * do not support the FormData class can still run the generated client. - * - * @type {new () => FormData} - */ - formDataCtor?: new () => any; - - constructor(param: ConfigurationParameters = {}) { - this.apiKey = param.apiKey; - this.username = param.username; - this.password = param.password; - this.accessToken = param.accessToken; - this.basePath = param.basePath; - this.serverIndex = param.serverIndex; - this.baseOptions = param.baseOptions; - this.formDataCtor = param.formDataCtor; - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - public isJsonMime(mime: string): boolean { - const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); - return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); - } -} diff --git a/ui/src/services/api_config.ts b/ui/src/services/api_config.ts deleted file mode 100644 index f2f4464ba..000000000 --- a/ui/src/services/api_config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Configuration } from "./api/configuration"; - -const basePath = - process.env.REACT_APP_API_BASE_PATH ?? "http://localhost:8000/api/v1"; - -const config = new Configuration({ - basePath: basePath, -}); - -export default config; From 312ddef5a19a39ad102c23c19f1e1756a824eda6 Mon Sep 17 00:00:00 2001 From: Elijah Williams Date: Tue, 12 Nov 2024 15:45:14 -0700 Subject: [PATCH 2/3] remove vscode settings --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 050505ce7..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "interactive" -} From 08b2d4f6ff22486e0dcfb31180bf662e62194894 Mon Sep 17 00:00:00 2001 From: Elijah Williams Date: Tue, 12 Nov 2024 15:48:55 -0700 Subject: [PATCH 3/3] add cache path for gradle --- .github/workflows/pr_build.yml | 1 + .github/workflows/publish_release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index cf506b36d..5bb4efa3a 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -20,6 +20,7 @@ jobs: java-version: '21' distribution: 'temurin' cache: gradle + cache-dependency-path: backend/build.gradle.kts - name: Run Java backend tests run: ./gradlew test diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 1f6085fcc..6eeaee415 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -34,6 +34,7 @@ jobs: java-version: '21' distribution: 'temurin' cache: gradle + cache-dependency-path: backend/build.gradle.kts - name: Run Java backend tests run: ./gradlew test