Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mudar a forma de criar o executavel para que seja mais rapido #36

Merged
merged 95 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
41098df
Massive auditing change
cmaloney111 Apr 26, 2024
d913fb1
fix images
GiseleBr678 May 11, 2024
17a6b4f
Merge pull request #30 from TailUFPB/branch-images
jonasgabriel18 May 13, 2024
fc61a86
Update develop.yml
cmaloney111 May 13, 2024
3ec629d
Develop
cmaloney111 May 13, 2024
e2f8057
Add environment yml
cmaloney111 May 13, 2024
3a51a7a
environment.yml
cmaloney111 May 13, 2024
6cef87d
Update develop.yml
cmaloney111 May 13, 2024
09ab522
Update develop.yml
cmaloney111 May 13, 2024
2801926
Update develop.yml
cmaloney111 May 13, 2024
32131dc
update env.yml
cmaloney111 May 13, 2024
ee7ef6d
Update develop.yml
cmaloney111 May 13, 2024
f4209cc
Update develop.yml
cmaloney111 May 13, 2024
b006e68
Update develop.yml
cmaloney111 May 13, 2024
838a167
Change about links
cmaloney111 May 13, 2024
a4cc165
search for app
cmaloney111 May 13, 2024
8c8f6ef
remove path and fs
cmaloney111 May 13, 2024
904724a
change app.spec
cmaloney111 May 13, 2024
9ae8e73
Update develop.yml
cmaloney111 May 13, 2024
8629088
change app.spec
cmaloney111 May 13, 2024
e1505f0
Update develop.yml
cmaloney111 May 13, 2024
a3d4ad0
change app.spec
cmaloney111 May 13, 2024
e8c86a0
Update develop.yml
cmaloney111 May 13, 2024
4fc12ed
Change app.spec location
cmaloney111 May 13, 2024
e303725
No optimize
cmaloney111 May 13, 2024
022d86c
Update app.spec
cmaloney111 May 13, 2024
3ce3e52
Change app.spec
cmaloney111 May 13, 2024
5a0e049
change app.spec
cmaloney111 May 13, 2024
6d827db
change app.spec
cmaloney111 May 13, 2024
9d9e15c
change app.spec
cmaloney111 May 13, 2024
d5d1d33
Update develop.yml
cmaloney111 May 13, 2024
419f936
change package.json
cmaloney111 May 13, 2024
66a08d2
change package.json
cmaloney111 May 13, 2024
13246b3
Get that scipy!
cmaloney111 May 14, 2024
3ad75cb
Update develop.yml
cmaloney111 May 14, 2024
bead507
Update requirements.txt
cmaloney111 May 14, 2024
48c5294
Update develop.yml
cmaloney111 May 14, 2024
d63d0f5
No matplotlib
cmaloney111 May 14, 2024
6a2782b
Update develop.yml
cmaloney111 May 14, 2024
9918da2
Remove unnecessary requirements
cmaloney111 May 14, 2024
3b2d290
Update develop.yml
cmaloney111 May 14, 2024
3abdba7
remove unnnecessary extra files
cmaloney111 May 14, 2024
8d8cb7b
Update develop.yml
cmaloney111 May 14, 2024
db2edda
Update develop.yml
cmaloney111 May 14, 2024
335dffa
Update develop.yml
cmaloney111 May 14, 2024
684dd2c
Update develop.yml
cmaloney111 May 14, 2024
e138473
Update develop.yml for windows
cmaloney111 May 14, 2024
13a0a0e
Update develop.yml
cmaloney111 May 14, 2024
0e421f5
First release using conda and pyinstaller for quicker setup
cmaloney111 May 14, 2024
9acc4f3
Update develop.yml
cmaloney111 May 15, 2024
fccc8dc
Update develop.yml
cmaloney111 May 15, 2024
1a54c17
Update main.yml
cmaloney111 May 15, 2024
9cc18b3
Delete .github/workflows/create-release.yml
cmaloney111 May 15, 2024
12d6ecf
Update main.yml
cmaloney111 May 15, 2024
0949be1
Delete .github/workflows/create-release.yml
cmaloney111 May 15, 2024
9d56057
Update develop.yml
cmaloney111 May 15, 2024
023755f
Update main.yml
cmaloney111 May 15, 2024
7c464a7
Delete yarn.lock
cmaloney111 May 15, 2024
2cf081a
fix images
GiseleBr678 May 11, 2024
810f700
Merge pull request #30 from TailUFPB/branch-images
jonasgabriel18 May 13, 2024
f4bc803
Update develop.yml
cmaloney111 May 13, 2024
7459cd9
Develop
cmaloney111 May 13, 2024
6cae0cb
Add environment yml
cmaloney111 May 13, 2024
4bd384f
environment.yml
cmaloney111 May 13, 2024
b4758ec
Update develop.yml
cmaloney111 May 13, 2024
dda1706
Update develop.yml
cmaloney111 May 13, 2024
06f254f
Update develop.yml
cmaloney111 May 13, 2024
2af92f9
update env.yml
cmaloney111 May 13, 2024
4880a54
Update develop.yml
cmaloney111 May 13, 2024
8499c46
Update develop.yml
cmaloney111 May 13, 2024
ecbc6d2
hi
cmaloney111 May 15, 2024
1b8d288
Change about links
cmaloney111 May 13, 2024
1196d3a
search for app
cmaloney111 May 13, 2024
0e8ae79
remove path and fs
cmaloney111 May 13, 2024
5a71bf1
change app.spec
cmaloney111 May 13, 2024
97cc814
change app.spec
cmaloney111 May 13, 2024
eea9cb5
change app.spec
cmaloney111 May 13, 2024
3312a17
Change app.spec location
cmaloney111 May 13, 2024
c72ed7c
No optimize
cmaloney111 May 13, 2024
91199ba
Update app.spec
cmaloney111 May 13, 2024
e96b605
Change app.spec
cmaloney111 May 13, 2024
be23656
change app.spec
cmaloney111 May 13, 2024
743fd45
change app.spec
cmaloney111 May 13, 2024
57d6e2e
change app.spec
cmaloney111 May 13, 2024
3e57dbd
change package.json
cmaloney111 May 13, 2024
b3f238c
change package.json
cmaloney111 May 13, 2024
93ce6e4
Get that scipy!
cmaloney111 May 14, 2024
377e894
Update requirements.txt
cmaloney111 May 14, 2024
caa72ee
No matplotlib
cmaloney111 May 14, 2024
7f46c3b
Remove unnecessary requirements
cmaloney111 May 14, 2024
98db85f
remove unnnecessary extra files
cmaloney111 May 14, 2024
0e1da69
Merge branch 'cmaloney111-patch-1' into develop
cmaloney111 May 15, 2024
23c066f
Update main.yml
cmaloney111 May 15, 2024
8b3aeca
Update develop.yml
cmaloney111 May 15, 2024
7a9214e
LinguifAI built with pyinstaller and conda
cmaloney111 May 15, 2024
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
38 changes: 0 additions & 38 deletions .github/workflows/create-release.yml

This file was deleted.

119 changes: 20 additions & 99 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,30 @@
name: CI
# Controls when the workflow will run
on:
push:
branches: ["develop"]

# Prevent duplicate workflows from running
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Static tests don't involve any logic or context.
# They are just a set of tests that can detect if we are not introducing any faulty code.
static-test:
name: 🔬 Static tests
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: ⎔ Setup Node
uses: actions/setup-node@v3
with:
cache: "npm"

- name: 🟨 Setup Python
uses: actions/setup-python@v3

- name: 📦 Install Node dependencies
run: npm install

# # Unit tests are tests that are not dependent on any external service.
# # Usually, they are tests that are testing the logic of a specific function or component.
unit-test:
needs: [static-test]
name: 🚦 Unit tests
runs-on: ubuntu-latest
build:
name: 🏗️ Build
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: ⎔ Setup Node
uses: actions/setup-node@v3
- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
cache: "npm"

- name: 🟨 Setup Python
uses: actions/setup-python@v3

- name: 📦 Install dependencies
run: npm install
activate-environment: default
environment-file: api/environment.yml

- name: 🚦 Run unit tests
run: npm test

# # Integration tests are tests that are dependent on external services.
integration-test:
needs: [static-test]
name: 🚥 Integration tests
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
Expand All @@ -76,65 +37,26 @@ jobs:

- name: 🟨 Setup Python
uses: actions/setup-python@v3

- name: 📦 Install dependencies
run: npm install

# - name: 🐳 Docker compose
# run:
# docker-compose up -d && sleep 3 && pnpm prisma migrate reset --force
# --skip-seed

- name: 🚦 Run integration tests
run: npm test

# Create Build
build:
needs: [static-test, unit-test, integration-test]
name: 🏗️ Build
runs-on: ubuntu-latest
steps:
- name: Set up Wine
uses: actions/setup-node@v2
with:
node-version: "14"

- name: Install Wine64
run: sudo apt update && sudo apt install wine64

- name: Install Wine32
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32

- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
python-version: 3.12.3

- name: ⎔ Setup Node
uses: actions/setup-node@v3
with:
cache: "npm"
- name: Install pip dependencies
run: pip install -r api/requirements.txt pyinstaller==6.6.0

- name: 🟨 Setup Python
uses: actions/setup-python@v3
- name: Build flask exe
run: pyinstaller api/app.spec

- name: 📦 Install dependencies
- name: Install dependencies
run: npm install

- name: 🏗️ Build
run: npm run build

#- name: 📦 Electron Package
# run: npx electron-packager . LinguifAI --platform=win32 --arch=x64 --out=dist

- name: 📦 Electron Builder
run: npm run electron:package:win
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Print directory tree
run: tree

- name: Get latest release number
id: get_latest_release
uses: actions/github-script@v4
Expand All @@ -154,7 +76,7 @@ jobs:
console.log(`::set-output name=new_version::${newVersion}`);

- name: Rename file
run: mv -f dist/LinguifAI\ Setup\ 0.1.0.exe dist/LinguifAI\ Setup\ ${{ steps.get_latest_release.outputs.new_version }}.exe
run: ren "dist\LinguifAI Setup 0.1.0.exe" "LinguifAI Setup ${{ steps.get_latest_release.outputs.new_version }}.exe"

- name: Create Release
id: create_release
Expand All @@ -165,5 +87,4 @@ jobs:
tag_name: v${{ steps.get_latest_release.outputs.new_version }}
name: v${{ steps.get_latest_release.outputs.new_version }}
prerelease: true
body: |
Descrição do release aqui
body: ${{ github.event.head_commit.message }}
60 changes: 38 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,20 @@ jobs:
build:
needs: [static-test, unit-test, integration-test]
name: 🏗️ Build
runs-on: ubuntu-latest
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- name: Set up Wine
uses: actions/setup-node@v2
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
node-version: "14"

- name: Install Wine64
run: sudo apt update && sudo apt install wine64
fetch-depth: 2

- name: Install Wine32
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32
- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: default
environment-file: api/environment.yml

- name: ⬇️ Checkout repo
uses: actions/checkout@v4
Expand All @@ -120,21 +119,26 @@ jobs:

- name: 🟨 Setup Python
uses: actions/setup-python@v3
with:
python-version: 3.12.3

- name: 📦 Install dependencies
run: npm install
- name: Install pip dependencies
run: pip install -r api/requirements.txt pyinstaller==6.6.0

- name: 🏗️ Build
run: npm run build
- name: Build flask exe
run: pyinstaller api/app.spec

#- name: 📦 Electron Package
# run: npx electron-packager . LinguifAI --platform=win32 --arch=x64 --out=dist
- name: Install dependencies
run: npm install

- name: 📦 Electron Builder
run: npm run electron:package:win
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Print directory tree
run: tree

- name: Get latest release number
id: get_latest_release
uses: actions/github-script@v4
Expand All @@ -145,7 +149,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 10
});
});

const latestPreRelease = response.data[0];
const preReleaseTag = latestPreRelease.name;
Expand All @@ -154,8 +158,21 @@ jobs:
console.log(`::set-output name=new_version::${newVersion}`);

- name: Rename file
run: mv -f dist/LinguifAI\ Setup\ 0.1.0.exe dist/LinguifAI\ Setup\ ${{ steps.get_latest_release.outputs.new_version }}.exe
run: ren "dist\LinguifAI Setup 0.1.0.exe" "LinguifAI Setup ${{ steps.get_latest_release.outputs.new_version }}.exe"

- name: Get latest commit message
id: get_latest_commit_message
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
console.log(`::set-output name=commit_message::${response.data[0].commit.message}`);

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
Expand All @@ -165,5 +182,4 @@ jobs:
tag_name: v${{ steps.get_latest_release.outputs.new_version }}
name: v${{ steps.get_latest_release.outputs.new_version }}
prerelease: true
body: |
Descrição do release aqui
body: ${{ steps.get_latest_commit_message.outputs.commit_message }}
38 changes: 27 additions & 11 deletions api/DataProcesser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
from NbNewsModel import news_prediction
from NbEmotionsModel import make_prediction
from available_classifiers import get_available_classifiers
from sklearn.pipeline import make_pipeline

# bag of words
from sklearn.feature_extraction.text import TfidfVectorizer

from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB

import Neural_Network2
import pickle
import re
import joblib
import numpy as np
import string
import os
import pandas as pd
import torch
Expand All @@ -30,7 +35,8 @@ def handle_classify(self, df, classifier):
classifier_switcher = get_available_classifiers() # id: nome_arquivo
model_name = classifier_switcher[classifier]
if model_name.endswith('.pkl'):
return self.pretrained_predict(df, model_name)
pipeline = self.get_pipeline(model_name)
return self.pretrained_predict(df, pipeline)
else:
return self.trained_predict(df, model_name)
#classifier_switcher = {
Expand All @@ -41,6 +47,20 @@ def handle_classify(self, df, classifier):

#return classifier_switcher.get(classifier, lambda: "Invalid Classifier")(df)

def get_pipeline(self, model_name):
if model_name=="emotion_pipeline.pkl":
df = pd.read_csv('api/training_df/tweet_emotions.csv')
train_data, test_data, train_target, test_target = train_test_split(df['content'], df['sentiment'], test_size=0.2, shuffle=True)
elif model_name=="hate_speech.pkl":
df = pd.read_csv('api/training_df/nb_hatespeech.csv', sep=';')
train_data, test_data, train_target, test_target = train_test_split(df['comment'], df['isHate'], test_size=0.2, shuffle=True)
elif model_name=="text_classification_pipeline.pkl":
df = pd.read_csv('api/training_df/nb_news.csv')
train_data, test_data, train_target, test_target = train_test_split(df['short_description'], df['category'], test_size=0.2, shuffle=True)
else:
return None
return make_pipeline(TfidfVectorizer(), MultinomialNB()).fit(train_data, train_target)

def generate_statistics(self, df):
unique_labels = df['output_column'].unique()

Expand All @@ -67,19 +87,15 @@ def classify_emotions(self, df):
df['output_column'] = df['input_column'].apply(make_prediction)
return df

def lin_regression_model(self, df):
df['output_column'] = df['input_column'].apply(make_prediction_nblin)
return df
# def lin_regression_model(self, df):
# df['output_column'] = df['input_column'].apply(make_prediction_nblin)
# return df

def nb_news_application(self, df):
df['output_column'] = df['input_column'].apply(news_prediction)
return df

def pretrained_predict(self, df, model_name):
model_file = f'api/models/{model_name}'
with open(model_file, 'rb') as model:
pipeline = pickle.load(model)

def pretrained_predict(self, df, pipeline):
texts_to_predict = df['input_column']
texts_to_predict = [str(text) for text in texts_to_predict]
predictions = pipeline.predict(texts_to_predict)
Expand Down
Loading
Loading