Spaces:
Sleeping
Sleeping
Initial Draft
Browse files- Dashboard.py +28 -28
Dashboard.py
CHANGED
|
@@ -1,42 +1,42 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
-
from datasets import load_dataset
|
| 4 |
import os
|
|
|
|
|
|
|
| 5 |
|
| 6 |
################################
|
| 7 |
######### Variables ############
|
| 8 |
################################
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
################################
|
| 13 |
####### GenericFunctions #######
|
| 14 |
################################
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
dataset = load_hf_dataset()
|
| 22 |
-
|
| 23 |
-
# Create a directory to save the files
|
| 24 |
-
output_directory = "data"
|
| 25 |
-
os.makedirs(output_directory, exist_ok=True)
|
| 26 |
-
|
| 27 |
-
# Iterate through the dataset and save each file to the data folder
|
| 28 |
-
for split in dataset.keys():
|
| 29 |
-
for file_name, file_content in enumerate(dataset[split]):
|
| 30 |
-
file_path = os.path.join(output_directory, file_name)
|
| 31 |
-
with open(file_path, 'w', encoding='utf-8') as file:
|
| 32 |
-
file.write(file_content)
|
| 33 |
-
|
| 34 |
-
print(f"Saved: {file_path}")
|
| 35 |
|
| 36 |
-
print("All files saved successfully.")
|
| 37 |
-
|
| 38 |
-
|
| 39 |
################################
|
| 40 |
####### Display of data ########
|
| 41 |
################################
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import lib.gdrive as gdrive
|
|
|
|
| 3 |
import os
|
| 4 |
+
import sys
|
| 5 |
+
import pandas as pd
|
| 6 |
|
| 7 |
################################
|
| 8 |
######### Variables ############
|
| 9 |
################################
|
| 10 |
+
# -- Loading Variables
|
| 11 |
+
script_directory = os.path.dirname(os.path.abspath(sys.argv[0]))
|
| 12 |
+
|
| 13 |
+
# -- Loading Session Data
|
| 14 |
+
if 'project_data' not in st.session_state:
|
| 15 |
+
st.session_state.project_data = pd.read_csv(script_directory+'/data/project.csv')
|
| 16 |
|
| 17 |
################################
|
| 18 |
####### GenericFunctions #######
|
| 19 |
################################
|
| 20 |
+
# -- Save Files
|
| 21 |
+
def save_data_files():
|
| 22 |
+
if not os.listdir(script_directory+"/data"):
|
| 23 |
+
gdrive.download_file("project.csv",script_directory+"/data/")
|
| 24 |
+
else:
|
| 25 |
+
print("Project details already exists")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
################################
|
| 28 |
####### Display of data ########
|
| 29 |
################################
|
| 30 |
+
# -- Streamlit Settings
|
| 31 |
+
st.set_page_config(layout='wide')
|
| 32 |
+
st.title("Dashboard")
|
| 33 |
+
|
| 34 |
+
# -- Load base files from Google Drive
|
| 35 |
+
save_data_files()
|
| 36 |
+
|
| 37 |
+
# -- Show Metrics
|
| 38 |
+
col1, col2, col3 = st.columns(3)
|
| 39 |
+
col1.metric("Projects", len(st.session_state.project_data))
|
| 40 |
+
|
| 41 |
+
# -- Transformations Performed
|
| 42 |
+
col2.metric("Transformations", "12")
|