File size: 1,428 Bytes
0f115b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f82747d
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

import json
from datasets import load_dataset



class get_files:

    def predefined_dataset(dataset_name):
        global dataset # bad practice, I know... But just bear with me. Will later update to state dict.
        dataset = load_dataset(dataset_name, split = "train")
        return 'Successfully loaded dataset'
    
    def uploaded_dataset(file):
        global dataset # bad practice, I know... But just bear with me. Will later update to state dict.
        dataset = []
        if file is None:
            return "File not found. Please upload the file again."
        try:
            with open(file,'r') as file:
                for line in file:
                    dataset.append(json.loads(line.strip()))
            return "File retrieved."
        except FileNotFoundError:
            return "File not found. Please upload the file again."

    def load_markdown_file(file_path):
        try:
            with open(file_path, 'r') as f:
                return f.read()
        except FileNotFoundError:
            return "File not found. Please check the file path."
        except Exception as e:
            return f"Error loading file: {str(e)}"

def submit_weights(model, repository, model_out_name, token):
    """submits model to repository"""
    repo = repository + '/' + model_out_name
    
    model.push_to_hub(repo, token = token)
    tokenizer.push_to_hub(repo, token = token)
    return 0