Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .github/workflows/main.yamlAdded+28
- .gitignoreAdded+160
- DT.pickleAdded+3
- DockerfileAdded+12
- GaussianNB.pickleAdded+3
- IRIS FLOWER CLASSIFICATION using machine learning models.ipynbAdded
- IRIS-FLOWER-CLASSIFICATION-using-machine-learning-models/.gitattributesAdded+35
- IRIS-FLOWER-CLASSIFICATION-using-machine-learning-models/README.mdAdded+11
- LICENSEAdded+201
- Logistic.pickleAdded+3
- README.mdAdded+110
- SVM.pickleAdded+3
- app.pyAdded+40
- knn.pickleAdded+3
- mytree.dotAdded+37
- requirements.txtAdded+8
- rf.pickleAdded+3
- templates/home.htmlAdded+86
- transformers/.circleci/TROUBLESHOOT.mdAdded+7
- transformers/.circleci/config.ymlAdded+232
- transformers/.circleci/create_circleci_config.pyAdded+678
- transformers/.coveragercAdded+12
- transformers/.gitattributesAdded+4
- transformers/.github/ISSUE_TEMPLATE/bug-report.ymlAdded+116
- transformers/.github/ISSUE_TEMPLATE/config.ymlAdded+12
- transformers/.github/ISSUE_TEMPLATE/feature-request.ymlAdded+31
- transformers/.github/ISSUE_TEMPLATE/i18n.mdAdded+46
- transformers/.github/ISSUE_TEMPLATE/migration.ymlAdded+72
- transformers/.github/ISSUE_TEMPLATE/new-model-addition.ymlAdded+31
- transformers/.github/PULL_REQUEST_TEMPLATE.mdAdded+78
- transformers/.github/conda/build.shAdded+1
- transformers/.github/conda/meta.yamlAdded+56
- transformers/.github/workflows/TROUBLESHOOT.mdAdded+9
- transformers/.github/workflows/add-model-like.ymlAdded+80
- transformers/.github/workflows/build-docker-images.ymlAdded+333
- transformers/.github/workflows/build-nightly-ci-docker-images.ymlAdded+85
- transformers/.github/workflows/build-past-ci-docker-images.ymlAdded+99
- transformers/.github/workflows/build_documentation.ymlAdded+22
- transformers/.github/workflows/build_pr_documentation.ymlAdded+18
- transformers/.github/workflows/check_tiny_models.ymlAdded+82
- transformers/.github/workflows/doctests.ymlAdded+83
- transformers/.github/workflows/model-templates.ymlAdded+81
- transformers/.github/workflows/model_jobs.ymlAdded+102
- transformers/.github/workflows/release-conda.ymlAdded+47
- transformers/.github/workflows/self-nightly-past-ci-caller.ymlAdded+134
- transformers/.github/workflows/self-nightly-scheduled.ymlAdded+290
- transformers/.github/workflows/self-past.ymlAdded+357
- transformers/.github/workflows/self-push-amd-mi210-caller.ymlAdded+25
- transformers/.github/workflows/self-push-amd-mi250-caller.ymlAdded+25
- transformers/.github/workflows/self-push-amd.ymlAdded+329
12345678910111213141516171819202122232425262728name: Deploy to Hugging Face Spaces
on: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v2
- name: Login to Hugging Face uses: Hugging Face/action-hub-docker-login@v1 with: email: ${{ secrets.HUGGINGFACE_EMAIL }} hf-api-token: ${{ secrets.HUGGINGFACE_TOKEN }} hf_app_name: ${{ secrets.HEROKU_APP_NAME }}
- name: Build, Push and Release to Hugging Face Spaces uses: Hugging Face/action-hub-push@v1 with: email: ${{ secrets.HUGGINGFACE_EMAIL }} hf-api-token: ${{ secrets.HUGGINGFACE_TOKEN }} hf_app_name: ${{ secrets.HEROKU_APP_NAME }} dockerfile: Dockerfile context: ./123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class
# C extensions*.so
# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/share/python-wheels/*.egg-info/.installed.cfg*.eggMANIFEST
# PyInstaller# Usually these files are written by a python script from a template# before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec
# Installer logspip-log.txtpip-delete-this-directory.txt
# Unit test / coverage reportshtmlcov/.tox/.nox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover*.py,cover.hypothesis/.pytest_cache/cover/
# Translations*.mo*.pot
# Django stuff:*.loglocal_settings.pydb.sqlite3db.sqlite3-journal
# Flask stuff:instance/.webassets-cache
# Scrapy stuff:.scrapy
# Sphinx documentationdocs/_build/
# PyBuilder.pybuilder/target/
# Jupyter Notebook.ipynb_checkpoints
# IPythonprofile_default/ipython_config.py
# pyenv# For a library or package, you might want to ignore these files since the code is# intended to run in multiple environments; otherwise, check them in:# .python-version
# pipenv# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.# However, in case of collaboration, if having platform-specific dependencies or dependencies# having no cross-platform support, pipenv may install dependencies that don't work, or not# install all needed dependencies.#Pipfile.lock
# poetry# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.# This is especially recommended for binary packages to ensure reproducibility, and is more# commonly ignored for libraries.# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control#poetry.lock
# pdm# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.#pdm.lock# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it# in version control.# https://pdm.fming.dev/#use-with-ide.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm__pypackages__/
# Celery stuffcelerybeat-schedulecelerybeat.pid
# SageMath parsed files*.sage.py
# Environments.env.venvenv/venv/ENV/env.bak/venv.bak/
# Spyder project settings.spyderproject.spyproject
# Rope project settings.ropeproject
# mkdocs documentation/site
# mypy.mypy_cache/.dmypy.jsondmypy.json
# Pyre type checker.pyre/
# pytype static type analyzer.pytype/
# Cython debug symbolscython_debug/
# PyCharm# JetBrains specific template is maintained in a separate JetBrains.gitignore that can# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore# and can be added to the global gitignore or merged into this file. For a more nuclear# option (not recommended) you can uncomment the following to ignore the entire idea folder.#.idea/123version https://git-lfs.github.com/spec/v1oid sha256:15524acb9fb06bccbdbae58f92b63a9074bca93030c1471d953bfef11684f11esize 4135123456789101112# Use Python 3.10.14 as the base imageFROM python:3.10.14
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY . .
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]123version https://git-lfs.github.com/spec/v1oid sha256:15524acb9fb06bccbdbae58f92b63a9074bca93030c1471d953bfef11684f11esize 41351234567891011121314151617181920212223242526272829303132333435*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text1234567891011---title: IRIS FLOWER CLASSIFICATION Using Machine Learning Modelsemoji: 🏃colorFrom: yellowcolorTo: indigosdk: dockerpinned: falselicense: apache-2.0---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.123version https://git-lfs.github.com/spec/v1oid sha256:15524acb9fb06bccbdbae58f92b63a9074bca93030c1471d953bfef11684f11esize 4135123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110# IRIS-FLOWER-CLASSIFICATION-using-machine-learning-models# Software And Tools Requirements1. [Github Account](https://github.com)2. [HerokuAccount](https://www.heroku.com/)3. [VSCodeIDE](https://code.visualstudio.com/)4. [GitCLI](https://git-scm.com/book/en/v2/Getting-Started-The-Command-Line)
Create a new environment
```conda create -p venv python==3.10.14 -y
```
Activating Environment
```conda activate venv/
```
Install Requirements
```
pip install -r requirements.txt
```Docker image run steps
```docker build -t flask .docker run -it -p 7860:7860 flask
docker ps
```Hugging face deployment stepshttps://huggingface.co/docs/transformers/model_doc/pegasus
```
pip install transformers
pip install torchimport torchgit clone https://github.com/huggingface/transformers.githuggingface-cli login
```Configure user name
```git config --global user.name "Gnaneshwari"git config --global user.name
```
Configure user email
```git config --global user.email "gnaneshwari.m2009@gmail.com"git config --global user.email
```
Adding Files to github
```git init
git add requirements.txt git add .
```
Checking the Status of git push
```git status
```
Commit files to git
```git commit -m "This commit includes requirements.txt and readme files"
```
Config email for first time
```git config --global user.email "gnaneshwari.m2009@gmail.com"
```
Pushing files in git
```git push origin main
```
To Validate Json
```https://jsonlint.com/
```123version https://git-lfs.github.com/spec/v1oid sha256:15524acb9fb06bccbdbae58f92b63a9074bca93030c1471d953bfef11684f11esize 413512345678910111213141516171819202122232425262728293031323334353637383940# from transformers import PegasusForConditionalGeneration, PegasusTokenizerimport jsonimport pickleimport torch
from flask import Flask, request, jsonify, render_templateimport numpy as np
app = Flask(__name__)# model_name = "google/pegasus-xsum"# Load the modelwith open('rf.pickle', 'rb') as f: rf = pickle.load(f)
@app.route('/')def home(): return render_template('home.html')
@app.route('/predict_api', methods=['POST'])def predict_api(): try: data = request.json['data'] new_data = np.array(list(data.values())).reshape(1, -1) output = rf.predict(new_data)[0] return jsonify({'prediction': str(output)}) except Exception as e: return jsonify({'error': str(e)})
@app.route('/predict', methods=['POST'])def predict(): try: data = [float(x) for x in request.form.values()] final_input = np.array(data).reshape(1, -1) output = rf.predict(final_input)[0] return render_template("home.html", prediction_text="IRIS-FLOWER-CLASSIFICATION prediction is {}".format(output)) except Exception as e: return render_template("home.html", prediction_text="Error: {}".format(str(e)))
if __name__ == "__main__": app.run(host="0.0.0.0",port=int("7860"),debug=True)123version https://git-lfs.github.com/spec/v1oid sha256:15524acb9fb06bccbdbae58f92b63a9074bca93030c1471d953bfef11684f11esize 413512345678910111213141516171819202122232425262728293031323334353637digraph Tree {node [shape=box, fontname="helvetica"] ;edge [fontname="helvetica"] ;0 [label="x[2] <= 2.45\ngini = 0.666\nsamples = 120\nvalue = [42, 39, 39]"] ;1 [label="gini = 0.0\nsamples = 42\nvalue = [42, 0, 0]"] ;0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;2 [label="x[3] <= 1.75\ngini = 0.5\nsamples = 78\nvalue = [0, 39, 39]"] ;0 -> 2 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;3 [label="x[2] <= 4.95\ngini = 0.206\nsamples = 43\nvalue = [0, 38, 5]"] ;2 -> 3 ;4 [label="x[3] <= 1.65\ngini = 0.053\nsamples = 37\nvalue = [0, 36, 1]"] ;3 -> 4 ;5 [label="gini = 0.0\nsamples = 36\nvalue = [0, 36, 0]"] ;4 -> 5 ;6 [label="gini = 0.0\nsamples = 1\nvalue = [0, 0, 1]"] ;4 -> 6 ;7 [label="x[3] <= 1.55\ngini = 0.444\nsamples = 6\nvalue = [0, 2, 4]"] ;3 -> 7 ;8 [label="gini = 0.0\nsamples = 3\nvalue = [0, 0, 3]"] ;7 -> 8 ;9 [label="x[2] <= 5.45\ngini = 0.444\nsamples = 3\nvalue = [0, 2, 1]"] ;7 -> 9 ;10 [label="gini = 0.0\nsamples = 2\nvalue = [0, 2, 0]"] ;9 -> 10 ;11 [label="gini = 0.0\nsamples = 1\nvalue = [0, 0, 1]"] ;9 -> 11 ;12 [label="x[2] <= 4.85\ngini = 0.056\nsamples = 35\nvalue = [0, 1, 34]"] ;2 -> 12 ;13 [label="x[1] <= 3.1\ngini = 0.444\nsamples = 3\nvalue = [0, 1, 2]"] ;12 -> 13 ;14 [label="gini = 0.0\nsamples = 2\nvalue = [0, 0, 2]"] ;13 -> 14 ;15 [label="gini = 0.0\nsamples = 1\nvalue = [0, 1, 0]"] ;13 -> 15 ;16 [label="gini = 0.0\nsamples = 32\nvalue = [0, 0, 32]"] ;12 -> 16 ;}12345678Flaskscikit-learnpandasnumpymatplotlibgunicornseaborngunicorn123version https://git-lfs.github.com/spec/v1oid sha256:ea33980970b45438f77f58b00c7a78e290014ea3c49b7c9a483db29ad91b1e16size 1632841234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586<!DOCTYPE html><html>
<head> <meta charset="UTF-8"> <title>IRIS-FLOWER-CLASSIFICATION Prediction</title> <link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Arimo' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Hind:300' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'> <style> body { font-family: 'Arimo', sans-serif; background-color: #f4f4f4; margin: 0; padding: 0; }
.container { max-width: 600px; margin: 50px auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); }
h1 { font-family: 'Montserrat', cursive; font-size: 36px; margin-bottom: 20px; text-align: center; color: #333; }
form { text-align: center; }
input[type="text"] { width: 100%; padding: 10px; margin-bottom: 20px; border-radius: 5px; border: 1px solid #ccc; box-sizing: border-box; }
button[type="submit"] { width: 100%; background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
button[type="submit"]:hover { background-color: #45a049; }
.error-message { color: blue; font-size: 14px; margin-top: 10px; } </style></head>
<body> <div class="container"> <h1>IRIS-FLOWER-CLASSIFICATION Prediction</h1> <form action="{{ url_for('predict')}}" method="post"> <input type="text" name='SepalLengthCm' placeholder="Sepal Length (cm)" required><br> <input type="text" name='SepalWidthCm' placeholder="Sepal Width (cm)" required><br> <input type="text" name='PetalLengthCm' placeholder="Petal Length (cm)" required><br> <input type="text" name='PetalWidthCm' placeholder="Petal Width (cm)" required><br> <button type="submit">Predict</button> </form> <div class="error-message">{{prediction_text}}</div> </div></body>
</html>1234567# Troubleshooting
This is a document explaining how to deal with various issues on Circle-CI. The entries may include actual solutions or pointers to Issues that cover those.
## Circle CI
* pytest worker runs out of resident RAM and gets killed by `cgroups`: https://github.com/huggingface/transformers/issues/11408123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232version: 2.1setup: trueorbs: continuation: circleci/continuation@0.1.0
parameters: nightly: type: boolean default: false
jobs: # Ensure running with CircleCI/huggingface check_circleci_user: docker: - image: cimg/python:3.8.12 parallelism: 1 steps: - run: echo $CIRCLE_PROJECT_USERNAME - run: | if [ "$CIRCLE_PROJECT_USERNAME" = "huggingface" ]; then exit 0 else echo "The CI is running under $CIRCLE_PROJECT_USERNAME personal account. Please follow https://support.circleci.com/hc/en-us/articles/360008097173-Troubleshooting-why-pull-requests-are-not-triggering-jobs-on-my-organization- to fix it."; exit -1 fi # Fetch the tests to run fetch_tests: working_directory: ~/transformers docker: - image: cimg/python:3.8.12 parallelism: 1 steps: - checkout - run: pip install --upgrade --upgrade-strategy eager pip - run: pip install -U --upgrade-strategy eager GitPython - run: pip install -U --upgrade-strategy eager . - run: mkdir -p test_preparation - run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt - store_artifacts: path: ~/transformers/tests_fetched_summary.txt - run: | if [ -f test_list.txt ]; then cp test_list.txt test_preparation/test_list.txt else touch test_preparation/test_list.txt fi - run: | if [ -f examples_test_list.txt ]; then mv examples_test_list.txt test_preparation/examples_test_list.txt else touch test_preparation/examples_test_list.txt fi - run: | if [ -f filtered_test_list_cross_tests.txt ]; then mv filtered_test_list_cross_tests.txt test_preparation/filtered_test_list_cross_tests.txt else touch test_preparation/filtered_test_list_cross_tests.txt fi - run: | if [ -f doctest_list.txt ]; then cp doctest_list.txt test_preparation/doctest_list.txt else touch test_preparation/doctest_list.txt fi - run: | if [ -f test_repo_utils.txt ]; then mv test_repo_utils.txt test_preparation/test_repo_utils.txt else touch test_preparation/test_repo_utils.txt fi - run: python utils/tests_fetcher.py --filter_tests - run: | if [ -f test_list.txt ]; then mv test_list.txt test_preparation/filtered_test_list.txt else touch test_preparation/filtered_test_list.txt fi - store_artifacts: path: test_preparation/test_list.txt - store_artifacts: path: test_preparation/doctest_list.txt - store_artifacts: path: ~/transformers/test_preparation/filtered_test_list.txt - store_artifacts: path: test_preparation/examples_test_list.txt - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation - run: | if [ ! -s test_preparation/generated_config.yml ]; then echo "No tests to run, exiting early!" circleci-agent step halt fi - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt - store_artifacts: path: test_preparation/generated_config.txt - store_artifacts: path: test_preparation/filtered_test_list_cross_tests.txt - continuation/continue: configuration_path: test_preparation/generated_config.yml
# To run all tests for the nightly build fetch_all_tests: working_directory: ~/transformers docker: - image: cimg/python:3.8.12 parallelism: 1 steps: - checkout - run: pip install --upgrade --upgrade-strategy eager pip - run: pip install -U --upgrade-strategy eager GitPython - run: pip install -U --upgrade-strategy eager . - run: | mkdir test_preparation echo -n "tests" > test_preparation/test_list.txt echo -n "all" > test_preparation/examples_test_list.txt echo -n "tests/repo_utils" > test_preparation/test_repo_utils.txt - run: | echo -n "tests" > test_list.txt python utils/tests_fetcher.py --filter_tests mv test_list.txt test_preparation/filtered_test_list.txt - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt - store_artifacts: path: test_preparation/generated_config.txt - continuation/continue: configuration_path: test_preparation/generated_config.yml
check_code_quality: working_directory: ~/transformers docker: - image: cimg/python:3.8.12 resource_class: large environment: TRANSFORMERS_IS_CI: yes PYTEST_TIMEOUT: 120 parallelism: 1 steps: - checkout - restore_cache: keys: - v0.7-code_quality-pip-{{ checksum "setup.py" }} - v0.7-code-quality-pip - restore_cache: keys: - v0.7-code_quality-site-packages-{{ checksum "setup.py" }} - v0.7-code-quality-site-packages - run: pip install --upgrade --upgrade-strategy eager pip - run: pip install -U --upgrade-strategy eager .[all,quality] - save_cache: key: v0.7-code_quality-pip-{{ checksum "setup.py" }} paths: - '~/.cache/pip' - save_cache: key: v0.7-code_quality-site-packages-{{ checksum "setup.py" }} paths: - '~/.pyenv/versions/' - run: name: Show installed libraries and their versions command: pip freeze | tee installed.txt - store_artifacts: path: ~/transformers/installed.txt - run: python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1) - run: ruff check examples tests src utils - run: ruff format tests src utils --check - run: python utils/custom_init_isort.py --check_only - run: python utils/sort_auto_mappings.py --check_only - run: python utils/check_doc_toc.py
check_repository_consistency: working_directory: ~/transformers docker: - image: cimg/python:3.8.12 resource_class: large environment: TRANSFORMERS_IS_CI: yes PYTEST_TIMEOUT: 120 parallelism: 1 steps: - checkout - restore_cache: keys: - v0.7-repository_consistency-pip-{{ checksum "setup.py" }} - v0.7-repository_consistency-pip - restore_cache: keys: - v0.7-repository_consistency-site-packages-{{ checksum "setup.py" }} - v0.7-repository_consistency-site-packages - run: pip install --upgrade --upgrade-strategy eager pip - run: pip install -U --upgrade-strategy eager .[all,quality] - save_cache: key: v0.7-repository_consistency-pip-{{ checksum "setup.py" }} paths: - '~/.cache/pip' - save_cache: key: v0.7-repository_consistency-site-packages-{{ checksum "setup.py" }} paths: - '~/.pyenv/versions/' - run: name: Show installed libraries and their versions command: pip freeze | tee installed.txt - store_artifacts: path: ~/transformers/installed.txt - run: python utils/check_copies.py - run: python utils/check_table.py - run: python utils/check_dummies.py - run: python utils/check_repo.py - run: python utils/check_inits.py - run: python utils/check_config_docstrings.py - run: python utils/check_config_attributes.py - run: python utils/check_doctest_list.py - run: make deps_table_check_updated - run: python utils/update_metadata.py --check-only - run: python utils/check_task_guides.py - run: python utils/check_docstrings.py - run: python utils/check_support_list.py
workflows: version: 2 setup_and_quality: when: not: <<pipeline.parameters.nightly>> jobs: - check_circleci_user - check_code_quality - check_repository_consistency - fetch_tests
nightly: when: <<pipeline.parameters.nightly>> jobs: - check_circleci_user - check_code_quality - check_repository_consistency - fetch_all_tests123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678# coding=utf-8# Copyright 2022 The HuggingFace Inc. team.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.
import argparseimport copyimport osimport randomfrom dataclasses import dataclassfrom typing import Any, Dict, List, Optional
import yaml
COMMON_ENV_VARIABLES = { "OMP_NUM_THREADS": 1, "TRANSFORMERS_IS_CI": True, "PYTEST_TIMEOUT": 120, "RUN_PIPELINE_TESTS": False, "RUN_PT_TF_CROSS_TESTS": False, "RUN_PT_FLAX_CROSS_TESTS": False,}# Disable the use of {"s": None} as the output is way too long, causing the navigation on CircleCI impracticalCOMMON_PYTEST_OPTIONS = {"max-worker-restart": 0, "dist": "loadfile", "v": None}DEFAULT_DOCKER_IMAGE = [{"image": "cimg/python:3.8.12"}]
class EmptyJob: job_name = "empty"
def to_dict(self): return { "working_directory": "~/transformers", "docker": copy.deepcopy(DEFAULT_DOCKER_IMAGE), "steps":["checkout"], }
@dataclassclass CircleCIJob: name: str additional_env: Dict[str, Any] = None cache_name: str = None cache_version: str = "0.8.2" docker_image: List[Dict[str, str]] = None install_steps: List[str] = None marker: Optional[str] = None parallelism: Optional[int] = 1 pytest_num_workers: int = 12 pytest_options: Dict[str, Any] = None resource_class: Optional[str] = "2xlarge" tests_to_run: Optional[List[str]] = None working_directory: str = "~/transformers" # This should be only used for doctest job! command_timeout: Optional[int] = None
def __post_init__(self): # Deal with defaults for mutable attributes. if self.additional_env is None: self.additional_env = {} if self.cache_name is None: self.cache_name = self.name if self.docker_image is None: # Let's avoid changing the default list and make a copy. self.docker_image = copy.deepcopy(DEFAULT_DOCKER_IMAGE) if self.install_steps is None: self.install_steps = [] if self.pytest_options is None: self.pytest_options = {} if isinstance(self.tests_to_run, str): self.tests_to_run = [self.tests_to_run] if self.parallelism is None: self.parallelism = 1
def to_dict(self): env = COMMON_ENV_VARIABLES.copy() env.update(self.additional_env)
cache_branch_prefix = os.environ.get("CIRCLE_BRANCH", "pull") if cache_branch_prefix != "main": cache_branch_prefix = "pull"
job = { "working_directory": self.working_directory, "docker": self.docker_image, "environment": env, } if self.resource_class is not None: job["resource_class"] = self.resource_class if self.parallelism is not None: job["parallelism"] = self.parallelism steps = [ "checkout", {"attach_workspace": {"at": "~/transformers/test_preparation"}}, { "restore_cache": { "keys": [ # check the fully-matched cache first f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-pip-" + '{{ checksum "setup.py" }}', # try the partially-matched cache from `main` f"v{self.cache_version}-{self.cache_name}-main-pip-", # try the general partially-matched cache f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-pip-", ] } }, { "restore_cache": { "keys": [ f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-site-packages-" + '{{ checksum "setup.py" }}', f"v{self.cache_version}-{self.cache_name}-main-site-packages-", f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-site-packages-", ] } }, ] steps.extend([{"run": l} for l in self.install_steps]) steps.extend([{"run": 'pip install "fsspec>=2023.5.0,<2023.10.0"'}]) steps.extend([{"run": "pip install pytest-subtests"}]) steps.append({"run": {"name": "Show installed libraries and their versions", "command": "pip freeze | tee installed.txt"}}) steps.append({"store_artifacts": {"path": "~/transformers/installed.txt"}})
all_options = {**COMMON_PYTEST_OPTIONS, **self.pytest_options} pytest_flags = [f"--{key}={value}" if (value is not None or key in ["doctest-modules"]) else f"-{key}" for key, value in all_options.items()] pytest_flags.append( f"--make-reports={self.name}" if "examples" in self.name else f"--make-reports=tests_{self.name}" )
steps.append({"run": {"name": "Create `test-results` directory", "command": "mkdir test-results"}})
test_command = "" if self.command_timeout: test_command = f"timeout {self.command_timeout} " test_command += f"python -m pytest --junitxml=test-results/junit.xml -n {self.pytest_num_workers} " + " ".join(pytest_flags)
if self.parallelism == 1: if self.tests_to_run is None: test_command += " << pipeline.parameters.tests_to_run >>" else: test_command += " " + " ".join(self.tests_to_run) else: # We need explicit list instead of `pipeline.parameters.tests_to_run` (only available at job runtime) tests = self.tests_to_run if tests is None: folder = os.environ["test_preparation_dir"] test_file = os.path.join(folder, "filtered_test_list.txt") if os.path.exists(test_file): with open(test_file) as f: tests = f.read().split(" ")
# expand the test list if tests == ["tests"]: tests = [os.path.join("tests", x) for x in os.listdir("tests")] expanded_tests = [] for test in tests: if test.endswith(".py"): expanded_tests.append(test) elif test == "tests/models": expanded_tests.extend([os.path.join(test, x) for x in os.listdir(test)]) elif test == "tests/pipelines": expanded_tests.extend([os.path.join(test, x) for x in os.listdir(test)]) else: expanded_tests.append(test) # Avoid long tests always being collected together random.shuffle(expanded_tests) tests = " ".join(expanded_tests)
# Each executor to run ~10 tests n_executors = max(len(tests) // 10, 1) # Avoid empty test list on some executor(s) or launching too many executors if n_executors > self.parallelism: n_executors = self.parallelism job["parallelism"] = n_executors
# Need to be newline separated for the command `circleci tests split` below command = f'echo {tests} | tr " " "\\n" >> tests.txt' steps.append({"run": {"name": "Get tests", "command": command}})
command = 'TESTS=$(circleci tests split tests.txt) && echo $TESTS > splitted_tests.txt' steps.append({"run": {"name": "Split tests", "command": command}})
steps.append({"store_artifacts": {"path": "~/transformers/tests.txt"}}) steps.append({"store_artifacts": {"path": "~/transformers/splitted_tests.txt"}})
test_command = "" if self.timeout: test_command = f"timeout {self.timeout} " test_command += f"python -m pytest -n {self.pytest_num_workers} " + " ".join(pytest_flags) test_command += " $(cat splitted_tests.txt)" if self.marker is not None: test_command += f" -m {self.marker}"
if self.name == "pr_documentation_tests": # can't use ` | tee tee tests_output.txt` as usual test_command += " > tests_output.txt" # Save the return code, so we can check if it is timeout in the next step. test_command += '; touch "$?".txt' # Never fail the test step for the doctest job. We will check the results in the next step, and fail that # step instead if the actual test failures are found. This is to avoid the timeout being reported as test # failure. test_command = f"({test_command}) || true" else: test_command = f"({test_command} | tee tests_output.txt) || true" steps.append({"run": {"name": "Run tests", "command": test_command}})
# Deal with errors check_test_command = f'if [ -s reports/{self.job_name}/errors.txt ]; ' check_test_command += 'then echo "Some tests errored out!"; echo ""; ' check_test_command += f'cat reports/{self.job_name}/errors.txt; ' check_test_command += 'echo ""; echo ""; '
py_command = f'import os; fp = open("reports/{self.job_name}/summary_short.txt"); failed = os.linesep.join([x for x in fp.read().split(os.linesep) if x.startswith("ERROR ")]); fp.close(); fp = open("summary_short.txt", "w"); fp.write(failed); fp.close()' check_test_command += f"$(python3 -c '{py_command}'); " check_test_command += 'cat summary_short.txt; echo ""; exit -1; '
# Deeal with failed tests check_test_command += f'elif [ -s reports/{self.job_name}/failures_short.txt ]; ' check_test_command += 'then echo "Some tests failed!"; echo ""; ' check_test_command += f'cat reports/{self.job_name}/failures_short.txt; ' check_test_command += 'echo ""; echo ""; '
py_command = f'import os; fp = open("reports/{self.job_name}/summary_short.txt"); failed = os.linesep.join([x for x in fp.read().split(os.linesep) if x.startswith("FAILED ")]); fp.close(); fp = open("summary_short.txt", "w"); fp.write(failed); fp.close()' check_test_command += f"$(python3 -c '{py_command}'); " check_test_command += 'cat summary_short.txt; echo ""; exit -1; '
check_test_command += f'elif [ -s reports/{self.job_name}/stats.txt ]; then echo "All tests pass!"; '
# return code `124` means the previous (pytest run) step is timeout if self.name == "pr_documentation_tests": check_test_command += 'elif [ -f 124.txt ]; then echo "doctest timeout!"; '
check_test_command += 'else echo "other fatal error"; echo ""; exit -1; fi;'
steps.append({"run": {"name": "Check test results", "command": check_test_command}})
steps.append({"store_test_results": {"path": "test-results"}})
steps.append({"store_artifacts": {"path": "~/transformers/tests_output.txt"}}) steps.append({"store_artifacts": {"path": "~/transformers/reports"}})
# save cache at the end: so pytest step runs before cache saving and we can see results earlier steps.append( { "save_cache": { "key": f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-pip-" + '{{ checksum "setup.py" }}', "paths": ["~/.cache/pip"], } } ) steps.append( { "save_cache": { "key": f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-site-packages-" + '{{ checksum "setup.py" }}', "paths": ["~/.pyenv/versions/"], } } )
job["steps"] = steps return job
@property def job_name(self): return self.name if "examples" in self.name else f"tests_{self.name}"
# JOBStorch_and_tf_job = CircleCIJob( "torch_and_tf", additional_env={"RUN_PT_TF_CROSS_TESTS": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng git-lfs cmake", "git lfs install", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]", "pip install -U --upgrade-strategy eager tensorflow_probability", "pip install -U --upgrade-strategy eager -e git+https://github.com/huggingface/accelerate@main#egg=accelerate", # TODO: remove this one after fixing the dependency issue(s) above "pip install -U --upgrade-strategy eager torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu", ], marker="is_pt_tf_cross_test", pytest_options={"rA": None, "durations": 0},)
torch_and_flax_job = CircleCIJob( "torch_and_flax", additional_env={"RUN_PT_FLAX_CROSS_TESTS": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", "pip install -U --upgrade-strategy eager --upgrade pip", "pip install -U --upgrade-strategy eager .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]", "pip install -U --upgrade-strategy eager -e git+https://github.com/huggingface/accelerate@main#egg=accelerate", ], marker="is_pt_flax_cross_test", pytest_options={"rA": None, "durations": 0},)
torch_job = CircleCIJob( "torch", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]", "pip install -U --upgrade-strategy eager -e git+https://github.com/huggingface/accelerate@main#egg=accelerate", ], parallelism=1, pytest_num_workers=12,)
tf_job = CircleCIJob( "tf", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng cmake", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]", "pip install -U --upgrade-strategy eager tensorflow_probability", ], parallelism=1,)
flax_job = CircleCIJob( "flax", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[flax,testing,sentencepiece,flax-speech,vision]", ], parallelism=1,)
pipelines_torch_job = CircleCIJob( "pipelines_torch", additional_env={"RUN_PIPELINE_TESTS": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm,video]", ], marker="is_pipeline_test", pytest_num_workers=12,)
pipelines_tf_job = CircleCIJob( "pipelines_tf", additional_env={"RUN_PIPELINE_TESTS": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install -y cmake", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,tf-cpu,testing,sentencepiece,vision]", "pip install -U --upgrade-strategy eager tensorflow_probability", ], marker="is_pipeline_test",)
custom_tokenizers_job = CircleCIJob( "custom_tokenizers", additional_env={"RUN_CUSTOM_TOKENIZERS": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install -y cmake", { "name": "install jumanpp", "command": "wget https://github.com/ku-nlp/jumanpp/releases/download/v2.0.0-rc3/jumanpp-2.0.0-rc3.tar.xz\n" "tar xvf jumanpp-2.0.0-rc3.tar.xz\n" "mkdir jumanpp-2.0.0-rc3/bld\n" "cd jumanpp-2.0.0-rc3/bld\n" "sudo cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local\n" "sudo make install\n", }, "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[ja,testing,sentencepiece,jieba,spacy,ftfy,rjieba]", "python -m unidic download", ], parallelism=None, resource_class=None, tests_to_run=[ "./tests/models/bert_japanese/test_tokenization_bert_japanese.py", "./tests/models/openai/test_tokenization_openai.py", "./tests/models/clip/test_tokenization_clip.py", ],)
examples_torch_job = CircleCIJob( "examples_torch", additional_env={"OMP_NUM_THREADS": 8}, cache_name="torch_examples", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,torch,sentencepiece,testing,torch-speech]", "pip install -U --upgrade-strategy eager -r examples/pytorch/_tests_requirements.txt", "pip install -U --upgrade-strategy eager -e git+https://github.com/huggingface/accelerate@main#egg=accelerate", ], pytest_num_workers=1,)
examples_tensorflow_job = CircleCIJob( "examples_tensorflow", cache_name="tensorflow_examples", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y cmake", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[sklearn,tensorflow,sentencepiece,testing]", "pip install -U --upgrade-strategy eager -r examples/tensorflow/_tests_requirements.txt", ],)
examples_flax_job = CircleCIJob( "examples_flax", cache_name="flax_examples", install_steps=[ "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[flax,testing,sentencepiece]", "pip install -U --upgrade-strategy eager -r examples/flax/_tests_requirements.txt", ],)
hub_job = CircleCIJob( "hub", additional_env={"HUGGINGFACE_CO_STAGING": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install git-lfs", 'git config --global user.email "ci@dummy.com"', 'git config --global user.name "ci"', "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[torch,sentencepiece,testing,vision]", ], marker="is_staging_test", pytest_num_workers=1,)
onnx_job = CircleCIJob( "onnx", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y cmake", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[torch,tf,testing,sentencepiece,onnxruntime,vision,rjieba]", ], pytest_options={"k onnx": None}, pytest_num_workers=1,)
exotic_models_job = CircleCIJob( "exotic_models", install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[torch,testing,vision]", "pip install -U --upgrade-strategy eager torchvision", "pip install -U --upgrade-strategy eager scipy", "pip install -U --upgrade-strategy eager 'git+https://github.com/facebookresearch/detectron2.git'", "sudo apt install tesseract-ocr", "pip install -U --upgrade-strategy eager pytesseract", "pip install --upgrade-strategy eager sentencepiece", "pip install -U --upgrade-strategy eager natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels", "pip install -U --upgrade-strategy eager python-Levenshtein", "pip install -U --upgrade-strategy eager opencv-python", "pip install -U --upgrade-strategy eager nltk", "pip uninstall -y torch torchvision torchaudio && pip install -U --upgrade-strategy eager 'torch<2.2.0' 'torchvision<0.17' 'torchaudio<2.2.0'" ], tests_to_run=[ "tests/models/*layoutlmv*", "tests/models/*nat", "tests/models/deta", "tests/models/udop", "tests/models/nougat", ], pytest_num_workers=1, pytest_options={"durations": 100},)
repo_utils_job = CircleCIJob( "repo_utils", install_steps=[ "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager .[quality,testing,torch]", ], parallelism=None, pytest_num_workers=1, resource_class="large", tests_to_run="tests/repo_utils",)
# We also include a `dummy.py` file in the files to be doc-tested to prevent edge case failure. Otherwise, the pytest# hangs forever during test collection while showing `collecting 0 items / 21 errors`. (To see this, we have to remove# the bash output redirection.)py_command = 'from utils.tests_fetcher import get_doctest_files; to_test = get_doctest_files() + ["dummy.py"]; to_test = " ".join(to_test); print(to_test)'py_command = f"$(python3 -c '{py_command}')"command = f'echo "{py_command}" > pr_documentation_tests_temp.txt'doc_test_job = CircleCIJob( "pr_documentation_tests", additional_env={"TRANSFORMERS_VERBOSITY": "error", "DATASETS_VERBOSITY": "error", "SKIP_CUDA_DOCTEST": "1"}, install_steps=[ "sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time ffmpeg", "pip install --upgrade --upgrade-strategy eager pip", "pip install -U --upgrade-strategy eager -e .[dev]", "pip install -U --upgrade-strategy eager -e git+https://github.com/huggingface/accelerate@main#egg=accelerate", "pip install --upgrade --upgrade-strategy eager 'pytest<8.0.0' pytest-sugar", "pip install -U --upgrade-strategy eager natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels", "pip install -U --upgrade-strategy eager g2p-en", # TODO: remove this one after fixing the dependency issue(s) above "pip install -U --upgrade-strategy eager torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu", "find -name __pycache__ -delete", "find . -name \*.pyc -delete", # Add an empty file to keep the test step running correctly even no file is selected to be tested. "touch dummy.py", { "name": "Get files to test", "command": command, }, { "name": "Show information in `Get files to test`", "command": "cat pr_documentation_tests_temp.txt" }, { "name": "Get the last line in `pr_documentation_tests.txt`", "command": "tail -n1 pr_documentation_tests_temp.txt | tee pr_documentation_tests.txt" }, ], tests_to_run="$(cat pr_documentation_tests.txt)", # noqa pytest_options={"-doctest-modules": None, "doctest-glob": "*.md", "dist": "loadfile", "rvsA": None}, command_timeout=1200, # test cannot run longer than 1200 seconds pytest_num_workers=1,)
REGULAR_TESTS = [ torch_and_tf_job, torch_and_flax_job, torch_job, tf_job, flax_job, custom_tokenizers_job, hub_job, onnx_job, exotic_models_job,]EXAMPLES_TESTS = [ examples_torch_job, examples_tensorflow_job, examples_flax_job,]PIPELINE_TESTS = [ pipelines_torch_job, pipelines_tf_job,]REPO_UTIL_TESTS = [repo_utils_job]DOC_TESTS = [doc_test_job]
def create_circleci_config(folder=None): if folder is None: folder = os.getcwd() # Used in CircleCIJob.to_dict() to expand the test list (for using parallelism) os.environ["test_preparation_dir"] = folder jobs = [] all_test_file = os.path.join(folder, "test_list.txt") if os.path.exists(all_test_file): with open(all_test_file) as f: all_test_list = f.read() else: all_test_list = [] if len(all_test_list) > 0: jobs.extend(PIPELINE_TESTS)
test_file = os.path.join(folder, "filtered_test_list.txt") if os.path.exists(test_file): with open(test_file) as f: test_list = f.read() else: test_list = [] if len(test_list) > 0: jobs.extend(REGULAR_TESTS)
extended_tests_to_run = set(test_list.split()) # Extend the test files for cross test jobs for job in jobs: if job.job_name in ["tests_torch_and_tf", "tests_torch_and_flax"]: for test_path in copy.copy(extended_tests_to_run): dir_path, fn = os.path.split(test_path) if fn.startswith("test_modeling_tf_"): fn = fn.replace("test_modeling_tf_", "test_modeling_") elif fn.startswith("test_modeling_flax_"): fn = fn.replace("test_modeling_flax_", "test_modeling_") else: if job.job_name == "test_torch_and_tf": fn = fn.replace("test_modeling_", "test_modeling_tf_") elif job.job_name == "test_torch_and_flax": fn = fn.replace("test_modeling_", "test_modeling_flax_") new_test_file = str(os.path.join(dir_path, fn)) if os.path.isfile(new_test_file): if new_test_file not in extended_tests_to_run: extended_tests_to_run.add(new_test_file) extended_tests_to_run = sorted(extended_tests_to_run) for job in jobs: if job.job_name in ["tests_torch_and_tf", "tests_torch_and_flax"]: job.tests_to_run = extended_tests_to_run fn = "filtered_test_list_cross_tests.txt" f_path = os.path.join(folder, fn) with open(f_path, "w") as fp: fp.write(" ".join(extended_tests_to_run))
example_file = os.path.join(folder, "examples_test_list.txt") if os.path.exists(example_file) and os.path.getsize(example_file) > 0: with open(example_file, "r", encoding="utf-8") as f: example_tests = f.read() for job in EXAMPLES_TESTS: framework = job.name.replace("examples_", "").replace("torch", "pytorch") if example_tests == "all": job.tests_to_run = [f"examples/{framework}"] else: job.tests_to_run = [f for f in example_tests.split(" ") if f.startswith(f"examples/{framework}")]
if len(job.tests_to_run) > 0: jobs.append(job)
doctest_file = os.path.join(folder, "doctest_list.txt") if os.path.exists(doctest_file): with open(doctest_file) as f: doctest_list = f.read() else: doctest_list = [] if len(doctest_list) > 0: jobs.extend(DOC_TESTS)
repo_util_file = os.path.join(folder, "test_repo_utils.txt") if os.path.exists(repo_util_file) and os.path.getsize(repo_util_file) > 0: jobs.extend(REPO_UTIL_TESTS)
if len(jobs) == 0: jobs = [EmptyJob()] config = {"version": "2.1"} config["parameters"] = { # Only used to accept the parameters from the trigger "nightly": {"type": "boolean", "default": False}, "tests_to_run": {"type": "string", "default": test_list}, } config["jobs"] = {j.job_name: j.to_dict() for j in jobs} config["workflows"] = {"version": 2, "run_tests": {"jobs": [j.job_name for j in jobs]}} with open(os.path.join(folder, "generated_config.yml"), "w") as f: f.write(yaml.dump(config, indent=2, width=1000000, sort_keys=False))
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--fetcher_folder", type=str, default=None, help="Only test that all tests and modules are accounted for." ) args = parser.parse_args()
create_circleci_config(args.fetcher_folder)123456789101112[run]source=transformersomit = # skip convertion scripts from testing for now */convert_* */__main__.py[report]exclude_lines = pragma: no cover raise except register_parameter1234*.py eol=lf*.rst eol=lf*.md eol=lf*.mdx eol=lf123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116name: "\U0001F41B Bug Report"description: Submit a bug report to help us improve transformersbody: - type: textarea id: system-info attributes: label: System Info description: Please share your system info with us. You can run the command `transformers-cli env` and copy-paste its output below. placeholder: transformers version, platform, python version, ... validations: required: true
- type: textarea id: who-can-help attributes: label: Who can help? description: | Your issue will be replied to more quickly if you can figure out the right person to tag with @ If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**. All issues are read by one of the core maintainers, so if you don't know who to tag, just leave this blank and a core maintainer will ping the right person. Please tag fewer than 3 people. Models:
- text models: @ArthurZucker and @younesbelkada - vision models: @amyeroberts - speech models: @sanchit-gandhi - graph models: @clefourrier Library: - flax: @sanchit-gandhi - generate: @gante - pipelines: @Narsil - tensorflow: @gante and @Rocketknight1 - tokenizers: @ArthurZucker - trainer: @muellerzr and @pacman100 Integrations: - deepspeed: HF Trainer/Accelerate: @pacman100 - ray/raytune: @richardliaw, @amogkam - Big Model Inference: @SunMarc - quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada Documentation: @stevhliu and @MKhalusova Model hub:
- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator. HF projects: - accelerate: [different repo](https://github.com/huggingface/accelerate) - datasets: [different repo](https://github.com/huggingface/datasets) - diffusers: [different repo](https://github.com/huggingface/diffusers) - rust tokenizers: [different repo](https://github.com/huggingface/tokenizers) Maintained examples (not research project or legacy): - Flax: @sanchit-gandhi - PyTorch: See Models above and tag the person corresponding to the modality of the example. - TensorFlow: @Rocketknight1
Research projects are not maintained and should be taken as is.
placeholder: "@Username ..."
- type: checkboxes id: information-scripts-examples attributes: label: Information description: 'The problem arises when using:' options: - label: "The official example scripts" - label: "My own modified scripts"
- type: checkboxes id: information-tasks attributes: label: Tasks description: "The tasks I am working on are:" options: - label: "An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)" - label: "My own task or dataset (give details below)"
- type: textarea id: reproduction validations: required: true attributes: label: Reproduction description: | Please provide a code sample that reproduces the problem you ran into. It can be a Colab link or just a code snippet. If you have code snippets, error messages, stack traces please provide them here as well. Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.
placeholder: | Steps to reproduce the behavior: 1. 2. 3.
- type: textarea id: expected-behavior validations: required: true attributes: label: Expected behavior description: "A clear and concise description of what you would expect to happen."123456789101112blank_issues_enabled: trueversion: 2.1contact_links: - name: Model checkpoints on the Hugging Face Hub url: https://huggingface.co/models about: Open a Pull request / Discussion related to a specific model checkpoint directly on the Hugging Face Hub - name: Website Related url: https://github.com/huggingface/hub-docs/issues about: Feature requests and bug reports related to the website - name: Forum url: https://discuss.huggingface.co/ about: General usage questions and community discussions12345678910111213141516171819202122232425262728293031name: "\U0001F680 Feature request"description: Submit a proposal/request for a new transformers featurelabels: [ "feature" ]body: - type: textarea id: feature-request validations: required: true attributes: label: Feature request description: | A clear and concise description of the feature proposal. Please provide a link to the paper and code in case they exist.
- type: textarea id: motivation validations: required: true attributes: label: Motivation description: | Please outline the motivation for the proposal. Is your feature request related to a problem? e.g., I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too.
- type: textarea id: contribution validations: required: true attributes: label: Your contribution description: | Is there any way that you could help, e.g. by submitting a PR? Make sure to read the CONTRIBUTING.MD [readme](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md)12345678910111213141516171819202122232425262728293031323334353637383940414243444546---name: 🌐 Translating a new language?about: Start a new translation effort in your languagetitle: '[i18n-<languageCode>] Translating docs to <languageName>'labels: WIPassignees: ''
---
<!--Note: Please search to see if an issue already exists for the language you are trying to translate.-->
Hi!
Let's bring the documentation to all the <languageName>-speaking community 🌐 (currently 0 out of 267 complete)
Who would want to translate? Please follow the 🤗 [TRANSLATING guide](https://github.com/huggingface/transformers/blob/main/docs/TRANSLATING.md). Here is a list of the files ready for translation. Let us know in this issue if you'd like to translate any, and we'll add your name to the list.
Some notes:
* Please translate using an informal tone (imagine you are talking with a friend about transformers 🤗).* Please translate in a gender-neutral way.* Add your translations to the folder called `<languageCode>` inside the [source folder](https://github.com/huggingface/transformers/tree/main/docs/source).* Register your translation in `<languageCode>/_toctree.yml`; please follow the order of the [English version](https://github.com/huggingface/transformers/blob/main/docs/source/en/_toctree.yml).* Once you're finished, open a pull request and tag this issue by including #issue-number in the description, where issue-number is the number of this issue. Please ping @stevhliu and @MKhalusova for review.* 🙋 If you'd like others to help you with the translation, you can also post in the 🤗 [forums](https://discuss.huggingface.co/).
## Get Started section
- [ ] [index.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/index.md) https://github.com/huggingface/transformers/pull/20180- [ ] [quicktour.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/quicktour.md) (waiting for initial PR to go through)- [ ] [installation.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/installation.md).
## Tutorial section- [ ] [pipeline_tutorial.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/pipeline_tutorial.md)- [ ] [autoclass_tutorial.md](https://github.com/huggingface/transformers/blob/master/docs/source/autoclass_tutorial.md)- [ ] [preprocessing.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/preprocessing.md)- [ ] [training.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/training.md)- [ ] [accelerate.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/accelerate.md)- [ ] [model_sharing.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_sharing.md)- [ ] [multilingual.md](https://github.com/huggingface/transformers/blob/main/docs/source/en/multilingual.md)
<!--Keep on adding more as you go 🔥-->123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172name: "\U0001F4DA Migration from pytorch-pretrained-bert or pytorch-transformers"description: Report a problem when migrating from pytorch-pretrained-bert or pytorch-transformers to transformerslabels: [ "migration" ]body: - type: textarea id: system-info attributes: label: System Info description: Please share your system info with us. You can run the command `transformers-cli env` and copy-paste its output below. render: shell placeholder: transformers version, platform, python version, ... validations: required: true
- type: checkboxes id: information-scripts-examples attributes: label: Information description: 'The problem arises when using:' options: - label: "The official example scripts" - label: "My own modified scripts"
- type: checkboxes id: information-tasks attributes: label: Tasks description: "The tasks I am working on are:" options: - label: "An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)" - label: "My own task or dataset (give details below)"
- type: textarea id: reproduction validations: required: true attributes: label: Reproduction description: | Please provide a code sample that reproduces the problem you ran into. It can be a Colab link or just a code snippet. If you have code snippets, error messages, stack traces please provide them here as well. Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.
placeholder: | Steps to reproduce the behavior: 1. 2. 3.
- type: textarea id: expected-behavior validations: required: true attributes: label: Expected behavior description: "A clear and concise description of what you would expect to happen." render: shell
- type: checkboxes id: checklist attributes: label: Checklist options: - label: "I have read the migration guide in the readme. ([pytorch-transformers](https://github.com/huggingface/transformers#migrating-from-pytorch-transformers-to-transformers); [pytorch-pretrained-bert](https://github.com/huggingface/transformers#migrating-from-pytorch-pretrained-bert-to-transformers))" required: true - label: "I checked if a related official extension example runs on my machine." required: true12345678910111213141516171819202122232425262728293031name: "\U0001F31F New model addition"description: Submit a proposal/request to implement a new modellabels: [ "New model" ]
body: - type: textarea id: description-request validations: required: true attributes: label: Model description description: | Put any and all important information relative to the model
- type: checkboxes id: information-tasks attributes: label: Open source status description: | Please note that if the model implementation isn't available or if the weights aren't open-source, we are less likely to implement it in `transformers`. options: - label: "The model implementation is available" - label: "The model weights are available"
- type: textarea id: additional-info attributes: label: Provide useful links for the implementation description: | Please provide information regarding the implementation, the weights, and the authors. Please mention the authors by @gh-username if you're aware of their usernames.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778# What does this PR do?
<!--Congratulations! You've made it this far! You're not quite done yet though.
Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.
Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.
Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.-->
<!-- Remove if not applicable -->
Fixes # (issue)
## Before submitting- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request), Pull Request section?- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link to it if that's the case.- [ ] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).- [ ] Did you write any new necessary tests?
## Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tagmembers/contributors who may be interested in your PR.
<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @
If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**. Please tag fewer than 3 people.
Models:
- text models: @ArthurZucker and @younesbelkada- vision models: @amyeroberts- speech models: @sanchit-gandhi- graph models: @clefourrier
Library:
- flax: @sanchit-gandhi- generate: @gante- pipelines: @Narsil- tensorflow: @gante and @Rocketknight1- tokenizers: @ArthurZucker- trainer: @muellerzr and @pacman100
Integrations:
- deepspeed: HF Trainer/Accelerate: @pacman100- ray/raytune: @richardliaw, @amogkam- Big Model Inference: @SunMarc- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada
Documentation: @stevhliu and @MKhalusova
HF projects:
- accelerate: [different repo](https://github.com/huggingface/accelerate)- datasets: [different repo](https://github.com/huggingface/datasets)- diffusers: [different repo](https://github.com/huggingface/diffusers)- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
Maintained examples (not research project or legacy):
- Flax: @sanchit-gandhi- PyTorch: See Models above and tag the person corresponding to the modality of the example.- TensorFlow: @Rocketknight1
-->1$PYTHON setup.py install # Python command to install the script.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556{% set name = "transformers" %}
package: name: "{{ name|lower }}" version: "{{ TRANSFORMERS_VERSION }}"
source: path: ../../
build: noarch: python
requirements: host: - python - pip - numpy >=1.17 - dataclasses - huggingface_hub - packaging - filelock - requests - tqdm >=4.27 - sacremoses - regex !=2019.12.17 - protobuf - tokenizers >=0.11.1,!=0.11.3,<0.13 - pyyaml >=5.1 - safetensors - fsspec run: - python - numpy >=1.17 - dataclasses - huggingface_hub - packaging - filelock - requests - tqdm >=4.27 - sacremoses - regex !=2019.12.17 - protobuf - tokenizers >=0.11.1,!=0.11.3,<0.13 - pyyaml >=5.1 - safetensors - fsspec
test: imports: - transformers
about: home: https://huggingface.co license: Apache License 2.0 license_file: LICENSE summary: "🤗Transformers: State-of-the-art Natural Language Processing for Pytorch and TensorFlow 2.0."123456789# Troubleshooting
This is a document explaining how to deal with various issues on github-actions self-hosted CI. The entries may include actual solutions or pointers to Issues that cover those.
## GitHub Actions (self-hosted CI)
* Deepspeed
- if jit build hangs, clear out `rm -rf ~/.cache/torch_extensions/` reference: https://github.com/huggingface/transformers/pull/127231234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980name: Add model like runner
on: push: branches: - none # put main here when this is fixed #pull_request: # paths: # - "src/**" # - "tests/**" # - ".github/**" # types: [opened, synchronize, reopened]
jobs: run_tests_templates_like: name: "Add new model like template tests" runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3
- name: Install dependencies run: | sudo apt -y update && sudo apt install -y libsndfile1-dev
- name: Load cached virtual environment uses: actions/cache@v2 id: cache with: path: ~/venv/ key: v4-tests_model_like-${{ hashFiles('setup.py') }}
- name: Create virtual environment on cache miss if: steps.cache.outputs.cache-hit != 'true' run: | python -m venv ~/venv && . ~/venv/bin/activate pip install --upgrade pip!=21.3 pip install -e .[dev]
- name: Check transformers location # make `transformers` available as package (required since we use `-e` flag) and check it's indeed from the repo. run: | . ~/venv/bin/activate python setup.py develop transformers_install=$(pip list -e | grep transformers) transformers_install_array=($transformers_install) transformers_loc=${transformers_install_array[-1]} transformers_repo_loc=$(pwd .) if [ "$transformers_loc" != "$transformers_repo_loc" ]; then echo "transformers is from $transformers_loc but it shoud be from $transformers_repo_loc/src." echo "A fix is required. Stop testing." exit 1 fi
- name: Create model files run: | . ~/venv/bin/activate transformers-cli add-new-model-like --config_file tests/fixtures/add_distilbert_like_config.json --path_to_repo . make style make fix-copies
- name: Run all PyTorch modeling test run: | . ~/venv/bin/activate python -m pytest -n 2 --dist=loadfile -s --make-reports=tests_new_models tests/bert_new/test_modeling_bert_new.py
- name: Run style changes run: | . ~/venv/bin/activate make style && make quality && make repo-consistency
- name: Failure short reports if: ${{ always() }} run: cat reports/tests_new_models/failures_short.txt
- name: Test suite reports artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: run_all_tests_new_models_test_reports path: reports/tests_new_models123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333name: Build docker images (scheduled)
on: push: branches: - build_ci_docker_image* repository_dispatch: workflow_call: inputs: image_postfix: required: true type: string schedule: - cron: "17 0 * * *"
concurrency: group: docker-images-builds cancel-in-progress: false
jobs: latest-docker: name: "Latest PyTorch + TensorFlow [dev]" runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-all-latest-gpu build-args: | REF=main push: true tags: huggingface/transformers-all-latest-gpu${{ inputs.image_postfix }} # Push CI images still need to be re-built daily - name: Build and push (for Push CI) in a daily basis # This condition allows `schedule` events, or `push` events that trigger this workflow NOT via `workflow_call`. # The later case is useful for manual image building for debugging purpose. Use another tag in this case! if: inputs.image_postfix != '-push-ci' uses: docker/build-push-action@v5 with: context: ./docker/transformers-all-latest-gpu build-args: | REF=main push: true tags: huggingface/transformers-all-latest-gpu-push-ci
latest-torch-deepspeed-docker: name: "Latest PyTorch + DeepSpeed" runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Cleanup disk run: | sudo ls -l /usr/local/lib/ sudo ls -l /usr/share/ sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-deepspeed-latest-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-deepspeed-latest-gpu${{ inputs.image_postfix }}
# Can't build 2 images in a single job `latest-torch-deepspeed-docker` (for `nvcr.io/nvidia`) latest-torch-deepspeed-docker-for-push-ci-daily-build: name: "Latest PyTorch + DeepSpeed (Push CI - Daily Build)" runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Cleanup disk run: | sudo ls -l /usr/local/lib/ sudo ls -l /usr/share/ sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} # Push CI images still need to be re-built daily - name: Build and push (for Push CI) in a daily basis # This condition allows `schedule` events, or `push` events that trigger this workflow NOT via `workflow_call`. # The later case is useful for manual image building for debugging purpose. Use another tag in this case! if: inputs.image_postfix != '-push-ci' uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-deepspeed-latest-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-deepspeed-latest-gpu-push-ci
doc-builder: name: "Doc builder" # Push CI doesn't need this image if: inputs.image_postfix != '-push-ci' runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-doc-builder push: true tags: huggingface/transformers-doc-builder
latest-pytorch: name: "Latest PyTorch [dev]" # Push CI doesn't need this image if: inputs.image_postfix != '-push-ci' runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Cleanup disk run: | sudo ls -l /usr/local/lib/ sudo ls -l /usr/share/ sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-gpu
latest-pytorch-amd: name: "Latest PyTorch (AMD) [dev]" runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-amd-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-amd-gpu${{ inputs.image_postfix }} # Push CI images still need to be re-built daily - name: Build and push (for Push CI) in a daily basis # This condition allows `schedule` events, or `push` events that trigger this workflow NOT via `workflow_call`. # The later case is useful for manual image building for debugging purpose. Use another tag in this case! if: inputs.image_postfix != '-push-ci' uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-amd-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-amd-gpu-push-ci
latest-tensorflow: name: "Latest TensorFlow [dev]" # Push CI doesn't need this image if: inputs.image_postfix != '-push-ci' runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-tensorflow-gpu build-args: | REF=main push: true tags: huggingface/transformers-tensorflow-gpu
latest-pytorch-deepspeed-amd: name: "PyTorch + DeepSpeed (AMD) [dev]" runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-deepspeed-amd-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-deepspeed-amd-gpu${{ inputs.image_postfix }} # Push CI images still need to be re-built daily - name: Build and push (for Push CI) in a daily basis # This condition allows `schedule` events, or `push` events that trigger this workflow NOT via `workflow_call`. # The later case is useful for manual image building for debugging purpose. Use another tag in this case! if: inputs.image_postfix != '-push-ci' uses: docker/build-push-action@v5 with: context: ./docker/transformers-pytorch-deepspeed-amd-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-deepspeed-amd-gpu-push-ci
latest-quantization-torch-docker: name: "Latest Pytorch + Quantization [dev]" # Push CI doesn't need this image if: inputs.image_postfix != '-push-ci' runs-on: [intel-cpu, 8-cpu, ci] steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: ./docker/transformers-quantization-latest-gpu build-args: | REF=main push: true tags: huggingface/transformers-quantization-latest-gpu${{ inputs.image_postfix }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485name: Build docker images (Nightly CI)
on: workflow_call: push: branches: - build_nightly_ci_docker_image*
concurrency: group: docker-images-builds cancel-in-progress: false
jobs: latest-with-torch-nightly-docker: name: "Nightly PyTorch + Stable TensorFlow" runs-on: ubuntu-22.04 steps: - name: Cleanup disk run: | sudo ls -l /usr/local/lib/ sudo ls -l /usr/share/ sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v3 with: context: ./docker/transformers-all-latest-gpu build-args: | REF=main PYTORCH=pre push: true tags: huggingface/transformers-all-latest-torch-nightly-gpu
nightly-torch-deepspeed-docker: name: "Nightly PyTorch + DeepSpeed" runs-on: ubuntu-22.04 steps: - name: Cleanup disk run: | sudo ls -l /usr/local/lib/ sudo ls -l /usr/share/ sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet sudo du -sh /usr/local/lib/ sudo du -sh /usr/share/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Check out code uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v3 with: context: ./docker/transformers-pytorch-deepspeed-nightly-gpu build-args: | REF=main push: true tags: huggingface/transformers-pytorch-deepspeed-nightly-gpu123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899name: Build docker images (Past CI)
on: push: branches: - build_past_ci_docker_image*
concurrency: group: docker-images-builds cancel-in-progress: false
jobs: past-pytorch-docker: name: "Past PyTorch Docker" strategy: fail-fast: false matrix: version: ["1.13", "1.12", "1.11"] runs-on: ubuntu-22.04 steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Check out code uses: actions/checkout@v3 - id: get-base-image name: Get Base Image env: framework_version: ${{ matrix.version }} run: | echo "base_image=$(python3 -c 'import os; from utils.past_ci_versions import past_versions_testing; base_image = past_versions_testing["pytorch"][os.environ["framework_version"]]["base_image"]; print(base_image)')" >> $GITHUB_OUTPUT - name: Print Base Image run: | echo ${{ steps.get-base-image.outputs.base_image }} - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v3 with: context: ./docker/transformers-past-gpu build-args: | REF=main BASE_DOCKER_IMAGE=${{ steps.get-base-image.outputs.base_image }} FRAMEWORK=pytorch VERSION=${{ matrix.version }} push: true tags: huggingface/transformers-pytorch-past-${{ matrix.version }}-gpu
past-tensorflow-docker: name: "Past TensorFlow Docker" strategy: fail-fast: false matrix: version: ["2.11", "2.10", "2.9", "2.8", "2.7", "2.6", "2.5"] runs-on: ubuntu-22.04 steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Check out code uses: actions/checkout@v3 - id: get-base-image name: Get Base Image env: framework_version: ${{ matrix.version }} run: | echo "base_image=$(python3 -c 'import os; from utils.past_ci_versions import past_versions_testing; base_image = past_versions_testing["tensorflow"][os.environ["framework_version"]]["base_image"]; print(base_image)')" >> $GITHUB_OUTPUT - name: Print Base Image run: | echo ${{ steps.get-base-image.outputs.base_image }} - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v3 with: context: ./docker/transformers-past-gpu build-args: | REF=main BASE_DOCKER_IMAGE=${{ steps.get-base-image.outputs.base_image }} FRAMEWORK=tensorflow VERSION=${{ matrix.version }} push: true tags: huggingface/transformers-tensorflow-past-${{ matrix.version }}-gpu12345678910111213141516171819202122name: Build documentation
on: push: branches: - main - doc-builder* - v*-release - use_templates
jobs: build: uses: huggingface/doc-builder/.github/workflows/build_main_documentation.yml@main with: commit_sha: ${{ github.sha }} package: transformers notebook_folder: transformers_doc languages: de en es fr hi it ko pt tr zh ja te custom_container: huggingface/transformers-doc-builder secrets: token: ${{ secrets.HUGGINGFACE_PUSH }} hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}123456789101112131415161718name: Build PR Documentation
on: pull_request:
concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true
jobs: build: uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main with: commit_sha: ${{ github.event.pull_request.head.sha }} pr_number: ${{ github.event.number }} package: transformers languages: de en es fr hi it ko pt tr zh ja te custom_container: huggingface/transformers-doc-builder12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182name: Check Tiny Models
on: push: branches: - check_tiny_models* repository_dispatch: schedule: - cron: "0 2 * * *"
env: TOKEN: ${{ secrets.TRANSFORMERS_HUB_BOT_HF_TOKEN }}
jobs: check_tiny_models: name: Check tiny models runs-on: ubuntu-22.04 steps: - name: Checkout transformers uses: actions/checkout@v3 with: fetch-depth: 2
- uses: actions/checkout@v3 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: # Semantic version range syntax or exact version of a Python version python-version: '3.8' # Optional - x64 or x86 architecture, defaults to x64 architecture: 'x64'
- name: Install run: | sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng cmake pip install --upgrade pip python -m pip install -U .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm,video,tf-cpu] pip install tensorflow_probability python -m pip install -U 'natten<0.15.0'
- name: Create all tiny models (locally) run: | python utils/create_dummy_models.py tiny_local_models --all --num_workers 2
- name: Local tiny model reports artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: tiny_local_model_creation_reports path: tiny_local_models/reports
# GitHub-hosted runners have 2-core CPUs - name: Run pipeline tests against all new (local) tiny models run: | OMP_NUM_THREADS=1 TRANSFORMERS_TINY_MODEL_PATH=tiny_local_models python -m pytest --max-worker-restart=0 -n 2 --dist=loadfile -s -rA --make-reports=tests_pipelines tests/models -m is_pipeline_test -k "test_pipeline_" | tee tests_output.txt
- name: Test suite reports artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: tiny_local_model_creation_reports path: reports/tests_pipelines
- name: Create + Upload tiny models for new model architecture(s) run: | python utils/update_tiny_models.py --num_workers 2
- name: Full report run: cat tiny_models/reports/tiny_model_creation_report.json
- name: Failure report run: cat tiny_models/reports/simple_failed_report.txt
- name: Summary report run: cat tiny_models/reports/tiny_model_summary.json
- name: New tiny model creation reports artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: tiny_model_creation_reports path: tiny_models/reports1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283name: Doctests
on: push: branches: - doctest* repository_dispatch: schedule: - cron: "17 2 * * *"
env: HF_HOME: /mnt/cache TRANSFORMERS_IS_CI: yes RUN_SLOW: yes OMP_NUM_THREADS: 16 MKL_NUM_THREADS: 16 SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }} TF_FORCE_GPU_ALLOW_GROWTH: true
jobs: run_doctests: runs-on: [single-gpu, nvidia-gpu, t4, ci] container: image: huggingface/transformers-all-latest-gpu options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ steps: - name: uninstall transformers (installed during docker image build) run: python3 -m pip uninstall -y transformers
- uses: actions/checkout@v3 - name: NVIDIA-SMI run: | nvidia-smi
- name: Install transformers in edit mode run: python3 -m pip install -e .[flax]
- name: GPU visibility run: | python3 utils/print_env.py
- name: Show installed libraries and their versions run: pip freeze
- name: Get doctest files run: | $(python3 -c 'from utils.tests_fetcher import get_all_doctest_files; to_test = get_all_doctest_files(); to_test = " ".join(to_test); fp = open("doc_tests.txt", "w"); fp.write(to_test); fp.close()')
- name: Run doctests run: | python3 -m pytest -v --make-reports doc_tests_gpu --doctest-modules $(cat doc_tests.txt) -sv --doctest-continue-on-failure --doctest-glob="*.md"
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat reports/doc_tests_gpu/failures_short.txt
- name: Test suite reports artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: doc_tests_gpu_test_reports path: reports/doc_tests_gpu
send_results: name: Send results to webhook runs-on: ubuntu-22.04 if: always() needs: [run_doctests] steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 - name: Send message to Slack env: CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }} CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID_DAILY_DOCS }} CI_SLACK_CHANNEL_ID_DAILY: ${{ secrets.CI_SLACK_CHANNEL_ID_DAILY_DOCS }} CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }} run: | pip install slack_sdk python utils/notification_service_doc_tests.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081name: Model templates runner
on: repository_dispatch: schedule: - cron: "0 2 * * *"
jobs: run_tests_templates: runs-on: ubuntu-22.04 steps: - name: Checkout repository uses: actions/checkout@v3
- name: Install dependencies run: | sudo apt -y update && sudo apt install -y libsndfile1-dev
- name: Load cached virtual environment uses: actions/cache@v2 id: cache with: path: ~/venv/ key: v4-tests_templates-${{ hashFiles('setup.py') }}
- name: Create virtual environment on cache miss if: steps.cache.outputs.cache-hit != 'true' run: | python -m venv ~/venv && . ~/venv/bin/activate pip install --upgrade pip!=21.3 pip install -e .[dev]
- name: Check transformers location # make `transformers` available as package (required since we use `-e` flag) and check it's indeed from the repo. run: | . ~/venv/bin/activate python setup.py develop transformer_loc=$(pip show transformers | grep "Location: " | cut -c11-) transformer_repo_loc=$(pwd .) if [ "$transformer_loc" != "$transformer_repo_loc/src" ]; then echo "transformers is from $transformer_loc but it shoud be from $transformer_repo_loc/src." echo "A fix is required. Stop testing." exit 1 fi
- name: Create model files run: | . ~/venv/bin/activate transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/encoder-bert-tokenizer.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/pt-encoder-bert-tokenizer.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/standalone.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/tf-encoder-bert-tokenizer.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/tf-seq-2-seq-bart-tokenizer.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/pt-seq-2-seq-bart-tokenizer.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/flax-encoder-bert-tokenizer.json --path=templates/adding_a_new_model transformers-cli add-new-model --testing --testing_file=templates/adding_a_new_model/tests/flax-seq-2-seq-bart-tokenizer.json --path=templates/adding_a_new_model make style python utils/check_table.py --fix_and_overwrite python utils/check_dummies.py --fix_and_overwrite python utils/check_copies.py --fix_and_overwrite
- name: Run all non-slow tests run: | . ~/venv/bin/activate python -m pytest -n 2 --dist=loadfile -s --make-reports=tests_templates tests/*template*
- name: Run style changes run: | . ~/venv/bin/activate make style && make quality && make repo-consistency
- name: Failure short reports if: ${{ always() }} run: cat reports/tests_templates/failures_short.txt
- name: Test suite reports artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: run_all_tests_templates_test_reports path: reports/tests_templates123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102name: model jobs
on: workflow_call: inputs: folder_slices: required: true type: string machine_type: required: true type: string slice_id: required: true type: number
env: HF_HOME: /mnt/cache TRANSFORMERS_IS_CI: yes OMP_NUM_THREADS: 8 MKL_NUM_THREADS: 8 RUN_SLOW: yes # For gated repositories, we still need to agree to share information on the Hub repo. page in order to get access. # This token is created under the bot `hf-transformers-bot`. HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }} TF_FORCE_GPU_ALLOW_GROWTH: true RUN_PT_TF_CROSS_TESTS: 1 CUDA_VISIBLE_DEVICES: 0,1
jobs: model_job: name: " " strategy: fail-fast: false matrix: folders: ${{ fromJson(inputs.folder_slices)[inputs.slice_id] }} runs-on: ['${{ inputs.machine_type }}', nvidia-gpu, t4, daily-ci] container: image: huggingface/transformers-all-latest-gpu options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ steps: - name: Echo input and matrix info shell: bash run: | echo "${{ inputs.folder_slices }}" echo "${{ matrix.folders }}" echo "${{ toJson(fromJson(inputs.folder_slices)[inputs.slice_id]) }}"
- name: Echo folder ${{ matrix.folders }} shell: bash # For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to # set the artifact folder names (because the character `/` is not allowed). run: | echo "${{ matrix.folders }}" matrix_folders=${{ matrix.folders }} matrix_folders=${matrix_folders/'models/'/'models_'} echo "$matrix_folders" echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
- name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ github.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: NVIDIA-SMI run: | nvidia-smi
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all tests on GPU working-directory: /transformers run: python3 -m pytest -v --make-reports=${{ inputs.machine_type }}_tests_gpu_${{ matrix.folders }} tests/${{ matrix.folders }}
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ inputs.machine_type }}_tests_gpu_${{ matrix.folders }}/failures_short.txt
- name: Run test shell: bash run: | mkdir -p /transformers/reports/${{ inputs.machine_type }}_tests_gpu_${{ matrix.folders }} echo "hello" > /transformers/reports/${{ inputs.machine_type }}_tests_gpu_${{ matrix.folders }}/hello.txt echo "${{ inputs.machine_type }}_tests_gpu_${{ matrix.folders }}"
- name: "Test suite reports artifacts: ${{ inputs.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ inputs.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports path: /transformers/reports/${{ inputs.machine_type }}_tests_gpu_${{ matrix.folders }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647name: Release - Conda
on: push: tags: - v* branches: - conda_*
env: ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
jobs: build_and_package: runs-on: ubuntu-22.04 defaults: run: shell: bash -l {0}
steps: - name: Checkout repository uses: actions/checkout@v1
- name: Install miniconda uses: conda-incubator/setup-miniconda@v2 with: auto-update-conda: true auto-activate-base: false python-version: 3.8 activate-environment: "build-transformers" channels: huggingface
- name: Setup conda env run: | conda install -c defaults anaconda-client conda-build
- name: Extract version run: echo "TRANSFORMERS_VERSION=`python setup.py --version`" >> $GITHUB_ENV
- name: Build conda packages run: | conda info conda list conda-build .github/conda
- name: Upload to Anaconda run: anaconda upload `conda-build .github/conda --output` --force123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134name: Self-hosted runner (nightly-past-ci-caller)
on: schedule: # 2:17 am on each Sunday and Thursday
- cron: "17 2 * * 0,4" push: branches: - run_nightly_ci* - run_past_ci*
jobs: build_nightly_ci_images: name: Build Nightly CI Docker Images if: (github.event_name == 'schedule') || ((github.event_name == 'push') && startsWith(github.ref_name, 'run_nightly_ci')) uses: ./.github/workflows/build-nightly-ci-docker-images.yml secrets: inherit
run_nightly_ci: name: Nightly CI needs: [build_nightly_ci_images] uses: ./.github/workflows/self-nightly-scheduled.yml secrets: inherit
run_past_ci_pytorch_1-13: name: PyTorch 1.13 if: (cancelled() != true) && ((github.event_name == 'schedule') || ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci'))) needs: [run_nightly_ci] uses: ./.github/workflows/self-past.yml with: framework: pytorch version: "1.13" sha: ${{ github.sha }} secrets: inherit
run_past_ci_pytorch_1-12: name: PyTorch 1.12 if: (cancelled() != true) && ((github.event_name == 'schedule') || ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci'))) needs: [run_past_ci_pytorch_1-13] uses: ./.github/workflows/self-past.yml with: framework: pytorch version: "1.12" sha: ${{ github.sha }} secrets: inherit
run_past_ci_pytorch_1-11: name: PyTorch 1.11 if: (cancelled() != true) && ((github.event_name == 'schedule') || ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci'))) needs: [run_past_ci_pytorch_1-12] uses: ./.github/workflows/self-past.yml with: framework: pytorch version: "1.11" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-11: name: TensorFlow 2.11 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_pytorch_1-11] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.11" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-10: name: TensorFlow 2.10 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_tensorflow_2-11] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.10" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-9: name: TensorFlow 2.9 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_tensorflow_2-10] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.9" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-8: name: TensorFlow 2.8 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_tensorflow_2-9] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.8" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-7: name: TensorFlow 2.7 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_tensorflow_2-8] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.7" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-6: name: TensorFlow 2.6 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_tensorflow_2-7] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.6" sha: ${{ github.sha }} secrets: inherit
run_past_ci_tensorflow_2-5: name: TensorFlow 2.5 if: (cancelled() != true) && ((github.event_name == 'push') && startsWith(github.ref_name, 'run_past_ci')) needs: [run_past_ci_tensorflow_2-6] uses: ./.github/workflows/self-past.yml with: framework: tensorflow version: "2.5" sha: ${{ github.sha }} secrets: inherit123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290name: Self-hosted runner (nightly-ci)
# Note that each job's dependencies go into a corresponding docker file.## For example for `run_all_tests_torch_cuda_extensions_gpu` the docker image is# `huggingface/transformers-pytorch-deepspeed-latest-gpu`, which can be found at# `docker/transformers-pytorch-deepspeed-latest-gpu/Dockerfile`
on: repository_dispatch: workflow_call:
env: HF_HOME: /mnt/cache TRANSFORMERS_IS_CI: yes OMP_NUM_THREADS: 8 MKL_NUM_THREADS: 8 RUN_SLOW: yes HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }} TF_FORCE_GPU_ALLOW_GROWTH: true RUN_PT_TF_CROSS_TESTS: 1 CUDA_VISIBLE_DEVICES: 0,1
jobs: setup: name: Setup strategy: matrix: machine_type: [single-gpu, multi-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] container: image: huggingface/transformers-all-latest-torch-nightly-gpu options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Update clone working-directory: /transformers run: | git fetch && git checkout ${{ github.sha }}
- name: Cleanup working-directory: /transformers run: | rm -rf tests/__pycache__ rm -rf tests/models/__pycache__ rm -rf reports
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- id: set-matrix name: Identify models to test working-directory: /transformers/tests run: | echo "matrix=$(python3 -c 'import os; tests = os.getcwd(); model_tests = os.listdir(os.path.join(tests, "models")); d1 = sorted(list(filter(os.path.isdir, os.listdir(tests)))); d2 = sorted(list(filter(os.path.isdir, [f"models/{x}" for x in model_tests]))); d1.remove("models"); d = d2 + d1; print(d)')" >> $GITHUB_OUTPUT
- name: NVIDIA-SMI run: | nvidia-smi
run_tests_single_gpu: name: Model tests strategy: fail-fast: false matrix: folders: ${{ fromJson(needs.setup.outputs.matrix) }} machine_type: [single-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] container: image: huggingface/transformers-all-latest-torch-nightly-gpu options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ needs: setup steps: - name: Echo folder ${{ matrix.folders }} shell: bash # For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to # set the artifact folder names (because the character `/` is not allowed). run: | echo "${{ matrix.folders }}" matrix_folders=${{ matrix.folders }} matrix_folders=${matrix_folders/'models/'/'models_'} echo "$matrix_folders" echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
- name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ github.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: NVIDIA-SMI run: | nvidia-smi
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all tests on GPU working-directory: /transformers run: python3 -m pytest -v --make-reports=${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }} tests/${{ matrix.folders }}
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/failures_short.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_nightly" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_nightly path: /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}
run_tests_multi_gpu: name: Model tests strategy: fail-fast: false matrix: folders: ${{ fromJson(needs.setup.outputs.matrix) }} machine_type: [multi-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] container: image: huggingface/transformers-all-latest-torch-nightly-gpu options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ needs: setup steps: - name: Echo folder ${{ matrix.folders }} shell: bash # For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to # set the artifact folder names (because the character `/` is not allowed). run: | echo "${{ matrix.folders }}" matrix_folders=${{ matrix.folders }} matrix_folders=${matrix_folders/'models/'/'models_'} echo "$matrix_folders" echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
- name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ github.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: NVIDIA-SMI run: | nvidia-smi
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all tests on GPU working-directory: /transformers run: python3 -m pytest -v --make-reports=${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }} tests/${{ matrix.folders }}
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/failures_short.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_nightly" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_nightly path: /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}
run_all_tests_torch_cuda_extensions_gpu: name: Torch CUDA extension tests strategy: fail-fast: false matrix: machine_type: [single-gpu, multi-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] needs: setup container: image: huggingface/transformers-pytorch-deepspeed-nightly-gpu options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ steps: - name: Update clone working-directory: /workspace/transformers run: git fetch && git checkout ${{ github.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /workspace/transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: Remove cached torch extensions run: rm -rf /github/home/.cache/torch_extensions/
# To avoid unknown test failures - name: Pre build DeepSpeed *again* working-directory: /workspace run: | python3 -m pip uninstall -y deepspeed rm -rf DeepSpeed git clone https://github.com/microsoft/DeepSpeed && cd DeepSpeed && rm -rf build DS_BUILD_CPU_ADAM=1 DS_BUILD_FUSED_ADAM=1 python3 -m pip install . --global-option="build_ext" --global-option="-j8" --no-cache -v --disable-pip-version-check
- name: NVIDIA-SMI run: | nvidia-smi
- name: Environment working-directory: /workspace/transformers run: | python utils/print_env.py
- name: Show installed libraries and their versions working-directory: /workspace/transformers run: pip freeze
- name: Run all tests on GPU working-directory: /workspace/transformers run: | python -m pytest -v --make-reports=${{ matrix.machine_type }}_tests_torch_cuda_extensions_gpu tests/deepspeed tests/extended
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /workspace/transformers/reports/${{ matrix.machine_type }}_tests_torch_cuda_extensions_gpu/failures_short.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_tests_torch_cuda_extensions_gpu_test_reports_postfix_nightly" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_tests_torch_cuda_extensions_gpu_test_reports_postfix_nightly path: /workspace/transformers/reports/${{ matrix.machine_type }}_tests_torch_cuda_extensions_gpu
send_results: name: Send results to webhook runs-on: ubuntu-22.04 if: always() needs: [ setup, run_tests_single_gpu, run_tests_multi_gpu, run_all_tests_torch_cuda_extensions_gpu ] steps: - name: Preliminary job status shell: bash # For the meaning of these environment variables, see the job `Setup` run: | echo "Setup status: ${{ needs.setup.result }}"
- uses: actions/checkout@v3 - uses: actions/download-artifact@v3 - name: Send message to Slack env: CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }} CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }} CI_SLACK_CHANNEL_ID_DAILY: ${{ secrets.CI_SLACK_CHANNEL_ID_DAILY }} CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }} CI_SLACK_REPORT_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID_PAST_FUTURE }} ACCESS_REPO_INFO_TOKEN: ${{ secrets.ACCESS_REPO_INFO_TOKEN }} CI_EVENT: Nightly CI SETUP_STATUS: ${{ needs.setup.result }} # We pass `needs.setup.outputs.matrix` as the argument. A processing in `notification_service.py` to change # `models/bert` to `models_bert` is required, as the artifact names use `_` instead of `/`. run: | pip install slack_sdk pip show slack_sdk python utils/notification_service.py "${{ needs.setup.outputs.matrix }}"
# delete-artifact - uses: geekyeggo/delete-artifact@v2 with: name: | single-* multi-*123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357name: Self-hosted runner (past-ci)
# Note that each job's dependencies go into a corresponding docker file.## For example for `run_all_tests_torch_cuda_extensions_gpu` the docker image is# `huggingface/transformers-pytorch-deepspeed-latest-gpu`, which can be found at# `docker/transformers-pytorch-deepspeed-latest-gpu/Dockerfile`
on: workflow_call: inputs: framework: required: true type: string version: required: true type: string # Use this to control the commit to test against sha: default: 'main' required: false type: string
env: HF_HOME: /mnt/cache TRANSFORMERS_IS_CI: yes OMP_NUM_THREADS: 8 MKL_NUM_THREADS: 8 RUN_SLOW: yes HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }} TF_FORCE_GPU_ALLOW_GROWTH: true RUN_PT_TF_CROSS_TESTS: 1 CUDA_VISIBLE_DEVICES: 0,1
jobs: setup: name: Setup strategy: matrix: machine_type: [single-gpu, multi-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] container: image: huggingface/transformers-${{ inputs.framework }}-past-${{ inputs.version }}-gpu options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ inputs.sha }}
- name: Cleanup working-directory: /transformers run: | rm -rf tests/__pycache__ rm -rf tests/models/__pycache__ rm -rf reports
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- id: set-matrix working-directory: /transformers name: Identify models to test run: | cd tests echo "matrix=$(python3 -c 'import os; tests = os.getcwd(); model_tests = os.listdir(os.path.join(tests, "models")); d1 = sorted(list(filter(os.path.isdir, os.listdir(tests)))); d2 = sorted(list(filter(os.path.isdir, [f"models/{x}" for x in model_tests]))); d1.remove("models"); d = d2 + d1; print(d)')" >> $GITHUB_OUTPUT
run_tests_single_gpu: name: Model tests strategy: fail-fast: false matrix: folders: ${{ fromJson(needs.setup.outputs.matrix) }} machine_type: [single-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] container: image: huggingface/transformers-${{ inputs.framework }}-past-${{ inputs.version }}-gpu options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ needs: setup steps: - name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ inputs.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: Update some packages working-directory: /transformers run: python3 -m pip install -U datasets
- name: Echo folder ${{ matrix.folders }} shell: bash # For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to # set the artifact folder names (because the character `/` is not allowed). run: | echo "${{ matrix.folders }}" matrix_folders=${{ matrix.folders }} matrix_folders=${matrix_folders/'models/'/'models_'} echo "$matrix_folders" echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
- name: NVIDIA-SMI run: | nvidia-smi
- name: Install if: inputs.framework == 'pytorch' working-directory: /transformers run: | python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all tests on GPU working-directory: /transformers run: python3 -m pytest -v --make-reports=${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }} tests/${{ matrix.folders }}
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/failures_short.txt
- name: Save job name if: ${{ always() }} shell: bash run: | matrix_folders=${matrix_folders/'models_'/'models/'} job_name="Model tests ($matrix_folders, ${{ matrix.machine_type }})" echo "$job_name" echo "$job_name" > /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/job_name.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_${{ inputs.framework }}-${{ inputs.version }}" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_${{ inputs.framework }}-${{ inputs.version }} path: /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}
run_tests_multi_gpu: name: Model tests strategy: fail-fast: false matrix: folders: ${{ fromJson(needs.setup.outputs.matrix) }} machine_type: [multi-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] container: image: huggingface/transformers-${{ inputs.framework }}-past-${{ inputs.version }}-gpu options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ needs: setup steps: - name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ inputs.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: Update some packages working-directory: /transformers run: python3 -m pip install -U datasets
- name: Echo folder ${{ matrix.folders }} shell: bash # For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to # set the artifact folder names (because the character `/` is not allowed). run: | echo "${{ matrix.folders }}" matrix_folders=${{ matrix.folders }} matrix_folders=${matrix_folders/'models/'/'models_'} echo "$matrix_folders" echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
- name: NVIDIA-SMI run: | nvidia-smi
- name: Install if: inputs.framework == 'pytorch' working-directory: /transformers run: | python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all tests on GPU working-directory: /transformers run: python3 -m pytest -v --make-reports=${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }} tests/${{ matrix.folders }}
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/failures_short.txt
- name: Save job name if: ${{ always() }} shell: bash run: | matrix_folders=${matrix_folders/'models_'/'models/'} job_name="Model tests ($matrix_folders, ${{ matrix.machine_type }})" echo "$job_name" echo "$job_name" > /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/job_name.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_${{ inputs.framework }}-${{ inputs.version }}" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports_postfix_${{ inputs.framework }}-${{ inputs.version }} path: /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}
run_all_tests_torch_cuda_extensions_gpu: name: Torch CUDA extension tests if: inputs.framework == 'pytorch' strategy: fail-fast: false matrix: machine_type: [single-gpu, multi-gpu] runs-on: ['${{ matrix.machine_type }}', nvidia-gpu, t4, past-ci] needs: setup container: image: huggingface/transformers-${{ inputs.framework }}-past-${{ inputs.version }}-gpu options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ steps: - name: Update clone working-directory: /transformers run: git fetch && git checkout ${{ github.sha }}
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: Update some packages working-directory: /transformers run: python3 -m pip install -U datasets
- name: Install working-directory: /transformers run: | python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
- name: Remove cached torch extensions run: rm -rf /github/home/.cache/torch_extensions/
# To avoid unknown test failures - name: Pre build DeepSpeed *again* working-directory: / run: | python3 -m pip uninstall -y deepspeed rm -rf DeepSpeed git clone https://github.com/microsoft/DeepSpeed && cd DeepSpeed && rm -rf build DS_BUILD_CPU_ADAM=1 DS_BUILD_FUSED_ADAM=1 python3 -m pip install . --global-option="build_ext" --global-option="-j8" --no-cache -v --disable-pip-version-check
- name: NVIDIA-SMI run: | nvidia-smi
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all tests on GPU working-directory: /transformers run: | python3 -m pytest -v --make-reports=${{ matrix.machine_type }}_tests_torch_cuda_extensions_gpu tests/deepspeed tests/extended
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ matrix.machine_type }}_tests_torch_cuda_extensions_gpu/failures_short.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_tests_torch_cuda_extensions_gpu_test_reports_postfix_${{ inputs.framework }}-${{ inputs.version }}" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_tests_torch_cuda_extensions_gpu_test_reports_postfix_${{ inputs.framework }}-${{ inputs.version }} path: /transformers/reports/${{ matrix.machine_type }}_tests_torch_cuda_extensions_gpu
send_results: name: Send results to webhook runs-on: ubuntu-22.04 if: always() needs: [ setup, run_tests_single_gpu, run_tests_multi_gpu, run_all_tests_torch_cuda_extensions_gpu ] steps: - name: Preliminary job status shell: bash # For the meaning of these environment variables, see the job `Setup` run: | echo "Setup status: ${{ needs.setup.result }}"
- uses: actions/checkout@v3 - uses: actions/download-artifact@v3
# Create a directory to store test failure tables in the next step - name: Create directory run: mkdir test_failure_tables
- name: Send message to Slack env: CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }} CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }} CI_SLACK_CHANNEL_ID_DAILY: ${{ secrets.CI_SLACK_CHANNEL_ID_DAILY }} CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }} CI_SLACK_REPORT_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID_PAST_FUTURE }} ACCESS_REPO_INFO_TOKEN: ${{ secrets.ACCESS_REPO_INFO_TOKEN }} CI_EVENT: Past CI - ${{ inputs.framework }}-${{ inputs.version }} SETUP_STATUS: ${{ needs.setup.result }} # We pass `needs.setup.outputs.matrix` as the argument. A processing in `notification_service.py` to change # `models/bert` to `models_bert` is required, as the artifact names use `_` instead of `/`. run: | pip install slack_sdk pip show slack_sdk python utils/notification_service.py "${{ needs.setup.outputs.matrix }}"
# Upload complete failure tables, as they might be big and only truncated versions could be sent to Slack. - name: Failure table artifacts if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: test_failure_tables_${{ inputs.framework }}-${{ inputs.version }} path: test_failure_tables
# delete-artifact - uses: geekyeggo/delete-artifact@v2 with: name: | single-* multi-*12345678910111213141516171819202122232425name: Self-hosted runner (AMD mi210 CI caller)
on: workflow_run: workflows: ["Self-hosted runner (push-caller)"] branches: ["main"] types: [completed] push: branches: - run_amd_push_ci_caller* paths: - "src/**" - "tests/**" - ".github/**" - "templates/**" - "utils/**"
jobs: run_amd_ci: name: AMD mi210 if: (cancelled() != true) && ((github.event_name == 'workflow_run') || ((github.event_name == 'push') && startsWith(github.ref_name, 'run_amd_push_ci_caller'))) uses: ./.github/workflows/self-push-amd.yml with: gpu_flavor: mi210 secrets: inherit12345678910111213141516171819202122232425name: Self-hosted runner (AMD mi250 CI caller)
on: workflow_run: workflows: ["Self-hosted runner (push-caller)"] branches: ["main"] types: [completed] push: branches: - run_amd_push_ci_caller* paths: - "src/**" - "tests/**" - ".github/**" - "templates/**" - "utils/**"
jobs: run_amd_ci: name: AMD mi250 if: (cancelled() != true) && ((github.event_name == 'workflow_run') || ((github.event_name == 'push') && startsWith(github.ref_name, 'run_amd_push_ci_caller'))) uses: ./.github/workflows/self-push-amd.yml with: gpu_flavor: mi250 secrets: inherit123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329name: Self-hosted runner AMD GPU (push)
on: workflow_call: inputs: gpu_flavor: required: true type: string
env: HF_HOME: /mnt/cache TRANSFORMERS_IS_CI: yes OMP_NUM_THREADS: 8 MKL_NUM_THREADS: 8 PYTEST_TIMEOUT: 60 TF_FORCE_GPU_ALLOW_GROWTH: true RUN_PT_TF_CROSS_TESTS: 1 HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
jobs: check_runner_status: name: Check Runner Status runs-on: ubuntu-22.04 steps: - name: Checkout transformers uses: actions/checkout@v3 with: fetch-depth: 2
- name: Check Runner Status run: python utils/check_self_hosted_runner.py --target_runners amd-mi210-single-gpu-ci-runner-docker --token ${{ secrets.ACCESS_REPO_INFO_TOKEN }}
check_runners: name: Check Runners needs: check_runner_status strategy: matrix: machine_type: [single-gpu, multi-gpu] runs-on: [self-hosted, docker-gpu, amd-gpu, '${{ matrix.machine_type }}', '${{ inputs.gpu_flavor }}'] container: image: huggingface/transformers-pytorch-amd-gpu-push-ci # <--- We test only for PyTorch for now options: --device /dev/kfd --device /dev/dri --env ROCR_VISIBLE_DEVICES --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ steps: - name: ROCM-SMI run: | rocm-smi - name: ROCM-INFO run: | rocminfo | grep "Agent" -A 14 - name: Show ROCR environment run: | echo "ROCR: $ROCR_VISIBLE_DEVICES"
setup_gpu: name: Setup needs: check_runners strategy: matrix: machine_type: [single-gpu, multi-gpu] runs-on: [self-hosted, docker-gpu, amd-gpu, '${{ matrix.machine_type }}', '${{ inputs.gpu_flavor }}'] container: image: huggingface/transformers-pytorch-amd-gpu-push-ci # <--- We test only for PyTorch for now options: --device /dev/kfd --device /dev/dri --env ROCR_VISIBLE_DEVICES --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} test_map: ${{ steps.set-matrix.outputs.test_map }} steps: # Necessary to get the correct branch name and commit SHA for `workflow_run` event # We also take into account the `push` event (we might want to test some changes in a branch) - name: Prepare custom environment variables shell: bash # `CI_BRANCH_PUSH`: The branch name from the push event # `CI_BRANCH_WORKFLOW_RUN`: The name of the branch on which this workflow is triggered by `workflow_run` event # `CI_BRANCH`: The non-empty branch name from the above two (one and only one of them is empty) # `CI_SHA_PUSH`: The commit SHA from the push event # `CI_SHA_WORKFLOW_RUN`: The commit SHA that triggers this workflow by `workflow_run` event # `CI_SHA`: The non-empty commit SHA from the above two (one and only one of them is empty) run: | CI_BRANCH_PUSH=${{ github.event.ref }} CI_BRANCH_PUSH=${CI_BRANCH_PUSH/'refs/heads/'/''} CI_BRANCH_WORKFLOW_RUN=${{ github.event.workflow_run.head_branch }} CI_SHA_PUSH=${{ github.event.head_commit.id }} CI_SHA_WORKFLOW_RUN=${{ github.event.workflow_run.head_sha }} echo $CI_BRANCH_PUSH echo $CI_BRANCH_WORKFLOW_RUN echo $CI_SHA_PUSH echo $CI_SHA_WORKFLOW_RUN [[ ! -z "$CI_BRANCH_PUSH" ]] && echo "CI_BRANCH=$CI_BRANCH_PUSH" >> $GITHUB_ENV || echo "CI_BRANCH=$CI_BRANCH_WORKFLOW_RUN" >> $GITHUB_ENV [[ ! -z "$CI_SHA_PUSH" ]] && echo "CI_SHA=$CI_SHA_PUSH" >> $GITHUB_ENV || echo "CI_SHA=$CI_SHA_WORKFLOW_RUN" >> $GITHUB_ENV
- name: print environment variables run: | echo "env.CI_BRANCH = ${{ env.CI_BRANCH }}" echo "env.CI_SHA = ${{ env.CI_SHA }}"
- name: Update clone using environment variables working-directory: /transformers run: | echo "original branch = $(git branch --show-current)" git fetch && git checkout ${{ env.CI_BRANCH }} echo "updated branch = $(git branch --show-current)" git checkout ${{ env.CI_SHA }} echo "log = $(git log -n 1)"
- name: Cleanup working-directory: /transformers run: | rm -rf tests/__pycache__ rm -rf tests/models/__pycache__ rm -rf reports
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Fetch the tests to run working-directory: /transformers # TODO: add `git-python` in the docker images run: | pip install --upgrade git-python python3 utils/tests_fetcher.py --diff_with_last_commit | tee test_preparation.txt
- name: Report fetched tests uses: actions/upload-artifact@v3 with: name: test_fetched path: /transformers/test_preparation.txt
- id: set-matrix name: Organize tests into models working-directory: /transformers # The `keys` is used as GitHub actions matrix for jobs, i.e. `models/bert`, `tokenization`, `pipeline`, etc. # The `test_map` is used to get the actual identified test files under each key. # If no test to run (so no `test_map.json` file), create a dummy map (empty matrix will fail) run: | if [ -f test_map.json ]; then keys=$(python3 -c 'import json; fp = open("test_map.json"); test_map = json.load(fp); fp.close(); d = list(test_map.keys()); print(d)') test_map=$(python3 -c 'import json; fp = open("test_map.json"); test_map = json.load(fp); fp.close(); print(test_map)') else keys=$(python3 -c 'keys = ["dummy"]; print(keys)') test_map=$(python3 -c 'test_map = {"dummy": []}; print(test_map)') fi echo $keys echo $test_map echo "matrix=$keys" >> $GITHUB_OUTPUT echo "test_map=$test_map" >> $GITHUB_OUTPUT
run_tests_amdgpu: name: Model tests needs: setup_gpu # `dummy` means there is no test to run if: contains(fromJson(needs.setup_gpu.outputs.matrix), 'dummy') != true strategy: fail-fast: false matrix: folders: ${{ fromJson(needs.setup_gpu.outputs.matrix) }} machine_type: [single-gpu, multi-gpu] runs-on: [self-hosted, docker-gpu, amd-gpu, '${{ matrix.machine_type }}', '${{ inputs.gpu_flavor }}'] container: image: huggingface/transformers-pytorch-amd-gpu-push-ci # <--- We test only for PyTorch for now options: --device /dev/kfd --device /dev/dri --env ROCR_VISIBLE_DEVICES --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ steps: # Necessary to get the correct branch name and commit SHA for `workflow_run` event # We also take into account the `push` event (we might want to test some changes in a branch) - name: Prepare custom environment variables shell: bash # For the meaning of these environment variables, see the job `Setup` run: | CI_BRANCH_PUSH=${{ github.event.ref }} CI_BRANCH_PUSH=${CI_BRANCH_PUSH/'refs/heads/'/''} CI_BRANCH_WORKFLOW_RUN=${{ github.event.workflow_run.head_branch }} CI_SHA_PUSH=${{ github.event.head_commit.id }} CI_SHA_WORKFLOW_RUN=${{ github.event.workflow_run.head_sha }} echo $CI_BRANCH_PUSH echo $CI_BRANCH_WORKFLOW_RUN echo $CI_SHA_PUSH echo $CI_SHA_WORKFLOW_RUN [[ ! -z "$CI_BRANCH_PUSH" ]] && echo "CI_BRANCH=$CI_BRANCH_PUSH" >> $GITHUB_ENV || echo "CI_BRANCH=$CI_BRANCH_WORKFLOW_RUN" >> $GITHUB_ENV [[ ! -z "$CI_SHA_PUSH" ]] && echo "CI_SHA=$CI_SHA_PUSH" >> $GITHUB_ENV || echo "CI_SHA=$CI_SHA_WORKFLOW_RUN" >> $GITHUB_ENV
- name: print environment variables run: | echo "env.CI_BRANCH = ${{ env.CI_BRANCH }}" echo "env.CI_SHA = ${{ env.CI_SHA }}"
- name: Update clone using environment variables working-directory: /transformers run: | echo "original branch = $(git branch --show-current)" git fetch && git checkout ${{ env.CI_BRANCH }} echo "updated branch = $(git branch --show-current)" git checkout ${{ env.CI_SHA }} echo "log = $(git log -n 1)"
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) working-directory: /transformers run: python3 -m pip uninstall -y transformers && python3 -m pip install -e .
- name: Echo folder ${{ matrix.folders }} shell: bash # For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to # set the artifact folder names (because the character `/` is not allowed). run: | echo "${{ matrix.folders }}" echo "${{ fromJson(needs.setup_gpu.outputs.test_map)[matrix.folders] }}" matrix_folders=${{ matrix.folders }} matrix_folders=${matrix_folders/'models/'/'models_'} echo "$matrix_folders" echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
- name: ROCM-SMI run: | rocm-smi - name: ROCM-INFO run: | rocminfo | grep "Agent" -A 14 - name: Show ROCR environment run: | echo "ROCR: $ROCR_VISIBLE_DEVICES"
- name: Environment working-directory: /transformers run: | python3 utils/print_env.py
- name: Show installed libraries and their versions working-directory: /transformers run: pip freeze
- name: Run all non-slow selected tests on GPU working-directory: /transformers run: | python3 -m pytest -n 2 --dist=loadfile -v --make-reports=${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }} ${{ fromJson(needs.setup_gpu.outputs.test_map)[matrix.folders] }}
- name: Failure short reports if: ${{ failure() }} continue-on-error: true run: cat /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}/failures_short.txt
- name: "Test suite reports artifacts: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports" if: ${{ always() }} uses: actions/upload-artifact@v3 with: name: ${{ matrix.machine_type }}_run_all_tests_gpu_${{ env.matrix_folders }}_test_reports path: /transformers/reports/${{ matrix.machine_type }}_tests_gpu_${{ matrix.folders }}
send_results: name: Send results to webhook runs-on: ubuntu-22.04 if: always() needs: [ check_runner_status, check_runners, setup_gpu, run_tests_amdgpu,# run_tests_torch_cuda_extensions_single_gpu,# run_tests_torch_cuda_extensions_multi_gpu ] steps: - name: Preliminary job status shell: bash # For the meaning of these environment variables, see the job `Setup` run: | echo "Runner availability: ${{ needs.check_runner_status.result }}" echo "Setup status: ${{ needs.setup_gpu.result }}" echo "Runner status: ${{ needs.check_runners.result }}"
# Necessary to get the correct branch name and commit SHA for `workflow_run` event # We also take into account the `push` event (we might want to test some changes in a branch) - name: Prepare custom environment variables shell: bash # For the meaning of these environment variables, see the job `Setup` run: | CI_BRANCH_PUSH=${{ github.event.ref }} CI_BRANCH_PUSH=${CI_BRANCH_PUSH/'refs/heads/'/''} CI_BRANCH_WORKFLOW_RUN=${{ github.event.workflow_run.head_branch }} CI_SHA_PUSH=${{ github.event.head_commit.id }} CI_SHA_WORKFLOW_RUN=${{ github.event.workflow_run.head_sha }} echo $CI_BRANCH_PUSH echo $CI_BRANCH_WORKFLOW_RUN echo $CI_SHA_PUSH echo $CI_SHA_WORKFLOW_RUN [[ ! -z "$CI_BRANCH_PUSH" ]] && echo "CI_BRANCH=$CI_BRANCH_PUSH" >> $GITHUB_ENV || echo "CI_BRANCH=$CI_BRANCH_WORKFLOW_RUN" >> $GITHUB_ENV [[ ! -z "$CI_SHA_PUSH" ]] && echo "CI_SHA=$CI_SHA_PUSH" >> $GITHUB_ENV || echo "CI_SHA=$CI_SHA_WORKFLOW_RUN" >> $GITHUB_ENV
- name: print environment variables run: | echo "env.CI_BRANCH = ${{ env.CI_BRANCH }}" echo "env.CI_SHA = ${{ env.CI_SHA }}"
- uses: actions/checkout@v3 # To avoid failure when multiple commits are merged into `main` in a short period of time. # Checking out to an old commit beyond the fetch depth will get an error `fatal: reference is not a tree: ... # (Only required for `workflow_run` event, where we get the latest HEAD on `main` instead of the event commit) with: fetch-depth: 20
- name: Update clone using environment variables run: | echo "original branch = $(git branch --show-current)" git fetch && git checkout ${{ env.CI_BRANCH }} echo "updated branch = $(git branch --show-current)" git checkout ${{ env.CI_SHA }} echo "log = $(git log -n 1)"
- uses: actions/download-artifact@v3 - name: Send message to Slack env: CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }} CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }} CI_SLACK_CHANNEL_ID_DAILY: ${{ secrets.CI_SLACK_CHANNEL_ID_DAILY }} CI_SLACK_CHANNEL_ID_AMD: ${{ secrets.CI_SLACK_CHANNEL_ID_AMD }} CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }} CI_SLACK_REPORT_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID_AMD }} ACCESS_REPO_INFO_TOKEN: ${{ secrets.ACCESS_REPO_INFO_TOKEN }} CI_EVENT: Push CI (AMD) - ${{ inputs.gpu_flavor }} CI_TITLE_PUSH: ${{ github.event.head_commit.message }} CI_TITLE_WORKFLOW_RUN: ${{ github.event.workflow_run.head_commit.message }} CI_SHA: ${{ env.CI_SHA }} RUNNER_STATUS: ${{ needs.check_runner_status.result }} RUNNER_ENV_STATUS: ${{ needs.check_runners.result }} SETUP_STATUS: ${{ needs.setup_gpu.result }}
# We pass `needs.setup_gpu.outputs.matrix` as the argument. A processing in `notification_service.py` to change # `models/bert` to `models_bert` is required, as the artifact names use `_` instead of `/`. run: | pip install slack_sdk pip show slack_sdk python utils/notification_service.py "${{ needs.setup_gpu.outputs.matrix }}".github/workflows/main.yamlAdded+28
.gitignoreAdded+160
DT.pickleAdded+3
DockerfileAdded+12
GaussianNB.pickleAdded+3
IRIS FLOWER CLASSIFICATION using machine learning models.ipynbAdded
IRIS-FLOWER-CLASSIFICATION-using-machine-learning-models/.gitattributesAdded+35
IRIS-FLOWER-CLASSIFICATION-using-machine-learning-models/README.mdAdded+11
LICENSEAdded+201
Logistic.pickleAdded+3
README.mdAdded+110
SVM.pickleAdded+3
app.pyAdded+40
knn.pickleAdded+3
mytree.dotAdded+37
requirements.txtAdded+8
rf.pickleAdded+3
templates/home.htmlAdded+86
transformers/.circleci/TROUBLESHOOT.mdAdded+7
transformers/.circleci/config.ymlAdded+232
transformers/.circleci/create_circleci_config.pyAdded+678
transformers/.coveragercAdded+12
transformers/.gitattributesAdded+4
transformers/.github/ISSUE_TEMPLATE/bug-report.ymlAdded+116
transformers/.github/ISSUE_TEMPLATE/config.ymlAdded+12
transformers/.github/ISSUE_TEMPLATE/feature-request.ymlAdded+31
transformers/.github/ISSUE_TEMPLATE/i18n.mdAdded+46
transformers/.github/ISSUE_TEMPLATE/migration.ymlAdded+72
transformers/.github/ISSUE_TEMPLATE/new-model-addition.ymlAdded+31
transformers/.github/PULL_REQUEST_TEMPLATE.mdAdded+78
transformers/.github/conda/build.shAdded+1
transformers/.github/conda/meta.yamlAdded+56
transformers/.github/workflows/TROUBLESHOOT.mdAdded+9
transformers/.github/workflows/add-model-like.ymlAdded+80
transformers/.github/workflows/build-docker-images.ymlAdded+333
transformers/.github/workflows/build-nightly-ci-docker-images.ymlAdded+85
transformers/.github/workflows/build-past-ci-docker-images.ymlAdded+99
transformers/.github/workflows/build_documentation.ymlAdded+22
transformers/.github/workflows/build_pr_documentation.ymlAdded+18
transformers/.github/workflows/check_tiny_models.ymlAdded+82
transformers/.github/workflows/doctests.ymlAdded+83
transformers/.github/workflows/model-templates.ymlAdded+81
transformers/.github/workflows/model_jobs.ymlAdded+102
transformers/.github/workflows/release-conda.ymlAdded+47
transformers/.github/workflows/self-nightly-past-ci-caller.ymlAdded+134
transformers/.github/workflows/self-nightly-scheduled.ymlAdded+290
transformers/.github/workflows/self-past.ymlAdded+357
transformers/.github/workflows/self-push-amd-mi210-caller.ymlAdded+25
transformers/.github/workflows/self-push-amd-mi250-caller.ymlAdded+25
transformers/.github/workflows/self-push-amd.ymlAdded+329