Make pytorch examples UV-compatible (#39635)
* update release.py * add uv headers in some pytorch examples * rest of pytorch examples * style
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
datasets>=1.14.0
|
datasets[audio]>=1.14.0
|
||||||
evaluate
|
evaluate
|
||||||
librosa
|
librosa
|
||||||
torchaudio
|
torchaudio
|
||||||
torch>=1.6
|
torch>=1.6
|
||||||
|
|||||||
@@ -13,6 +13,17 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets[audio]>=1.14.0",
|
||||||
|
# "evaluate",
|
||||||
|
# "librosa",
|
||||||
|
# "torchaudio",
|
||||||
|
# "torch>=1.6",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -12,6 +12,16 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "torch>=1.5.0",
|
||||||
|
# "torchvision>=0.6.0",
|
||||||
|
# "datasets>=1.8.0",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Training a CLIP like dual encoder models using text and vision encoders in the library.
|
Training a CLIP like dual encoder models using text and vision encoders in the library.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate>=0.12.0",
|
||||||
|
# "torch>=1.5.0",
|
||||||
|
# "torchvision>=0.6.0",
|
||||||
|
# "datasets>=2.14.0",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -11,6 +11,19 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate>=0.12.0",
|
||||||
|
# "torch>=1.5.0",
|
||||||
|
# "torchvision>=0.6.0",
|
||||||
|
# "datasets>=2.14.0",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning any 🤗 Transformers model for image classification leveraging 🤗 Accelerate."""
|
"""Finetuning any 🤗 Transformers model for image classification leveraging 🤗 Accelerate."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -12,6 +12,15 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "torch>=1.5.0",
|
||||||
|
# "torchvision>=0.6.0",
|
||||||
|
# "datasets>=1.8.0",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -12,6 +12,15 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "torch>=1.5.0",
|
||||||
|
# "torchvision>=0.6.0",
|
||||||
|
# "datasets>=1.8.0",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -12,6 +12,15 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "torch>=1.5.0",
|
||||||
|
# "torchvision>=0.6.0",
|
||||||
|
# "datasets>=1.8.0",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "timm",
|
||||||
|
# "datasets",
|
||||||
|
# "torchmetrics",
|
||||||
|
# "pycocotools",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning 🤗 Transformers model for instance segmentation leveraging the Trainer API."""
|
"""Finetuning 🤗 Transformers model for instance segmentation leveraging the Trainer API."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "timm",
|
||||||
|
# "datasets",
|
||||||
|
# "torchmetrics",
|
||||||
|
# "pycocotools",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning 🤗 Transformers model for instance segmentation with Accelerate 🚀."""
|
"""Finetuning 🤗 Transformers model for instance segmentation with Accelerate 🚀."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...) on a text file or a dataset.
|
Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...) on a text file or a dataset.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...)
|
Fine-tuning the library models for causal language modeling (GPT, GPT-2, CTRL, ...)
|
||||||
on a text file or a dataset without using HuggingFace Trainer.
|
on a text file or a dataset without using HuggingFace Trainer.
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for causal language modeling using
|
Fine-tuning the library models for causal language modeling using
|
||||||
Fill-in-the middle (FIM) objective on a text file or a dataset.
|
Fill-in-the middle (FIM) objective on a text file or a dataset.
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for causal language modeling using
|
Fine-tuning the library models for causal language modeling using
|
||||||
Fill-in-the middle (FIM) objective on a text file or a dataset without using HuggingFace Trainer.
|
Fill-in-the middle (FIM) objective on a text file or a dataset without using HuggingFace Trainer.
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for masked language modeling (BERT, ALBERT, RoBERTa...) on a text file or a dataset.
|
Fine-tuning the library models for masked language modeling (BERT, ALBERT, RoBERTa...) on a text file or a dataset.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for masked language modeling (BERT, ALBERT, RoBERTa...)
|
Fine-tuning the library models for masked language modeling (BERT, ALBERT, RoBERTa...)
|
||||||
on a text file or a dataset without using HuggingFace Trainer.
|
on a text file or a dataset without using HuggingFace Trainer.
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "datasets >= 2.14.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "evaluate",
|
||||||
|
# "scikit-learn",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for permutation language modeling.
|
Fine-tuning the library models for permutation language modeling.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for multiple choice.
|
Fine-tuning the library models for multiple choice.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning a 🤗 Transformers model on multiple choice relying on the accelerate library without using a Trainer.
|
Fine-tuning a 🤗 Transformers model on multiple choice relying on the accelerate library without using a Trainer.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "timm",
|
||||||
|
# "datasets>=4.0",
|
||||||
|
# "torchmetrics",
|
||||||
|
# "pycocotools",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning any 🤗 Transformers model supported by AutoModelForObjectDetection for object detection leveraging the Trainer API."""
|
"""Finetuning any 🤗 Transformers model supported by AutoModelForObjectDetection for object detection leveraging the Trainer API."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@@ -11,6 +11,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# "timm",
|
||||||
|
# "datasets>=4.0",
|
||||||
|
# "torchmetrics",
|
||||||
|
# "pycocotools",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning 🤗 Transformers model for object detection with Accelerate."""
|
"""Finetuning 🤗 Transformers model for object detection with Accelerate."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets >= 2.0.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "accelerate",
|
||||||
|
# "evaluate""
|
||||||
|
# "Pillow",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -11,6 +11,19 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets >= 2.0.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "accelerate",
|
||||||
|
# "evaluate""
|
||||||
|
# "Pillow",
|
||||||
|
# "albumentations >= 1.4.16",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning any 🤗 Transformers model supported by AutoModelForSemanticSegmentation for semantic segmentation."""
|
"""Finetuning any 🤗 Transformers model supported by AutoModelForSemanticSegmentation for semantic segmentation."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
datasets >= 1.12.0
|
datasets[audio] >= 1.12.0
|
||||||
torch >= 1.5
|
torch >= 1.5
|
||||||
torchaudio
|
torchaudio
|
||||||
accelerate >= 0.12.0
|
accelerate >= 0.12.0
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets[audio] >= 1.12.0",
|
||||||
|
# "torch >= 1.5",
|
||||||
|
# "torchaudio",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "librosa",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Pre-Training a 🤗 Wav2Vec2 model on unlabeled audio data"""
|
"""Pre-Training a 🤗 Wav2Vec2 model on unlabeled audio data"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
datasets >= 1.18.0
|
datasets[audio] >= 1.18.0
|
||||||
torch >= 1.5
|
torch >= 1.5
|
||||||
torchaudio
|
torchaudio
|
||||||
librosa
|
librosa
|
||||||
|
|||||||
@@ -13,6 +13,18 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets[audio] >= 1.18.0",
|
||||||
|
# "torch >= 1.5",
|
||||||
|
# "torchaudio",
|
||||||
|
# "librosa",
|
||||||
|
# "jiwer",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Fine-tuning a 🤗 Transformers CTC model for automatic speech recognition"""
|
"""Fine-tuning a 🤗 Transformers CTC model for automatic speech recognition"""
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|||||||
@@ -13,6 +13,18 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets[audio] >= 1.18.0",
|
||||||
|
# "torch >= 1.5",
|
||||||
|
# "torchaudio",
|
||||||
|
# "librosa",
|
||||||
|
# "jiwer",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""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 functools
|
||||||
|
|||||||
@@ -12,6 +12,19 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "datasets[audio] >= 1.18.0",
|
||||||
|
# "torch >= 1.5",
|
||||||
|
# "torchaudio",
|
||||||
|
# "librosa",
|
||||||
|
# "jiwer",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for sequence to sequence speech recognition.
|
Fine-tuning the library models for sequence to sequence speech recognition.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,22 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "rouge-score",
|
||||||
|
# "nltk",
|
||||||
|
# "py7zr",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for sequence to sequence.
|
Fine-tuning the library models for sequence to sequence.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,22 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "rouge-score",
|
||||||
|
# "nltk",
|
||||||
|
# "py7zr",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning a 🤗 Transformers model on summarization.
|
Fine-tuning a 🤗 Transformers model on summarization.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "scipy",
|
||||||
|
# "scikit-learn",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""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.
|
# You can also adapt this script on your own text classification task. Pointers for this are left as comments.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "scipy",
|
||||||
|
# "scikit-learn",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""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.
|
# You can also adapt this script on your own text classification task. Pointers for this are left as comments.
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "scipy",
|
||||||
|
# "scikit-learn",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning a 🤗 Transformers model for sequence classification on GLUE."""
|
"""Finetuning a 🤗 Transformers model for sequence classification on GLUE."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
@@ -13,6 +13,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "scipy",
|
||||||
|
# "scikit-learn",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""Finetuning multi-lingual models on XNLI (e.g. Bert, DistilBERT, XLM).
|
"""Finetuning multi-lingual models on XNLI (e.g. Bert, DistilBERT, XLM).
|
||||||
Adapted from `examples/text-classification/run_glue.py`"""
|
Adapted from `examples/text-classification/run_glue.py`"""
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,17 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.21.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""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 argparse
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.21.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""The examples of running contrastive search on the auto-APIs;
|
"""The examples of running contrastive search on the auto-APIs;
|
||||||
|
|
||||||
Running this example:
|
Running this example:
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "seqeval",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for token classification.
|
Fine-tuning the library models for token classification.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "seqeval",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning a 🤗 Transformers model on token classification tasks (NER, POS, CHUNKS) relying on the accelerate library
|
Fine-tuning a 🤗 Transformers model on token classification tasks (NER, POS, CHUNKS) relying on the accelerate library
|
||||||
without using a Trainer.
|
without using a Trainer.
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "sacrebleu >= 1.4.12",
|
||||||
|
# "py7zr",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning the library models for sequence to sequence.
|
Fine-tuning the library models for sequence to sequence.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -12,6 +12,21 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "transformers @ git+https://github.com/huggingface/transformers.git",
|
||||||
|
# "accelerate >= 0.12.0",
|
||||||
|
# "datasets >= 1.8.0",
|
||||||
|
# "sentencepiece != 0.1.92",
|
||||||
|
# "protobuf",
|
||||||
|
# "sacrebleu >= 1.4.12",
|
||||||
|
# "py7zr",
|
||||||
|
# "torch >= 1.3",
|
||||||
|
# "evaluate",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Fine-tuning a 🤗 Transformers model on text translation.
|
Fine-tuning a 🤗 Transformers model on text translation.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ REPLACE_PATTERNS = {
|
|||||||
"examples": (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'),
|
"examples": (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'),
|
||||||
"init": (re.compile(r'^__version__\s+=\s+"([^"]+)"\s*$', re.MULTILINE), '__version__ = "VERSION"\n'),
|
"init": (re.compile(r'^__version__\s+=\s+"([^"]+)"\s*$', re.MULTILINE), '__version__ = "VERSION"\n'),
|
||||||
"setup": (re.compile(r'^(\s*)version\s*=\s*"[^"]+",', re.MULTILINE), r'\1version="VERSION",'),
|
"setup": (re.compile(r'^(\s*)version\s*=\s*"[^"]+",', re.MULTILINE), r'\1version="VERSION",'),
|
||||||
|
"uv_script_release": (
|
||||||
|
re.compile(r'^# "transformers(\[.+\])?.*$', re.MULTILINE),
|
||||||
|
r'# "transformers\g<1>==VERSION",',
|
||||||
|
),
|
||||||
|
"uv_script_dev": (
|
||||||
|
re.compile(r'^# "transformers(\[.+\])?.*$', re.MULTILINE),
|
||||||
|
r'# "transformers\g<1> @ git+https://github.com/huggingface/transformers.git",',
|
||||||
|
),
|
||||||
}
|
}
|
||||||
# This maps a type of file to its path in Transformers
|
# This maps a type of file to its path in Transformers
|
||||||
REPLACE_FILES = {
|
REPLACE_FILES = {
|
||||||
@@ -66,6 +74,7 @@ REPLACE_FILES = {
|
|||||||
"setup": "setup.py",
|
"setup": "setup.py",
|
||||||
}
|
}
|
||||||
README_FILE = "README.md"
|
README_FILE = "README.md"
|
||||||
|
UV_SCRIPT_MARKER = "# /// script"
|
||||||
|
|
||||||
|
|
||||||
def update_version_in_file(fname: str, version: str, file_type: str):
|
def update_version_in_file(fname: str, version: str, file_type: str):
|
||||||
@@ -86,12 +95,13 @@ def update_version_in_file(fname: str, version: str, file_type: str):
|
|||||||
f.write(code)
|
f.write(code)
|
||||||
|
|
||||||
|
|
||||||
def update_version_in_examples(version: str):
|
def update_version_in_examples(version: str, patch: bool = False):
|
||||||
"""
|
"""
|
||||||
Update the version in all examples files.
|
Update the version in all examples files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
version (`str`): The new version to set in the examples.
|
version (`str`): The new version to set in the examples.
|
||||||
|
patch (`bool`, *optional*, defaults to `False`): Whether or not this is a patch release.
|
||||||
"""
|
"""
|
||||||
for folder, directories, fnames in os.walk(PATH_TO_EXAMPLES):
|
for folder, directories, fnames in os.walk(PATH_TO_EXAMPLES):
|
||||||
# Removing some of the folders with non-actively maintained examples from the walk
|
# Removing some of the folders with non-actively maintained examples from the walk
|
||||||
@@ -99,7 +109,13 @@ def update_version_in_examples(version: str):
|
|||||||
directories.remove("legacy")
|
directories.remove("legacy")
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
if fname.endswith(".py"):
|
if fname.endswith(".py"):
|
||||||
update_version_in_file(os.path.join(folder, fname), version, file_type="examples")
|
if UV_SCRIPT_MARKER in Path(folder, fname).read_text():
|
||||||
|
# Update the depdendencies in UV scripts
|
||||||
|
uv_script_file_type = "uv_script_dev" if ".dev" in version else "uv_script_release"
|
||||||
|
update_version_in_file(os.path.join(folder, fname), version, file_type=uv_script_file_type)
|
||||||
|
if not patch:
|
||||||
|
# We don't update the version in the examples for patch releases.
|
||||||
|
update_version_in_file(os.path.join(folder, fname), version, file_type="examples")
|
||||||
|
|
||||||
|
|
||||||
def global_version_update(version: str, patch: bool = False):
|
def global_version_update(version: str, patch: bool = False):
|
||||||
@@ -112,9 +128,7 @@ def global_version_update(version: str, patch: bool = False):
|
|||||||
"""
|
"""
|
||||||
for pattern, fname in REPLACE_FILES.items():
|
for pattern, fname in REPLACE_FILES.items():
|
||||||
update_version_in_file(fname, version, pattern)
|
update_version_in_file(fname, version, pattern)
|
||||||
if not patch:
|
update_version_in_examples(version, patch=patch)
|
||||||
# We don't update the version in the examples for patch releases.
|
|
||||||
update_version_in_examples(version)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_conversion_scripts():
|
def remove_conversion_scripts():
|
||||||
|
|||||||
Reference in New Issue
Block a user