diff --git a/.github/workflows/colab-ssh-setup.yml b/.github/workflows/colab-ssh-setup.yml new file mode 100644 index 0000000..bf5733d --- /dev/null +++ b/.github/workflows/colab-ssh-setup.yml @@ -0,0 +1,14 @@ +name: Colab SSH Setup + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Google Colab SSH + run: bash ./scripts/colab_ssh_setup.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f7df838 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Your Name + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5a2ac37 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Colab SSH Setup + +This repository provides a script and example to set up an SSH connection to Google Colab, allowing you to use Colab's resources locally in VS Code for resource-intensive tasks like machine learning. + +## Setup Instructions + +1. Clone the repository: + + ```bash + git clone https://github.com/yourusername/colab-ssh-setup.git + cd colab-ssh-setup +Open scripts/colab_ssh_setup.sh and replace 'YOUR_NGROK_TOKEN' and 'YOUR_CHOSEN_PASSWORD' with your Ngrok token and desired SSH password. + +Run the script in a Google Colab notebook: +``` +!bash ./scripts/colab_ssh_setup.sh +``` +Follow the instructions in the Colab output to establish an SSH connection. + +Running the Flask App +Navigate to the examples/flask_app directory: +``` +cd examples/flask_app +``` +Install the required packages: +``` +pip install -r ../../requirements.txt +``` +Run the Flask app: +``` +python app.py +``` +Access the app by opening a browser and going to http://localhost:5000. + diff --git a/examples/flask_app/app.py b/examples/flask_app/app.py new file mode 100644 index 0000000..26631f4 --- /dev/null +++ b/examples/flask_app/app.py @@ -0,0 +1,21 @@ +from flask import Flask, render_template, request +import pandas as pd + +app = Flask(__name__) + +@app.route('/') +def home(): + return render_template('index.html') + +@app.route('/analyze', methods=['POST']) +def analyze(): + # Load Titanic dataset + df = pd.read_csv('https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv') + + # Example analysis: survival rate by class + analysis = df.groupby('Pclass')['Survived'].mean().to_dict() + + return render_template('index.html', analysis=analysis) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/examples/flask_app/requirements.txt b/examples/flask_app/requirements.txt new file mode 100644 index 0000000..dd9f47b --- /dev/null +++ b/examples/flask_app/requirements.txt @@ -0,0 +1,2 @@ +flask +pandas diff --git a/examples/flask_app/templates/index.html b/examples/flask_app/templates/index.html new file mode 100644 index 0000000..ab4e3c6 --- /dev/null +++ b/examples/flask_app/templates/index.html @@ -0,0 +1,24 @@ + + +
+ + +