diff --git a/.DS_Store b/.DS_Store index aac5204febf3bcd78dcae180ae50b836f5e40066..87b56ad1c0caa0cd8b0aa4497cbd4d095b75bc27 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.flaskenv b/.flaskenv index 09578f2480a1770be7f1d24ae4fef69e0ea89628..adfe7a48941f238a842cacea32c5d17cf4d9c60e 100644 --- a/.flaskenv +++ b/.flaskenv @@ -1 +1 @@ -FLASK_APP=autoaugmentation \ No newline at end of file +FLASK_APP=auto_augmentation \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8b297e4d01f488181c1de2ae66b7ce67092e0c96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,152 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..5b0f266669db9d5eaa4b256e713ce32ae3ebcc7c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +build-job: + stage: build + script: + - echo "Hello, I'm Building" + - pip install pytest + - pip install flask + - pip install pandoc # for pdf making + - pip install weasyprint # for pdf making + +test-job: + stage: test + script: + - echo "Now I'm Testing!" + - python3 -m tests.test_query_processor + +deploy-job: + stage: deploy + script: + - echo "Now I'm Deploying to VM!" + - python3 -m venv venv + - . venv/bin/activate + - pip install -r requirements.txt + - flask run & + - echo "Now I'm Deploying to Heroku!" + - dpl --provider=heroku --app=yw21218-simplewebapp --api-key=5ccc3ae7-725e-4f9f-b441-0c9a28ebdc1b diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3ee025e601252084a1b6fcad8a6f72b1030a4d2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3 + +RUN pip3 install virtualenv + +RUN python3 -m venv venvs + +COPY requirements.txt requirements.txt + +RUN pip3 install -r requirements.txt + +COPY . . + +CMD ["flask", "run"] \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..05b126a4f3af13308397226e5c9cd881e2913083 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: flask run --host=0.0.0.0 --port=$PORT diff --git a/autoaugmentation/.DS_Store b/auto_augmentation/.DS_Store similarity index 86% rename from autoaugmentation/.DS_Store rename to auto_augmentation/.DS_Store index ce806c27eaa94d0cd9fa3bab974cc9efa760e6f0..122d7a06c1978c57c195ced3ced40a85ba4129d7 100644 Binary files a/autoaugmentation/.DS_Store and b/auto_augmentation/.DS_Store differ diff --git a/auto_augmentation/__init__.py b/auto_augmentation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..81b6f0c720cdd6715e62cd374e381a30e40ef934 --- /dev/null +++ b/auto_augmentation/__init__.py @@ -0,0 +1,28 @@ +import os + +from flask import Flask, render_template, request, flash + +def create_app(test_config=None): + # create and configure the app + app = Flask(__name__, instance_relative_config=True) + app.config.from_mapping( + SECRET_KEY='dev', + ) + + if test_config is None: + # load the instance config, if it exists, when not testing + app.config.from_pyfile('config.py', silent=True) + else: + # load the test config if passed in + app.config.from_mapping(test_config) + + # ensure the instance folder exists + os.makedirs(app.instance_path, exist_ok=True) + + from auto_augmentation import search_page, search_result, download_file + + app.register_blueprint(search_page.bp) + app.register_blueprint(search_result.bp) + app.register_blueprint(download_file.bp) + + return app diff --git a/auto_augmentation/download_file.py b/auto_augmentation/download_file.py new file mode 100644 index 0000000000000000000000000000000000000000..c0dffa0cf02e281d4c60a2037b3e6fc230bdbe29 --- /dev/null +++ b/auto_augmentation/download_file.py @@ -0,0 +1,12 @@ +from flask import Blueprint, request, render_template, flash, send_file + +bp = Blueprint("download_file", __name__) + +@bp.route("/download_file", methods=["GET"]) +@bp.route("/choose_file", methods=["GET", "POST"]) +def download(): + # Setup for the 'return send_file()' function call at the end of this function + path = 'templates/CNN.zip' # e.g. 'templates/download.markdown' + + return send_file(path, + as_attachment=True) diff --git a/autoaugmentation/app.py b/auto_augmentation/search_page.py similarity index 95% rename from autoaugmentation/app.py rename to auto_augmentation/search_page.py index 18442d5a956d4ab26794b553c03538c0f64b58a4..7b14acb5ecee2aea47d184117701959714d10894 100644 --- a/autoaugmentation/app.py +++ b/auto_augmentation/search_page.py @@ -1,7 +1,7 @@ -from flask import Blueprint, render_template - -bp = Blueprint("home", __name__) - -@bp.route("/") -def index(): - return render_template("home.html") +from flask import Blueprint, render_template + +bp = Blueprint("home", __name__) + +@bp.route("/") +def index(): + return render_template("home.html") diff --git a/auto_augmentation/search_result.py b/auto_augmentation/search_result.py new file mode 100644 index 0000000000000000000000000000000000000000..d4e26c92df198d37d988b6fbecb0c0535b84bbd8 --- /dev/null +++ b/auto_augmentation/search_result.py @@ -0,0 +1,14 @@ +from flask import Blueprint, request, render_template, flash, send_file +import subprocess + +bp = Blueprint("search_result", __name__) + +@bp.route("/search_result", methods=["GET", "POST"]) +@bp.route("/choose_type", methods=["GET", "POST"]) +def response(): + query = request.args["search_query"] + if not query: + flash("No query") + print('query', query) + + return render_template("result.html") \ No newline at end of file diff --git a/autoaugmentation/static/image/data_augment_cat.jpeg b/auto_augmentation/static/image/data_augment_cat.jpeg similarity index 100% rename from autoaugmentation/static/image/data_augment_cat.jpeg rename to auto_augmentation/static/image/data_augment_cat.jpeg diff --git a/auto_augmentation/templates/basic.html b/auto_augmentation/templates/basic.html new file mode 100644 index 0000000000000000000000000000000000000000..db609ea5f49ca101d3394b2e1219c1488160908b --- /dev/null +++ b/auto_augmentation/templates/basic.html @@ -0,0 +1,12 @@ +<!doctype html> +<html> + <head> + {% block head %} + <title>{% block title %}{% endblock %} - Meta Reinforcement Learning for Data Augmentation</title> + {% endblock %} + </head> + <body> + {% block body %}{% endblock %} + </body> +</html> + diff --git a/auto_augmentation/templates/home.html b/auto_augmentation/templates/home.html new file mode 100644 index 0000000000000000000000000000000000000000..981fe46c5d0713afe1827796cad78df11c7a3ceb --- /dev/null +++ b/auto_augmentation/templates/home.html @@ -0,0 +1,12 @@ +{% extends "basic.html" %} +{% block title%}Home{% endblock %} +{% block body %} +Search some literature: +<form action="/search_result"> + <label for="search_query">Query:</label> + <input type="text" id="search_query" name="search_query"><br> + + <input type="submit"> +</form> + +{% endblock %} diff --git a/auto_augmentation/templates/progress.html b/auto_augmentation/templates/progress.html new file mode 100644 index 0000000000000000000000000000000000000000..2b9bdc3e708f0f99f5849da4d608c15376584624 --- /dev/null +++ b/auto_augmentation/templates/progress.html @@ -0,0 +1,6 @@ +{% extends "basic.html" %} +{% block title%}Home{% endblock %} +{% block body %} +Training the model... + +{% endblock %} \ No newline at end of file diff --git a/auto_augmentation/templates/result.html b/auto_augmentation/templates/result.html new file mode 100644 index 0000000000000000000000000000000000000000..79a2729b4ab104d3bb597828bf080abf0deed297 --- /dev/null +++ b/auto_augmentation/templates/result.html @@ -0,0 +1,31 @@ +{% extends "basic.html" %} +{% block title %}Response{% endblock %} +{% block body %} +Response to query:<br> +<ul> +{% for result in search_results %} +<li> {{ result }} +{% endfor %} +</ul> + +<div> + <form action="/choose_file"> + <input type="radio" id="downloadTypeChoice1" + name="Filetype" value="html"> + <label for="downloadChoice1">HTML</label><br> + + <input type="radio" id="downloadTypeChoice2" + name="Filetype" value="markdown"> + <label for="downloadTypeChoice2">Markdown</label><br> + + <input type="radio" id="downloadTypeChoice3" + name="Filetype" value="pdf"> + <label for="downloadTypeChoice3">PDF</label><br> + + <input type="submit"> + </form> + +</div> + +{% endblock %} + diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a254e2e411577dcc5abec859535d28502c75e38 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile # path to your Dockerfile diff --git a/autoaugmentation/templates/home.html b/old_templates/home.html similarity index 100% rename from autoaugmentation/templates/home.html rename to old_templates/home.html diff --git a/autoaugmentation/templates/layout.html b/old_templates/layout.html similarity index 100% rename from autoaugmentation/templates/layout.html rename to old_templates/layout.html diff --git a/autoaugmentation/templates/result.html b/old_templates/result.html similarity index 100% rename from autoaugmentation/templates/result.html rename to old_templates/result.html diff --git a/autoaugmentation/templates/progress.html b/progress.html similarity index 100% rename from autoaugmentation/templates/progress.html rename to progress.html diff --git a/stdout.txt b/stdout.txt new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391