Skip to content

Commit

Permalink
update ruff version (huggingface#30932)
Browse files Browse the repository at this point in the history
* update ruff version

* fix research projects

* Empty

* Fix errors

---------

Co-authored-by: Lysandre <[email protected]>
  • Loading branch information
2 people authored and Vaibhavs10 committed May 22, 2024
1 parent f2fbd57 commit f0f483d
Show file tree
Hide file tree
Showing 1,172 changed files with 1,577 additions and 1,883 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export PYTHONPATH = src

check_dirs := examples tests src utils

exclude_folders := examples/research_projects
exclude_folders := ""

modified_only_fixup:
$(eval modified_py_files := $(shell python utils/get_modified_files.py $(check_dirs)))
Expand Down
1 change: 1 addition & 0 deletions examples/flax/language-modeling/run_mlm_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Here is the full list of checkpoints on the hub that can be fine-tuned by this script:
https://huggingface.co/models?filter=fill-mask
"""

import json
import logging
import math
Expand Down
1 change: 1 addition & 0 deletions examples/flax/language-modeling/run_t5_mlm_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Here is the full list of checkpoints on the hub that can be pretrained by this script:
https://huggingface.co/models?filter=t5
"""

import json
import logging
import math
Expand Down
1 change: 1 addition & 0 deletions examples/flax/question-answering/utils_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Post-processing utilities for question answering.
"""

import collections
import json
import logging
Expand Down
3 changes: 2 additions & 1 deletion examples/flax/text-classification/run_flax_glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# 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.
""" Finetuning a 🤗 Flax Transformers model for sequence classification on GLUE."""
"""Finetuning a 🤗 Flax Transformers model for sequence classification on GLUE."""

import json
import logging
import math
Expand Down
3 changes: 2 additions & 1 deletion examples/flax/token-classification/run_flax_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# 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.
""" Fine-tuning a 🤗 Flax Transformers model on token classification tasks (NER, POS, CHUNKS)"""
"""Fine-tuning a 🤗 Flax Transformers model on token classification tasks (NER, POS, CHUNKS)"""

import json
import logging
import math
Expand Down
12 changes: 6 additions & 6 deletions examples/legacy/benchmarking/plot_csv_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ def __init__(self, args):
self.result_dict[model_name]["seq_len"].append(int(row["sequence_length"]))
if can_convert_to_int(row["result"]):
# value is not None
self.result_dict[model_name]["result"][
(int(row["batch_size"]), int(row["sequence_length"]))
] = int(row["result"])
self.result_dict[model_name]["result"][(int(row["batch_size"]), int(row["sequence_length"]))] = (
int(row["result"])
)
elif can_convert_to_float(row["result"]):
# value is not None
self.result_dict[model_name]["result"][
(int(row["batch_size"]), int(row["sequence_length"]))
] = float(row["result"])
self.result_dict[model_name]["result"][(int(row["batch_size"]), int(row["sequence_length"]))] = (
float(row["result"])
)

def plot(self):
fig, ax = plt.subplots()
Expand Down
2 changes: 1 addition & 1 deletion examples/legacy/benchmarking/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# 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.
""" Benchmarking the library on inference and training """
"""Benchmarking the library on inference and training"""

from transformers import HfArgumentParser, PyTorchBenchmark, PyTorchBenchmarkArguments

Expand Down
3 changes: 1 addition & 2 deletions examples/legacy/multiple_choice/run_multiple_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
""" Finetuning the library models for multiple choice (Bert, Roberta, XLNet)."""

"""Finetuning the library models for multiple choice (Bert, Roberta, XLNet)."""

import logging
import os
Expand Down
3 changes: 1 addition & 2 deletions examples/legacy/multiple_choice/utils_multiple_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
""" Multiple choice fine-tuning: utilities to work with multiple choice tasks of reading comprehension """

"""Multiple choice fine-tuning: utilities to work with multiple choice tasks of reading comprehension"""

import csv
import glob
Expand Down
3 changes: 1 addition & 2 deletions examples/legacy/question-answering/run_squad.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
""" Finetuning the library models for question-answering on SQuAD (DistilBERT, Bert, XLM, XLNet)."""

"""Finetuning the library models for question-answering on SQuAD (DistilBERT, Bert, XLM, XLNet)."""

import argparse
import glob
Expand Down
3 changes: 1 addition & 2 deletions examples/legacy/question-answering/run_squad_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
""" Fine-tuning the library models for question-answering."""

"""Fine-tuning the library models for question-answering."""

import logging
import os
Expand Down
1 change: 0 additions & 1 deletion examples/legacy/run_language_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using a masked language modeling (MLM) loss. XLNet is fine-tuned using a permutation language modeling (PLM) loss.
"""


import logging
import math
import os
Expand Down
1 change: 1 addition & 0 deletions examples/legacy/run_openai_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
--output_dir ../log \
--train_batch_size 16 \
"""

import argparse
import csv
import logging
Expand Down
3 changes: 1 addition & 2 deletions examples/legacy/run_swag.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""BERT finetuning runner.
Finetuning the library models for multiple choice on SWAG (Bert).
Finetuning the library models for multiple choice on SWAG (Bert).
"""


import argparse
import csv
import glob
Expand Down
9 changes: 4 additions & 5 deletions examples/legacy/run_transfo_xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
# 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.
""" PyTorch Transformer XL model evaluation script.
Adapted from https://github.com/kimiyoung/transformer-xl.
In particular https://github.com/kimiyoung/transformer-xl/blob/master/pytorch/eval.py
"""PyTorch Transformer XL model evaluation script.
Adapted from https://github.com/kimiyoung/transformer-xl.
In particular https://github.com/kimiyoung/transformer-xl/blob/master/pytorch/eval.py
This script with default values evaluates a pretrained Transformer-XL on WikiText 103
This script with default values evaluates a pretrained Transformer-XL on WikiText 103
"""


import argparse
import logging
import math
Expand Down
1 change: 0 additions & 1 deletion examples/legacy/seq2seq/xla_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""


import importlib
import sys
from argparse import REMAINDER, ArgumentParser
Expand Down
3 changes: 2 additions & 1 deletion examples/legacy/token-classification/run_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# 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.
""" Fine-tuning the library models for named entity recognition on CoNLL-2003. """
"""Fine-tuning the library models for named entity recognition on CoNLL-2003."""

import logging
import os
import sys
Expand Down
3 changes: 1 addition & 2 deletions examples/legacy/token-classification/utils_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
""" Named entity recognition fine-tuning: utilities to work with CoNLL-2003 task. """

"""Named entity recognition fine-tuning: utilities to work with CoNLL-2003 task."""

import logging
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# 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.
""" Finetuning any 🤗 Transformers model for image classification leveraging 🤗 Accelerate."""
"""Finetuning any 🤗 Transformers model for image classification leveraging 🤗 Accelerate."""

import argparse
import json
import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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.
""" Finetuning 🤗 Transformers model for object detection with Accelerate."""
"""Finetuning 🤗 Transformers model for object detection with Accelerate."""

import argparse
import json
Expand Down
1 change: 1 addition & 0 deletions examples/pytorch/question-answering/trainer_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
A subclass of `Trainer` specific to Question-Answering tasks
"""

import math
import time

Expand Down
1 change: 1 addition & 0 deletions examples/pytorch/question-answering/trainer_seq2seq_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
A subclass of `Trainer` specific to Question-Answering tasks
"""

import math
import time
from typing import Dict, List, Optional
Expand Down
1 change: 1 addition & 0 deletions examples/pytorch/question-answering/utils_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Post-processing utilities for question answering.
"""

import collections
import json
import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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.
""" Finetuning any 🤗 Transformers model supported by AutoModelForSemanticSegmentation for semantic segmentation."""
"""Finetuning any 🤗 Transformers model supported by AutoModelForSemanticSegmentation for semantic segmentation."""

import argparse
import json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

""" Pre-Training a 🤗 Wav2Vec2 model on unlabeled audio data """
"""Pre-Training a 🤗 Wav2Vec2 model on unlabeled audio data"""

import argparse
import math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

""" Fine-tuning a 🤗 Transformers CTC model for automatic speech recognition"""
"""Fine-tuning a 🤗 Transformers CTC model for automatic speech recognition"""

import functools
import json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

""" Fine-tuning a 🤗 Transformers CTC adapter model for automatic speech recognition"""
"""Fine-tuning a 🤗 Transformers CTC adapter model for automatic speech recognition"""

import functools
import json
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/text-classification/run_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 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.
""" Finetuning the library models for text classification."""
"""Finetuning the library models for text classification."""
# You can also adapt this script on your own text classification task. Pointers for this are left as comments.

import logging
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/text-classification/run_glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 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.
""" Finetuning the library models for sequence classification on GLUE."""
"""Finetuning the library models for sequence classification on GLUE."""
# You can also adapt this script on your own text classification task. Pointers for this are left as comments.

import logging
Expand Down
3 changes: 2 additions & 1 deletion examples/pytorch/text-classification/run_glue_no_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# 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.
""" Finetuning a 🤗 Transformers model for sequence classification on GLUE."""
"""Finetuning a 🤗 Transformers model for sequence classification on GLUE."""

import argparse
import json
import logging
Expand Down
4 changes: 2 additions & 2 deletions examples/pytorch/text-classification/run_xnli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# 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.
""" Finetuning multi-lingual models on XNLI (e.g. Bert, DistilBERT, XLM).
Adapted from `examples/text-classification/run_glue.py`"""
"""Finetuning multi-lingual models on XNLI (e.g. Bert, DistilBERT, XLM).
Adapted from `examples/text-classification/run_glue.py`"""

import logging
import os
Expand Down
4 changes: 1 addition & 3 deletions examples/pytorch/text-generation/run_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
# 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.
""" Conditional text generation with the auto-regressive models of the library (GPT/GPT-2/CTRL/Transformer-XL/XLNet)
"""

"""Conditional text generation with the auto-regressive models of the library (GPT/GPT-2/CTRL/Transformer-XL/XLNet)"""

import argparse
import inspect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
# 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.
""" The examples of running contrastive search on the auto-APIs;
"""The examples of running contrastive search on the auto-APIs;
Running this example:
python run_generation_contrastive_search.py --model_name_or_path=openai-community/gpt2-large --penalty_alpha=0.6 --k=4 --length=256
"""


import argparse
import logging

Expand Down
1 change: 0 additions & 1 deletion examples/pytorch/xla_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""


import importlib
import sys
from argparse import REMAINDER, ArgumentParser
Expand Down
2 changes: 1 addition & 1 deletion examples/research_projects/adversarial/run_hans.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 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.
""" Finetuning the library models for sequence classification on HANS."""
"""Finetuning the library models for sequence classification on HANS."""

import logging
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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.
"""PyTorch ALBERT model with Patience-based Early Exit. """
"""PyTorch ALBERT model with Patience-based Early Exit."""

import logging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
"""PyTorch BERT model with Patience-based Early Exit. """

"""PyTorch BERT model with Patience-based Early Exit."""

import logging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# 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.
""" Training and inference using the library models for sequence classification on GLUE (Bert, Albert) with PABEE."""

"""Training and inference using the library models for sequence classification on GLUE (Bert, Albert) with PABEE."""

import argparse
import glob
Expand Down
3 changes: 2 additions & 1 deletion examples/research_projects/bertabs/configuration_bertabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# 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.
""" BertAbs configuration """
"""BertAbs configuration"""

import logging

from transformers import PretrainedConfig
Expand Down
Loading

0 comments on commit f0f483d

Please sign in to comment.