ariG23498 HF Staff commited on
Commit
6a2ceaa
·
verified ·
1 Parent(s): dd3ae73

Upload google_gemma-3n-E2B-it-litert-lm_0.py with huggingface_hub

Browse files
google_gemma-3n-E2B-it-litert-lm_0.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "numpy",
5
+ # "einops",
6
+ # "pandas",
7
+ # "matplotlib",
8
+ # "protobuf",
9
+ # "torch",
10
+ # "sentencepiece",
11
+ # "torchvision",
12
+ # "transformers",
13
+ # "timm",
14
+ # "diffusers",
15
+ # "sentence-transformers",
16
+ # "accelerate",
17
+ # "peft",
18
+ # "slack-sdk",
19
+ # ]
20
+ # ///
21
+
22
+ try:
23
+ from huggingface_hub import login
24
+ login(new_session=False)
25
+ with open('google_gemma-3n-E2B-it-litert-lm_0.txt', 'w', encoding='utf-8') as f:
26
+ f.write('Everything was good in google_gemma-3n-E2B-it-litert-lm_0.txt')
27
+ except Exception as e:
28
+ import os
29
+ from slack_sdk import WebClient
30
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
31
+ client.chat_postMessage(
32
+ channel='#hub-model-metadata-snippets-sprint',
33
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/google_gemma-3n-E2B-it-litert-lm_0.txt|google_gemma-3n-E2B-it-litert-lm_0.txt>',
34
+ )
35
+
36
+ with open('google_gemma-3n-E2B-it-litert-lm_0.txt', 'a', encoding='utf-8') as f:
37
+ import traceback
38
+ f.write('''```CODE:
39
+ from huggingface_hub import login
40
+ login(new_session=False)
41
+ ```
42
+
43
+ ERROR:
44
+ ''')
45
+ traceback.print_exc(file=f)
46
+
47
+ finally:
48
+ from huggingface_hub import upload_file
49
+ upload_file(
50
+ path_or_fileobj='google_gemma-3n-E2B-it-litert-lm_0.txt',
51
+ repo_id='model-metadata/code_execution_files',
52
+ path_in_repo='google_gemma-3n-E2B-it-litert-lm_0.txt',
53
+ repo_type='dataset',
54
+ )