Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ on:
- main
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -26,35 +26,59 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine build

- name: Build the package
run: |
python setup.py sdist bdist_wheel
run: python -m build

- name: Publish to PyPI
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
run: twine upload dist/*

tag:
runs-on: ubuntu-latest
create_release:
name: Create Release
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'

runs-on: ubuntu-latest
permissions:
contents: write
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set Git committer identity
- name: Get version and create tag
id: version
run: |
git config --global user.email "p_srivastav@outlook.com"
git config --global user.name "Prashant Srivastav"
VERSION="0.1.$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "TAG_NAME=v${VERSION}" >> $GITHUB_OUTPUT
if git tag -l "v${VERSION}" | grep -q "v${VERSION}"; then
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT
fi

- name: Tag the release
id: tag
- name: Create and push tag
if: steps.version.outputs.TAG_EXISTS == 'false'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.TAG_NAME }}" -m "Release ${{ steps.version.outputs.TAG_NAME }}"
git push origin "${{ steps.version.outputs.TAG_NAME }}"

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NEW_TAG=$(date +'%Y%m%d%H%M%S')
git tag -a "v${NEW_TAG}" -m "Release version ${NEW_TAG}"
git push origin "v${NEW_TAG}"
echo "# Release ${{ steps.version.outputs.TAG_NAME }}" > release-notes.md
echo "" >> release-notes.md
echo "## Changes" >> release-notes.md
echo "- Automated release from commit $(git rev-parse --short HEAD)" >> release-notes.md
gh release create "${{ steps.version.outputs.TAG_NAME }}" \
--title "Release ${{ steps.version.outputs.TAG_NAME }}" \
--notes-file release-notes.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Editor
/.vscode
/.venv/*

# Secret stuff
/.env
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "rapida/artifacts/internal"]
path = rapida/artifacts/internal
url = git@github.com:lexatic/internal-bridge.git
[submodule "rapida/clients/protos/artifacts"]
path = rapida/clients/protos/artifacts
url = git@github.com:lexatic/internal-bridge.git
92 changes: 73 additions & 19 deletions bin/artifacts-generate.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,76 @@
python3 -m grpc.tools.protoc \
-I ./rapida/artifacts/internal \
--pyi_out=./rapida/artifacts/protos \
--python_out=./rapida/artifacts/protos \
--grpc_python_out=./rapida/artifacts/protos \
./rapida/artifacts/internal/*.proto

# Find all .py files and replace the import statement
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import common_pb2 as common__pb2/import rapida.artifacts.protos.common_pb2 as common__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.pyi' -exec sed -i.bak 's/import common_pb2 as _common_pb2/import rapida.artifacts.protos.common_pb2 as _common_pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import web_api_pb2 as web__api__pb2/import rapida.artifacts.protos.web_api_pb2 as web__api__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import provider_api_pb2 as provider__api__pb2/import rapida.artifacts.protos.provider_api_pb2 as provider__api__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import vault_api_pb2 as vault__api__pb2/import rapida.artifacts.protos.vault_api_pb2 as vault__api__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import integration_api_pb2 as integration__api__pb2/import rapida.artifacts.protos.integration_api_pb2 as integration__api__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import knowledge_api_pb2 as knowledge__api__pb2/import rapida.artifacts.protos.knowledge_api_pb2 as knowledge__api__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import invoker_api_pb2 as invoker__api__pb2/import rapida.artifacts.protos.invoker_api_pb2 as invoker__api__pb2/g' {} +
# Remove backup files created by sed
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import assistant_deployment_pb2 as assistant__deployment__pb2/import rapida.artifacts.protos.assistant_deployment_pb2 as assistant__deployment__pb2/g' {} +
find "rapida/artifacts/protos/" -name '*.py' -exec sed -i.bak 's/import talk_api_pb2 as talk__api__pb2/import rapida.artifacts.protos.talk_api_pb2 as talk__api__pb2/g' {} +
-I ./rapida/clients/protos/artifacts \
--pyi_out=./rapida/clients/protos \
--python_out=./rapida/clients/protos \
--grpc_python_out=./rapida/clients/protos \
./rapida/clients/protos/artifacts/*.proto



# for file in rapida/clients/protos/*.py; do
# if grep -q "import assistant_.*_pb2" "$file"; then
# sed 's/import \(assistant_.*_pb2\)/import rapida.clients.protos.\1/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
# fi
# done
for file in rapida/clients/protos/*.py rapida/clients/protos/*.pyi; do

# import document_api_pb2 as document__api__pb2

if grep -q "import .*_api_pb2 " "$file"; then
sed 's/import \(.*_api_pb2\)/import rapida.clients.protos.\1/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle assistant_*_pb2 imports
if grep -q "import assistant_.*_pb2" "$file"; then
sed 's/import \(assistant_.*_pb2\)/import rapida.clients.protos.\1/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle common_pb2 imports
if grep -q "import common_pb2" "$file"; then
sed 's/import common_pb2 as common__pb2/import rapida.clients.protos.common_pb2 as common__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
sed 's/import common_pb2 as _common_pb2/import rapida.clients.protos.common_pb2 as _common_pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle web_api_pb2 imports
if grep -q "import web_api_pb2" "$file"; then
sed 's/import web_api_pb2 as web__api__pb2/import rapida.clients.protos.web_api_pb2 as web__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

find "rapida/artifacts/protos/" -name '*.bak' -exec rm {} +
# Handle provider_api_pb2 imports
if grep -q "import provider_api_pb2" "$file"; then
sed 's/import provider_api_pb2 as provider__api__pb2/import rapida.clients.protos.provider_api_pb2 as provider__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle vault_api_pb2 imports
if grep -q "import vault_api_pb2" "$file"; then
sed 's/import vault_api_pb2 as vault__api__pb2/import rapida.clients.protos.vault_api_pb2 as vault__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle integration_api_pb2 imports
if grep -q "import integration_api_pb2" "$file"; then
sed 's/import integration_api_pb2 as integration__api__pb2/import rapida.clients.protos.integration_api_pb2 as integration__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle knowledge_api_pb2 imports
if grep -q "import knowledge_api_pb2" "$file"; then
sed 's/import knowledge_api_pb2 as knowledge__api__pb2/import rapida.clients.protos.knowledge_api_pb2 as knowledge__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle invoker_api_pb2 imports
if grep -q "import invoker_api_pb2" "$file"; then
sed 's/import invoker_api_pb2 as invoker__api__pb2/import rapida.clients.protos.invoker_api_pb2 as invoker__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle assistant_deployment_pb2 imports
if grep -q "import assistant_deployment_pb2" "$file"; then
sed 's/import assistant_deployment_pb2 as assistant__deployment__pb2/import rapida.clients.protos.assistant_deployment_pb2 as assistant__deployment__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi

# Handle talk_api_pb2 imports
if grep -q "import talk_api_pb2" "$file"; then
sed 's/import talk_api_pb2 as talk__api__pb2/import rapida.clients.protos.talk_api_pb2 as talk__api__pb2/g' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi
done

# Remove backup files created by sed
find "rapida/clients/protos/" -name '*.bak' -exec rm {} +
61 changes: 61 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "rapida"
version = "0.1.6" # Consider using dynamic versioning
description = "RapidaAI SDK to integrate rapida.ai APIs"
readme = "README.md"
authors = [{name = "RapidaAI", email = "code@rapida.ai"}]
license = "MIT"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.9"
dependencies = [
"protobuf",
"grpcio",
"grpcio-tools",
]

[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
"flake8",
"black",
"mypy",
]

[project.urls]
Homepage = "https://github.com/rapidaai/rapida-python"
"Bug Reports" = "https://github.com/rapidaai/rapida-python/issues"
Documentation = "https://rapida.ai/docs"
Source = "https://github.com/rapidaai/rapida-python"

[tool.setuptools]
packages = [
"rapida",
"rapida.clients",
"rapida.clients.protos",
"rapida.configs",
"rapida.connections",
"rapida.utils"
# Add any other packages that should be included
]

[tool.setuptools.package-data]
"rapida" = ["py.typed"]
"rapida.clients.protos" = ["*.py"]

[tool.setuptools.exclude-package-data]
"*" = ["tests", "examples"]
Loading