model-metadata/code_python_files
013k
1# /// script2# requires-python = ">=3.12"3# dependencies = [4# "torch",5# "torchvision",6# "transformers",7# "diffusers",8# "sentence-transformers",9# "accelerate",10# "peft",11# "slack-sdk",12# ]13# ///14 15try:16 #@title Licensed under the Apache License, Version 2.0 (the "License");17 # you may not use this file except in compliance with the License.18 # You may obtain a copy of the License at19 #20 # https://www.apache.org/licenses/LICENSE-2.021 #22 # Unless required by applicable law or agreed to in writing, software23 # distributed under the License is distributed on an "AS IS" BASIS,24 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.25 # See the License for the specific language governing permissions and26 # limitations under the License.27 with open('google_embeddinggemma-300m_0.txt', 'w', encoding='utf-8') as f:28 f.write('Everything was good in google_embeddinggemma-300m_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/google_embeddinggemma-300m_0.txt|google_embeddinggemma-300m_0.txt>',36 )37 38 with open('google_embeddinggemma-300m_0.txt', 'a', encoding='utf-8') as f:39 import traceback40 f.write('''```CODE: 41#@title Licensed under the Apache License, Version 2.0 (the "License");42# you may not use this file except in compliance with the License.43# You may obtain a copy of the License at44#45# https://www.apache.org/licenses/LICENSE-2.046#47# Unless required by applicable law or agreed to in writing, software48# distributed under the License is distributed on an "AS IS" BASIS,49# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.50# See the License for the specific language governing permissions and51# limitations under the License.52```53 54ERROR: 55''')56 traceback.print_exc(file=f)57 58finally:59 from huggingface_hub import upload_file60 upload_file(61 path_or_fileobj='google_embeddinggemma-300m_0.txt',62 repo_id='model-metadata/code_execution_files',63 path_in_repo='google_embeddinggemma-300m_0.txt',64 repo_type='dataset',65 )66 