Skip to content

Commit

Permalink
Merge pull request #8 from Sunbird-ALL/all-1.0-prod
Browse files Browse the repository at this point in the history
Merging All 1.0 prod to Main
  • Loading branch information
sudeeppr1998 authored May 3, 2024
2 parents cb9b3c7 + ab6a667 commit 3ba363d
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 9 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/Prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: PROD DEPLOYMENT

on:
push:
branches: [ all-1.0-prod ]

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Load .env from GitHub Secret
run: echo "${{ secrets.MY_ENV_VARS_PROD }}" > .env

-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }}
env:
MY_ENV_VARS: ${{ secrets.MY_ENV_VARS_PROD }}
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Deploy Stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD }}
username: ${{ secrets.USERNAME_PROD }}
key: ${{ secrets.SSH_PRIVATE_KEY_PROD }}
port: ${{ secrets.PORT }}
script: |
docker login
docker container stop ${{ secrets.CONTAINER_NAME }}
docker rm ${{ secrets.CONTAINER_NAME }}
docker rmi ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }}
docker pull ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }}
docker run -d --name ${{ secrets.CONTAINER_NAME }} --network ${{ secrets.NETWORK }} -p ${{ secrets.CONTAINER_PORT }} -t ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }}
62 changes: 62 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: DEV DEPLOYMENT

on:
push:
branches: [ all-1.0 ]

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Load .env from GitHub Secret
run: echo "${{ secrets.MY_ENV_VARS }}" > .env

-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }}
env:
MY_ENV_VARS: ${{ secrets.MY_ENV_VARS }}
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Deploy Stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
docker login
docker container stop ${{ secrets.CONTAINER_NAME }}
docker rm ${{ secrets.CONTAINER_NAME }}
docker rmi ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }}
docker pull ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }}
docker run -d --name ${{ secrets.CONTAINER_NAME }} --network ${{ secrets.NETWORK }} -p ${{ secrets.CONTAINER_PORT }} -t ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN pip install -r requirements.txt
COPY . .

# Expose the port that the app runs on
EXPOSE 5000
EXPOSE $PORT

# Command to run the Flask application
CMD ["python", "app.py","--host","0.0.0.0"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# all-learner-text-eval
# all-learner-text-eval.
23 changes: 17 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def split_into_phonemes(token):
return ph_list

def identify_missing_tokens(orig_text, resp_text):
if resp_text == None:
resp_text = ""
orig_word_list = orig_text.split()
resp_word_list = resp_text.split()
construct_word_list =[]
Expand All @@ -230,10 +232,10 @@ def identify_missing_tokens(orig_text, resp_text):
for word in orig_word_list:
#use similarity algo euclidean distance and add them, if there is no direct match
closest_match, similarity_score = find_closest_match(word, resp_text)
#print(f"word:{word}: closest match: {closest_match}: sim score:{similarity_score}")
print(f"word:{word}: closest match: {closest_match}: sim score:{similarity_score}")
p_word = p.convert(word)
print(f"word - {word}:: phonemes - {p_word}")#p_word = split_into_phonemes(p_word)
if similarity_score > 80:
if closest_match != None and (similarity_score > 80 or len(orig_word_list) == 1):
#print("matched word")
construct_word_list.append(closest_match)
p_closest_match = p.convert(closest_match)
Expand All @@ -256,6 +258,16 @@ def identify_missing_tokens(orig_text, resp_text):
missing_flatList = list(set(missing_flatList))
construct_flatList = list(set(construct_flatList))

#For words like pew and few, we are adding to construct word and
# we just need to eliminate the matching phonemes and
# add missing phonemes into missing list
for m in orig_flatList:
print(m, " in construct phonemelist")
if m not in construct_flatList:
missing_flatList.append(m)
print('adding to missing list', m)
missing_flatList = list(set(missing_flatList))

print(f"orig Text: {orig_text}")
print(f"Resp Text: {resp_text}")
print(f"construct Text: {construct_text}")
Expand All @@ -265,8 +277,8 @@ def identify_missing_tokens(orig_text, resp_text):
print(f"Construct phonemes: {construct_phoneme_list}")

#print(f"flat Construct phonemes: {construct_flatList}")
print(f"missing phonemes: {missing_phoneme_list}")
#print(f"flat missing phonemes: {missing_flatList}")
#print(f"missing phonemes: {missing_phoneme_list}")
print(f"flat missing phonemes: {missing_flatList}")
return construct_flatList, missing_flatList,construct_text

def processLP(orig_text, resp_text):
Expand Down Expand Up @@ -331,10 +343,9 @@ def get_phonemes():
text = data.get('text')

phonemesList = split_into_phonemes(p.convert(text))
uniquePhonemesList = list(dict.fromkeys(phonemesList))

return jsonify({
"phonemes": uniquePhonemesList
"phonemes": phonemesList
})

if __name__ == '__main__':
Expand Down
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ services:
ALL-TEXT_EVAL:
image: all-text-eval-app
ports:
- '5001:5001'
- '0.0.0.0:5000:5000'
restart: always

networks:
ai-network:
driver: bridge

0 comments on commit 3ba363d

Please sign in to comment.