model-metadata/code_python_files
013k
1# /// script2# 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 22try:23 # Use a pipeline as a high-level helper24 from transformers import pipeline25 26 pipe = pipeline("text-generation", model="codelion/dhara-70m", trust_remote_code=True)27 with open('codelion_dhara-70m_0.txt', 'w', encoding='utf-8') as f:28 f.write('Everything was good in codelion_dhara-70m_0.txt')29except Exception as e:30 import os31 from slack_sdk import WebClient32 client = WebClient(token=os.environ['SLACK_TOKEN'])33 client.chat_postMessage(34 channel='#hub-model-metadata-snippets-sprint',35 text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/codelion_dhara-70m_0.txt|codelion_dhara-70m_0.txt>',36 )37 38 with open('codelion_dhara-70m_0.txt', 'a', encoding='utf-8') as f:39 import traceback40 f.write('''```CODE: 41# Use a pipeline as a high-level helper42from transformers import pipeline43 44pipe = pipeline("text-generation", model="codelion/dhara-70m", trust_remote_code=True)45```46 47ERROR: 48''')49 traceback.print_exc(file=f)50 51finally:52 from huggingface_hub import upload_file53 upload_file(54 path_or_fileobj='codelion_dhara-70m_0.txt',55 repo_id='model-metadata/code_execution_files',56 path_in_repo='codelion_dhara-70m_0.txt',57 repo_type='dataset',58 )59 