diff --git a/.dvc/.gitignore b/.dvc/.gitignore new file mode 100644 index 0000000..528f30c --- /dev/null +++ b/.dvc/.gitignore @@ -0,0 +1,3 @@ +/config.local +/tmp +/cache diff --git a/.dvc/config b/.dvc/config new file mode 100644 index 0000000..b601ef6 --- /dev/null +++ b/.dvc/config @@ -0,0 +1,6 @@ +[core] + remote = myminio +['remote "myminio"'] + url = s3://185.84.163.5:9000/dvcbucket2 + access_key_id= yZ9qhDgPHuqaRpQZ4kgH + secret_access_key= IksmsR3BHMCJQO9R9hqH72n7kMRHTG7xAlsRlpZN \ No newline at end of file diff --git a/.dvcignore b/.dvcignore new file mode 100644 index 0000000..5197305 --- /dev/null +++ b/.dvcignore @@ -0,0 +1,3 @@ +# Add patterns of files dvc should ignore, which could improve +# the performance. Learn more at +# https://dvc.org/doc/user-guide/dvcignore diff --git a/.github/workflows/python-app2.yml b/.github/workflows/python-app.yml similarity index 83% rename from .github/workflows/python-app2.yml rename to .github/workflows/python-app.yml index b37004a..164e2ca 100644 --- a/.github/workflows/python-app2.yml +++ b/.github/workflows/python-app.yml @@ -5,9 +5,9 @@ name: Python application on: push: - branches: [ "main" ] + branches: [ "dvc_deploy" ] pull_request: - branches: [ "main" ] + branches: [ dvc_deploy" ] permissions: contents: read @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v3 with: @@ -27,7 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f src/requirements.txt ]; then pip install -r src/requirements.txt; fi + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -36,4 +36,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pytest src/test.py + pytest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7acf8d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/test_data.csv diff --git a/active/fa.py b/active/fa.py index bb8fc6d..3c13c10 100644 --- a/active/fa.py +++ b/active/fa.py @@ -1,11 +1,13 @@ from fastapi import FastAPI +import model app = FastAPI() -import model + def process(input_text): return str(model.analyse(input_text)[0]) + @app.get("/process_text/{text}") async def process_text(text: str): result = process(text) diff --git a/active/main.py b/active/main.py index f4cc0d5..f0d6f5e 100644 --- a/active/main.py +++ b/active/main.py @@ -1,4 +1,3 @@ - import os import uvicorn @@ -6,4 +5,4 @@ try: uvicorn.run("fa:app", host="0.0.0.0", port=int(os.environ['PORT']), reload=False, log_level="debug") except Exception as e: - print("Error on running uvicorn: "+str(e)) \ No newline at end of file + print("Error on running uvicorn: "+str(e)) diff --git a/active/model.py b/active/model.py index 33b8b38..269a30a 100644 --- a/active/model.py +++ b/active/model.py @@ -1,18 +1,17 @@ from transformers import pipeline clf = pipeline( - task = 'sentiment-analysis', - model = 'SkolkovoInstitute/russian_toxicity_classifier') + task='sentiment-analysis', + model='SkolkovoInstitute/russian_toxicity_classifier') -text = ['У нас в есть убунты и текникал превью.', - 'Как минимум два малолетних дегенерата в треде, мда.', - 'иди на хер'] +text = ['У нас в есть убунты и текникал превью.', 'Как минимум два малолетних дегенерата в треде, мда.', 'иди на хер'] def analyse(text): - text=[text] - result=clf(text) + text = [text] + result = clf(text) print(result) return result -print(analyse("Кто любит жаб? Они крутые.")) \ No newline at end of file + +print(analyse("Кто любит жаб? Они крутые.")) diff --git a/active/web_app.py b/active/web_app.py index 55b6308..ee9a146 100644 --- a/active/web_app.py +++ b/active/web_app.py @@ -12,6 +12,7 @@ def process_text(input_text): return str(model.analyse(input_text)[0]) + # Обрабатываем введенный текст и выводим результат if st.button('Показать результат'): result = process_text(input_text) diff --git a/src/main.py b/src/main.py index cac7800..632227b 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,3 @@ - -import os import uvicorn if __name__ == "__main__": diff --git a/test_data.csv.dvc b/test_data.csv.dvc new file mode 100644 index 0000000..223a459 --- /dev/null +++ b/test_data.csv.dvc @@ -0,0 +1,5 @@ +outs: +- md5: 7d9ee4c06927ceccef9dc27350e015c9 + size: 52 + hash: md5 + path: test_data.csv