diff --git a/.github/workflows/azure-webapps-python.yml b/.github/workflows/azure-webapps-python.yml new file mode 100644 index 000000000000..51e6916a49f7 --- /dev/null +++ b/.github/workflows/azure-webapps-python.yml @@ -0,0 +1,86 @@ +# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch. +# +# This workflow assumes you have already created the target Azure App Service web app. +# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask +# +# To configure this workflow: +# +# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal. +# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials +# +# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. +# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret +# +# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below. +# +# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions +# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples + +name: Build and deploy Python app to Azure Web App + +env: + AZURE_WEBAPP_NAME: your-app-name # set this to the name of your Azure Web App + PYTHON_VERSION: '3.8' # set this to the Python version to use + +on: + push: + branches: [ "master" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python version + uses: actions/setup-python@v3.0.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Create and start virtual environment + run: | + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: pip install -r requirements.txt + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v3 + with: + name: python-app + path: | + . + !venv/ + + deploy: + permissions: + contents: none + runs-on: ubuntu-latest + needs: build + environment: + name: 'Development' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v3 + with: + name: python-app + path: . + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml new file mode 100644 index 000000000000..054d48cf0ca1 --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,26 @@ +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '3.x' # Use the latest Python 3 version + addToPath: true + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pytest + displayName: 'Run tests' + +- script: | + streamlit_app.py # Replace app.py with the name of your Streamlit application file + displayName: 'Build Streamlit application' + +# Add deployment steps here to deploy your Streamlit application to your hosting platform diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000000..6f401c61650f --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,36 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: ubuntu-latest +strategy: + matrix: + Python27: + python.version: '2.7' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' diff --git a/requirements.txt b/requirements.txt index 502d7d1a0d19..df7a9901b268 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ altair pandas streamlit +openpyxl +matplotlib diff --git a/streamlit_app.py b/streamlit_app.py index 7a0ed1272052..fc5112932b45 100644 --- a/streamlit_app.py +++ b/streamlit_app.py @@ -1,40 +1,92 @@ -import altair as alt -import numpy as np -import pandas as pd import streamlit as st +import pandas as pd +import matplotlib.pyplot as plt + +# Function to load student data from Excel sheet +def load_student_data(): + # Read student data from Excel sheet + student_data = pd.read_excel("student_data.xlsx") + return student_data + +# Function to filter students by course eligibility +def filter_students_by_course(course): + student_df = load_student_data() + if course == "Science": + eligible_students = student_df[student_df["Marks"] >= 80] + elif course == "Economics": + eligible_students = student_df[student_df["Marks"] >= 75] + elif course == "Humanities": + eligible_students = student_df[student_df["Marks"] >= 70] + else: + eligible_students = pd.DataFrame(columns=["Name", "Marks"]) # Return empty DataFrame if course is not recognized + return eligible_students + +# Streamlit UI +st.title('Education System') + +# Sidebar navigation +page = st.sidebar.radio("Navigation", ('Home', 'Add Student', 'Admission Checker', 'Course Eligibility', 'Data Visualization')) + +if page == 'Home': + st.subheader('Welcome to the Education System!') + st.write("This platform allows you to manage student data and check admission eligibility.") + st.write("To get started, you can:") + st.write("- Click on 'Manage Students' to view student data.") + + if st.button("Manage Students"): + student_df = load_student_data() + st.write(student_df) # Display student data + +def add_student(name, marks): + student_df = load_student_data() + if name in student_df["Name"].values: + st.warning("Student already exists in the database.") + elif marks >= 75: + # Create a new DataFrame with the new student data + new_student = pd.DataFrame({"Name": [name], "Marks": [marks]}) + # Append the new student DataFrame to the existing student DataFrame + student_df = pd.concat([student_df, new_student], ignore_index=True) + # Write the updated DataFrame to the Excel sheet (if needed) + # student_df.to_excel("students.xlsx", index=False) + st.success(f"{name} added successfully!") + else: + st.warning("Student not added. Marks should be 75 or greater for admission.") + return student_df # Return the updated DataFrame + +if page == 'Admission Checker': + st.subheader('Admission Checker') + name = st.text_input("Enter student name to check admission:") + + if st.button('Check Admission'): # Button click to check admission + student_df = load_student_data() + if name in student_df["Name"].values: + st.write("Student found.") + else: + st.write("Student not found.") + +elif page == 'Course Eligibility': + st.subheader('Course Eligibility') + course = st.selectbox("Select a course:", ["Science", "Economics", "Humanities"]) + + st.write(f"Students eligible for {course} course:") + eligible_students = filter_students_by_course(course) + st.write(eligible_students) + +elif page == 'Data Visualization': + st.subheader('Data Visualization') + + # Load student data + student_df = load_student_data() -""" -# Welcome to Streamlit! - -Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:. -If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community -forums](https://discuss.streamlit.io). - -In the meantime, below is an example of what you can do with just a few lines of code: -""" - -num_points = st.slider("Number of points in spiral", 1, 10000, 1100) -num_turns = st.slider("Number of turns in spiral", 1, 300, 31) - -indices = np.linspace(0, 1, num_points) -theta = 2 * np.pi * num_turns * indices -radius = indices - -x = radius * np.cos(theta) -y = radius * np.sin(theta) - -df = pd.DataFrame({ - "x": x, - "y": y, - "idx": indices, - "rand": np.random.randn(num_points), -}) - -st.altair_chart(alt.Chart(df, height=700, width=700) - .mark_point(filled=True) - .encode( - x=alt.X("x", axis=None), - y=alt.Y("y", axis=None), - color=alt.Color("idx", legend=None, scale=alt.Scale()), - size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])), - )) + # Check if the "Marks" column exists + if "Marks" not in student_df.columns: + st.error("The 'Marks' column is missing in the student data.") + else: + # Histogram of student marks distribution + st.write("Histogram of Student Marks Distribution") + fig, ax = plt.subplots() + ax.hist(student_df["Marks"], bins=10, color='skyblue', edgecolor='black') + ax.set_xlabel('Marks') + ax.set_ylabel('Frequency') + ax.set_title('Distribution of Student Marks') + st.pyplot(fig) diff --git a/student_data.xlsx b/student_data.xlsx new file mode 100644 index 000000000000..2c11b0e2e16e Binary files /dev/null and b/student_data.xlsx differ