Spaces:
Sleeping
Sleeping
Commit
ยท
10ac0d4
1
Parent(s):
b20d33a
updating show preds
Browse files- README copy.md +0 -57
- app.py +9 -8
README copy.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: DIS IPL Predictions
|
| 3 |
-
emoji: ๐ฆ
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: pink
|
| 6 |
-
sdk: streamlit
|
| 7 |
-
sdk_version: 1.32.2
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: apache-2.0
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
# DIS IPL Match Predictions App
|
| 14 |
-
|
| 15 |
-
> "Predict, Compete, and Win ๐ - Where Every Guess Counts! ๐"
|
| 16 |
-
|
| 17 |
-
Welcome to the DIS IPL Match Predictions App! This app allows you to predict the outcomes of IPL matches and compete with your colleagues to win exciting prizes.
|
| 18 |
-
|
| 19 |
-
## Getting Started
|
| 20 |
-
|
| 21 |
-
### Prerequisites
|
| 22 |
-
|
| 23 |
-
- Python 3.x installed on your system
|
| 24 |
-
- Git installed on your system
|
| 25 |
-
- Pip package manager
|
| 26 |
-
|
| 27 |
-
### Installation
|
| 28 |
-
|
| 29 |
-
1. Clone this repository to your local machine using Git:
|
| 30 |
-
|
| 31 |
-
```bash
|
| 32 |
-
git clone <repository_url>
|
| 33 |
-
```
|
| 34 |
-
|
| 35 |
-
2. Navigate to the cloned repository directory:
|
| 36 |
-
|
| 37 |
-
```bash
|
| 38 |
-
cd ipl-match-predictions-app
|
| 39 |
-
```
|
| 40 |
-
|
| 41 |
-
3. Install the required Python dependencies using Pip:
|
| 42 |
-
|
| 43 |
-
```bash
|
| 44 |
-
pip install -r requirements.txt
|
| 45 |
-
```
|
| 46 |
-
|
| 47 |
-
### Running The APP
|
| 48 |
-
|
| 49 |
-
1. After installing the dependencies, you can run the Streamlit app using the following command:
|
| 50 |
-
|
| 51 |
-
```bash
|
| 52 |
-
streamlit run app.py
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
2. The app will start running locally and open in your default web browser.
|
| 56 |
-
|
| 57 |
-
Thanks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -23,12 +23,16 @@ image_path = 'ipl_image.png'
|
|
| 23 |
PREDICTIONS_FOLDER = Path("ipl_predictions")
|
| 24 |
PREDICTIONS_FOLDER.mkdir(parents=True, exist_ok=True)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# Initialize CommitScheduler
|
| 27 |
scheduler = CommitScheduler(
|
| 28 |
repo_id="DIS_IPL_Dataset",
|
| 29 |
repo_type="dataset",
|
| 30 |
folder_path=PREDICTIONS_FOLDER, # Local folder where predictions are saved temporarily
|
| 31 |
-
path_in_repo="
|
| 32 |
every=2, # Push every 240 minutes (4 hours)
|
| 33 |
)
|
| 34 |
|
|
@@ -140,9 +144,6 @@ def submit_prediction(
|
|
| 140 |
st.error(f"Your bid points exceed the 20% limit of your total points. Maximum allowed bid points: {max_bid_points}")
|
| 141 |
return
|
| 142 |
|
| 143 |
-
|
| 144 |
-
# New: Generate a unique ID for this prediction
|
| 145 |
-
prediction_id = uuid.uuid4().hex
|
| 146 |
prediction_date = datetime.now().strftime('%Y-%m-%d')
|
| 147 |
|
| 148 |
prediction_data = {
|
|
@@ -155,10 +156,10 @@ def submit_prediction(
|
|
| 155 |
'prediction_date': prediction_date # Include the prediction date
|
| 156 |
}
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
|
| 163 |
st.success("Prediction submitted successfully!")
|
| 164 |
|
|
|
|
| 23 |
PREDICTIONS_FOLDER = Path("ipl_predictions")
|
| 24 |
PREDICTIONS_FOLDER.mkdir(parents=True, exist_ok=True)
|
| 25 |
|
| 26 |
+
prediction_id = uuid.uuid4().hex
|
| 27 |
+
# Save prediction to a local JSON file for CommitScheduler to handle
|
| 28 |
+
prediction_file_path = f"{PREDICTIONS_FOLDER}/prediction_{prediction_id}.json"
|
| 29 |
+
|
| 30 |
# Initialize CommitScheduler
|
| 31 |
scheduler = CommitScheduler(
|
| 32 |
repo_id="DIS_IPL_Dataset",
|
| 33 |
repo_type="dataset",
|
| 34 |
folder_path=PREDICTIONS_FOLDER, # Local folder where predictions are saved temporarily
|
| 35 |
+
path_in_repo="data", # Path in dataset repo where predictions will be saved
|
| 36 |
every=2, # Push every 240 minutes (4 hours)
|
| 37 |
)
|
| 38 |
|
|
|
|
| 144 |
st.error(f"Your bid points exceed the 20% limit of your total points. Maximum allowed bid points: {max_bid_points}")
|
| 145 |
return
|
| 146 |
|
|
|
|
|
|
|
|
|
|
| 147 |
prediction_date = datetime.now().strftime('%Y-%m-%d')
|
| 148 |
|
| 149 |
prediction_data = {
|
|
|
|
| 156 |
'prediction_date': prediction_date # Include the prediction date
|
| 157 |
}
|
| 158 |
|
| 159 |
+
with scheduler.lock:
|
| 160 |
+
with prediction_file_path.open("a") as file:
|
| 161 |
+
file.write(json.dumps(prediction_data))
|
| 162 |
+
file.write("\n")
|
| 163 |
|
| 164 |
st.success("Prediction submitted successfully!")
|
| 165 |
|