Skip to content

Commit

Permalink
Merge pull request #645 from Ilhasoft/hotfix/fix_version_tests
Browse files Browse the repository at this point in the history
Hotfix/fix version tests
  • Loading branch information
helllllllder committed Oct 5, 2021
2 parents 7960b6e + dfe0b49 commit d0eba1e
Show file tree
Hide file tree
Showing 25 changed files with 452 additions and 337 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ exclude =
./bothub/common/migrations
./manage.py
./bothub/common/languages.py
./bothub/protos/
32 changes: 32 additions & 0 deletions .github/workflows/build-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Production Image
on:
push:
tags:
- 'v*.*.*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: bothubit/bothub-engine:${{ steps.vars.outputs.tag }}

32 changes: 32 additions & 0 deletions .github/workflows/build-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Staging Image
on:
push:
tags:
- 'staging-v*.*.*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: bothubit/bothub-engine:${{ steps.vars.outputs.tag }}

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ staticfiles/
#Pycharm
.idea/

# gRPC Protobuff
bothub/protos/

#ASDF
.tool-versions

Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ env:
- ELASTICSEARCH_NUMBER_OF_SHARDS=1
- ELASTICSEARCH_NUMBER_OF_REPLICAS=1
script:
- make createproto
- python manage.py migrate
- python manage.py search_index --rebuild -f
- python manage.py collectstatic
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ RUN pipenv install --system

COPY . .

RUN make createproto

RUN chmod +x ./entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]
10 changes: 0 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ search_index:
then python manage.py search_index --rebuild -f; \
else pipenv run python manage.py search_index --rebuild -f; fi

createproto:

@rm -rf ./bothub/protos/
@git clone --depth 1 --branch main https://github.com/Ilhasoft/weni-protobuffers ./bothub/protos/
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/intelligence/authentication.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/intelligence/organization.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/intelligence/repository.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/connect/project.proto


# Utils

## Colors
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ django-elasticsearch-dsl-drf= "~=0.22.1"
elasticsearch= "~=7.14.0"
elasticsearch-dsl= "~=7.4.0"
psycopg2-binary = "~=2.9.1"
weni-protobuffers = "*"

[dev-packages]
"flake8" = "~=3.9.2"
Expand Down
591 changes: 324 additions & 267 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bothub/api/grpc/connect_grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import grpc
from django.conf import settings

from bothub.protos.src.weni.protobuf.connect import project_pb2_grpc, project_pb2
from weni.protobuf.connect import project_pb2_grpc, project_pb2


class ConnectGRPCClient:
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/organization/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from bothub.api.grpc.organization.services import OrgService
from bothub.protos.src.weni.protobuf.intelligence import organization_pb2_grpc
from weni.protobuf.intelligence import organization_pb2_grpc


def grpc_handlers(server):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/organization/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from bothub.authentication.models import User
from bothub.common.models import Organization, OrganizationAuthorization
from bothub.protos.src.weni.protobuf.intelligence import organization_pb2
from weni.protobuf.intelligence import organization_pb2


class OrgProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/organization/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
RepositoryAuthorization,
Repository,
)
from bothub.protos.src.weni.protobuf.intelligence.organization_pb2 import OrgStatistic
from weni.protobuf.intelligence.organization_pb2 import OrgStatistic


class OrgService(
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/repository/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .services import RepositoryService
from bothub.protos.src.weni.protobuf.intelligence import repository_pb2_grpc
from weni.protobuf.intelligence import repository_pb2_grpc


def grpc_handlers(server):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/repository/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from bothub.api.v2.repository.serializers import RepositoryCategorySerializer
from bothub.common.models import Repository
from bothub.protos.src.weni.protobuf.intelligence import repository_pb2
from weni.protobuf.intelligence import repository_pb2


class RepositoryProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/repository/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
OrganizationAuthorization,
RepositoryAuthorization,
)
from bothub.protos.src.weni.protobuf.intelligence import (
from weni.protobuf.intelligence import (
repository_pb2_grpc,
repository_pb2,
)
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/user/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
UserService,
UserLanguageService,
)
from bothub.protos.src.weni.protobuf.intelligence import authentication_pb2_grpc
from weni.protobuf.intelligence import authentication_pb2_grpc


def grpc_handlers(server):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/user/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rest_framework import serializers

from bothub.authentication.models import User
from bothub.protos.src.weni.protobuf.intelligence import authentication_pb2
from weni.protobuf.intelligence import authentication_pb2


class UserProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/user/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from bothub.api.v2.tests.utils import create_user_and_token
from bothub.authentication.models import User
from bothub.common.models import Organization, OrganizationAuthorization
from bothub.protos.src.weni.protobuf.intelligence import (
from weni.protobuf.intelligence import (
authentication_pb2_grpc,
authentication_pb2,
)
Expand Down
10 changes: 7 additions & 3 deletions bothub/api/v2/nlp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from bothub.common.models import (
QALogs,
RepositoryAuthorization,
RepositoryVersion,
RepositoryVersionLanguage,
RepositoryNLPLog,
RepositoryExample,
Expand Down Expand Up @@ -330,13 +331,16 @@ def retrieve(self, request, *args, **kwargs):
repository = repository_authorization.repository

repository_version = request.query_params.get("repository_version")

try:
is_default = RepositoryVersion.objects.get(pk=repository_version).is_default
except (RepositoryVersion.DoesNotExist, ValueError):
is_default = True
queryset = RepositoryExample.objects.filter(
repository_version_language__repository_version__repository=repository
)
serializer = repository.intents(
queryset=queryset,
version_default=False,
version_default=is_default,
repository_version=repository_version,
)

Expand Down Expand Up @@ -584,7 +588,7 @@ def retrieve(self, request, *args, **kwargs):
)

try:
repository.validate_if_can_run_automatic_evaluate(language=language)
repository.validate_if_can_run_automatic_evaluate(language=language, repository_version_id=repository_version)
can_run_automatic_evaluate = True
except ValidationError:
can_run_automatic_evaluate = False
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/v2/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def projectrepository(self, request, **kwargs):
@action(
detail=True,
methods=["POST"],
permission_classes=[RepositoryAdminManagerAuthorization],
permission_classes=[IsAuthenticated],
url_name="remove-repository-project",
serializer_class=RemoveRepositoryProject,
)
Expand Down
Loading

0 comments on commit d0eba1e

Please sign in to comment.