Update server.py
Browse files
server.py
CHANGED
|
@@ -1,37 +1,4 @@
|
|
| 1 |
|
| 2 |
-
import json
|
| 3 |
-
from datasets import load_dataset
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
class get_files:
|
| 8 |
-
|
| 9 |
-
def predefined_dataset(dataset_name):
|
| 10 |
-
global dataset # bad practice, I know... But just bear with me. Will later update to state dict.
|
| 11 |
-
dataset = load_dataset(dataset_name, split = "train")
|
| 12 |
-
return 'Successfully loaded dataset'
|
| 13 |
-
|
| 14 |
-
def uploaded_dataset(file):
|
| 15 |
-
global dataset # bad practice, I know... But just bear with me. Will later update to state dict.
|
| 16 |
-
dataset = []
|
| 17 |
-
if file is None:
|
| 18 |
-
return "File not found. Please upload the file again."
|
| 19 |
-
try:
|
| 20 |
-
with open(file,'r') as file:
|
| 21 |
-
for line in file:
|
| 22 |
-
dataset.append(json.loads(line.strip()))
|
| 23 |
-
return "File retrieved."
|
| 24 |
-
except FileNotFoundError:
|
| 25 |
-
return "File not found. Please upload the file again."
|
| 26 |
-
|
| 27 |
-
def load_markdown_file(file_path):
|
| 28 |
-
try:
|
| 29 |
-
with open(file_path, 'r') as f:
|
| 30 |
-
return f.read()
|
| 31 |
-
except FileNotFoundError:
|
| 32 |
-
return "File not found. Please check the file path."
|
| 33 |
-
except Exception as e:
|
| 34 |
-
return f"Error loading file: {str(e)}"
|
| 35 |
|
| 36 |
def submit_weights(model, repository, model_out_name, token):
|
| 37 |
"""submits model to repository"""
|
|
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def submit_weights(model, repository, model_out_name, token):
|
| 4 |
"""submits model to repository"""
|