python_code
stringlengths
0
290k
repo_name
stringclasses
30 values
file_path
stringlengths
6
125
autotrain-advanced-main
src/autotrain/infer/__init__.py
from dataclasses import dataclass from typing import Optional import torch from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig @dataclass class TextGenerationInference: model_path: str = "gpt2" use_int4: Optional[bool] = False use_int8: Optional[bool] = False temperature: O...
autotrain-advanced-main
src/autotrain/infer/text_generation.py
autotrain-advanced-main
src/autotrain/apps/image_classification.py
from functools import partial import gradio as gr import pandas as pd from autotrain.apps import common from autotrain.apps import utils as app_utils from autotrain.dataset import AutoTrainDataset from autotrain.project import AutoTrainProject ALLOWED_MODELS = [ "xgboost", "random_forest", "ridge", ...
autotrain-advanced-main
src/autotrain/apps/tabular.py
autotrain-advanced-main
src/autotrain/apps/__init__.py
from functools import partial import gradio as gr import pandas as pd from autotrain.apps import common from autotrain.apps import utils as app_utils from autotrain.dataset import AutoTrainDataset from autotrain.project import AutoTrainProject def start_training( jobs_df, model_choice, training_data, ...
autotrain-advanced-main
src/autotrain/apps/llm.py
from functools import partial import gradio as gr import pandas as pd from autotrain.apps import common from autotrain.apps import utils as app_utils from autotrain.dataset import AutoTrainDataset from autotrain.languages import SUPPORTED_LANGUAGES from autotrain.project import AutoTrainProject def start_training( ...
autotrain-advanced-main
src/autotrain/apps/text_classification.py
import os import gradio as gr from autotrain import allowed_file_types from autotrain.apps.utils import BACKEND_CHOICES, _login_user from autotrain.utils import get_user_token def user_validation(): user_token = os.environ.get("HF_TOKEN", "") if len(user_token) == 0: user_token = get_user_token() ...
autotrain-advanced-main
src/autotrain/apps/common.py
import copy import random import string import gradio as gr import numpy as np import pandas as pd from huggingface_hub import list_models from autotrain import logger from autotrain.utils import user_authentication THEME = "freddyaboulton/dracula_revamped" BACKEND_CHOICES = { "A10G Large": 3.15, "A10G Sma...
autotrain-advanced-main
src/autotrain/apps/utils.py
from functools import partial import gradio as gr import pandas as pd from autotrain.apps import common from autotrain.apps import utils as app_utils from autotrain.dataset import AutoTrainDreamboothDataset from autotrain.project import AutoTrainProject ALLOWED_FILE_TYPES = ["png", "jpg", "jpeg"] MODELS = [ "s...
autotrain-advanced-main
src/autotrain/apps/dreambooth.py
import gradio as gr from autotrain.apps import utils as app_utils from autotrain.apps.dreambooth import main as dreambooth from autotrain.apps.llm import main as llm from autotrain.apps.tabular import main as tabular from autotrain.apps.text_classification import main as text_classification llm = llm() text_classifi...
autotrain-advanced-main
src/autotrain/apps/main.py
import os import shutil import uuid from dataclasses import dataclass from typing import Optional import pandas as pd from datasets import load_dataset from sklearn.model_selection import train_test_split from autotrain import logger ALLOWED_EXTENSIONS = ("jpeg", "png", "jpg", "JPG", "JPEG", "PNG") @dataclass cla...
autotrain-advanced-main
src/autotrain/preprocessor/vision.py
from dataclasses import dataclass from typing import List, Optional import pandas as pd from datasets import Dataset from sklearn.model_selection import train_test_split RESERVED_COLUMNS = ["autotrain_id", "autotrain_label"] @dataclass class TabularBinaryClassificationPreprocessor: train_data: pd.DataFrame ...
autotrain-advanced-main
src/autotrain/preprocessor/tabular.py
autotrain-advanced-main
src/autotrain/preprocessor/__init__.py
from dataclasses import dataclass from typing import Optional import pandas as pd from datasets import ClassLabel, Dataset from sklearn.model_selection import train_test_split RESERVED_COLUMNS = ["autotrain_text", "autotrain_label"] LLM_RESERVED_COLUMNS = ["autotrain_prompt", "autotrain_context", "autotrain_response...
autotrain-advanced-main
src/autotrain/preprocessor/text.py
import io import json from dataclasses import dataclass from typing import Any, List from huggingface_hub import HfApi, create_repo from autotrain import logger @dataclass class DreamboothPreprocessor: concept_images: List[Any] concept_name: str username: str project_name: str token: str de...
autotrain-advanced-main
src/autotrain/preprocessor/dreambooth.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # 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/LI...
blog-main
assets/62_pytorch_fsdp/run_clm_no_trainer.py
import torch import torch.nn as nn from bitsandbytes.nn import Linear8bitLt # Utility function def get_model_memory_footprint(model): r""" Partially copied and inspired from: https://discuss.pytorch.org/t/gpu-memory-that-model-uses/56822/2 """ return sum([param.nelement() * param.element_size() f...
blog-main
assets/96_hf_bitsandbytes_integration/example.py
import functools import time from multiprocessing import pool import ray from ray_tpu import get_connection, start_ray from bloom_inference.tpu_manager import TPUManager tpu_name="bloom-tpu-v4-64" region="us-central2-b" ckpt = "bigscience/bloom" t5x_path = "gs://bloom-jax-us-central2-b/bloom-176B-scan-t5x/checkpoi...
bloom-jax-inference-main
run.py
import numpy as np import jax import jax.numpy as jnp from flax.core.frozen_dict import freeze from jax.experimental import PartitionSpec as P from t5x.partitioning import PjitPartitioner from t5x.train_state import InferenceState from bloom_inference.modeling_bloom import FlaxBloomForCausalLM, BloomConfig from trans...
bloom-jax-inference-main
sharding_example.py
from setuptools import setup, find_packages setup( name='bloom_inference', version='0.0.0', packages=find_packages() )
bloom-jax-inference-main
setup.py
import argparse import time import numpy as np import jax import jax.numpy as jnp from jax.experimental import PartitionSpec as P from t5x.partitioning import PjitPartitioner from t5x.train_state import InferenceState from t5x.checkpoints import Checkpointer from bloom_inference.modeling_bloom import FlaxBloomForCau...
bloom-jax-inference-main
run_speed.py
import functools import os import subprocess import time import glob import requests from fabric import Connection @functools.lru_cache() def get_bearer(): return subprocess.check_output("gcloud auth print-access-token", shell=True).decode("utf-8").strip() @functools.lru_cache() def get_project(): return s...
bloom-jax-inference-main
ray_tpu.py
import numpy as np import jax import jax.numpy as jnp from jax.experimental import PartitionSpec as P from flax.core.frozen_dict import freeze from t5x.partitioning import PjitPartitioner from t5x.train_state import InferenceState from t5x.checkpoints import Checkpointer from bloom_inference.modeling_bloom import Fla...
bloom-jax-inference-main
checkpointer_example.py
import os import ray import time from queue import Queue @ray.remote(resources={"tpu": 1}) # @ray.remote class TPUHostWorker(object): def __init__( self, ckpt="bigscience/bloom", t5x_path="gs://bloom-jax-us-central2-b/bloom-176B-scan-t5x/checkpoint_0", max_len=256, max_inpu...
bloom-jax-inference-main
bloom_inference/host_worker.py
bloom-jax-inference-main
bloom_inference/__init__.py
import warnings import jax import jax.numpy as jnp from jax.experimental import PartitionSpec as P from jax.experimental.compilation_cache import compilation_cache as cc from t5x.partitioning import PjitPartitioner from t5x.train_state import InferenceState from t5x.checkpoints import Checkpointer from transformers ...
bloom-jax-inference-main
bloom_inference/generator.py
import time import ray import numpy as np class TPUManager: # @func_set_timeout(1200) def __init__( self, node_count=8, ckpt="bigscience/bloom", t5x_path="gs://bloom-jax-us-central2-b/bloom-176B-scan-t5x/checkpoint_0", max_len=256, max_input_len=64, model...
bloom-jax-inference-main
bloom_inference/tpu_manager.py
# coding=utf-8 # Copyright 2021 The Google Flax Team Authors and 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 ...
bloom-jax-inference-main
bloom_inference/modeling_bloom/modeling_flax_utils.py
# coding=utf-8 # Copyright 2021 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 ...
bloom-jax-inference-main
bloom_inference/modeling_bloom/generation_flax_logits_process.py
from .modeling_bloom import FlaxBloomForCausalLM from .configuration_bloom import BloomConfig
bloom-jax-inference-main
bloom_inference/modeling_bloom/__init__.py
# coding=utf-8 # Copyright 2022 the Big Science Workshop and HuggingFace Inc. team. All rights reserved. # # 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/license...
bloom-jax-inference-main
bloom_inference/modeling_bloom/configuration_bloom.py
# coding=utf-8 # Copyright 2021 The Google AI Flax Team Authors, and The HuggingFace Inc. team. # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # 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 o...
bloom-jax-inference-main
bloom_inference/modeling_bloom/generation_flax_utils.py
# coding=utf-8 # Copyright 2022 HuggingFace Inc. team and Bigscience Workshop. All rights reserved. # # 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/LICE...
bloom-jax-inference-main
bloom_inference/modeling_bloom/modeling_bloom.py
# Copyright 2022 The T5X Authors. # # 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 writ...
bloom-jax-inference-main
bloom_inference/modeling_bloom/layers.py
# Lint as: python3 """ HuggingFace/Datasets is an open library of datasets. Note: VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention (we need to follow this convention to be able to retrieve versioned scripts) Simple check list for release from AllenNLP repo: https://github.com/allenai/al...
datasets-main
setup.py
""" Official evaluation script for ReCoRD v1.0. (Some functions are adopted from the SQuAD evaluation script.) """ import argparse import json import re import string import sys from collections import Counter def normalize_answer(s): """Lower text and remove punctuation, articles and extra whitespace.""" ...
datasets-main
metrics/super_glue/record_evaluation.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/super_glue/super_glue.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/indic_glue/indic_glue.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/bertscore/bertscore.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/glue/glue.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/code_eval/execute.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/code_eval/code_eval.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/coval/coval.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/seqeval/seqeval.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/sari/sari.py
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/spearmanr/spearmanr.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/xnli/xnli.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/meteor/meteor.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/competition_math/competition_math.py
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/matthews_correlation/matthews_correlation.py
# coding=utf-8 # Copyright 2020 The HuggingFace Datasets Authors. # # 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 app...
datasets-main
metrics/mauve/mauve.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/cuad/cuad.py
""" Official evaluation script for CUAD dataset. """ import argparse import json import re import string import sys import numpy as np IOU_THRESH = 0.5 def get_jaccard(prediction, ground_truth): remove_tokens = [".", ",", ";", ":"] for token in remove_tokens: ground_truth = ground_truth.replace(t...
datasets-main
metrics/cuad/evaluate.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/wiki_split/wiki_split.py
# Copyright 2021 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/cer/cer.py
# Copyright 2021 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/cer/test_cer.py
# Copyright 2022 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/mean_iou/mean_iou.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/sacrebleu/sacrebleu.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/google_bleu/google_bleu.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/bleu/bleu.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/accuracy/accuracy.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/recall/recall.py
# Copyright 2022 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/xtreme_s/xtreme_s.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/comet/comet.py
# Copyright 2021 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/ter/ter.py
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/perplexity/perplexity.py
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/pearsonr/pearsonr.py
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/mae/mae.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/roc_auc/roc_auc.py
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/mse/mse.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/squad_v2/squad_v2.py
"""Official evaluation script for SQuAD version 2.0. In addition to basic functionality, we also compute additional statistics and plot precision-recall curves if an additional na_prob.json file is provided. This file is expected to map question ID's to the model's predicted probability that a question is unanswerable...
datasets-main
metrics/squad_v2/evaluate.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/squad/squad.py
""" Official evaluation script for v1.1 of the SQuAD dataset. """ import argparse import json import re import string import sys from collections import Counter def normalize_answer(s): """Lower text and remove punctuation, articles and extra whitespace.""" def remove_articles(text): return re.sub(r...
datasets-main
metrics/squad/evaluate.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/bleurt/bleurt.py
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/mahalanobis/mahalanobis.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/precision/precision.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/f1/f1.py
# Copyright 2021 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/wer/wer.py
# Copyright 2020 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/rouge/rouge.py
# Copyright 2022 The HuggingFace Datasets Authors and the current metric script contributor. # # 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...
datasets-main
metrics/frugalscore/frugalscore.py
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets-main
metrics/exact_match/exact_match.py
# Copyright 2021 The HuggingFace Datasets Authors. # # 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 ...
datasets-main
metrics/chrf/chrf.py
import json import os import re from pathlib import Path import pytest from fsspec.registry import _registry as _fsspec_registry from fsspec.spec import AbstractBufferedFile, AbstractFileSystem from datasets.download.download_config import DownloadConfig from datasets.download.streaming_download_manager import ( ...
datasets-main
tests/test_streaming_download_manager.py
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class DatasetListTest(TestCase): def _create_example_records(self): return [ {"col_1": 3, "col_2": "a"}, {"col_1": 2, "col_2": "b"}, {"col_1": 1, "col_2": "c"}...
datasets-main
tests/test_dataset_list.py
import json import os import pickle import subprocess from hashlib import md5 from pathlib import Path from tempfile import gettempdir from textwrap import dedent from types import FunctionType from unittest import TestCase from unittest.mock import patch import pytest from multiprocess import Pool import datasets fr...
datasets-main
tests/test_fingerprint.py
import pytest from datasets.utils.version import Version @pytest.mark.parametrize( "other, expected_equality", [ (Version("1.0.0"), True), ("1.0.0", True), (Version("2.0.0"), False), ("2.0.0", False), ("1", False), ("a", False), (1, False), (Non...
datasets-main
tests/test_version.py
import os import pickle import tempfile import time from multiprocessing import Pool from unittest import TestCase import pytest from datasets.features import Features, Sequence, Value from datasets.metric import Metric, MetricInfo from .utils import require_tf, require_torch class DummyMetric(Metric): def _in...
datasets-main
tests/test_metric.py
import pytest import datasets # Import fixture modules as plugins pytest_plugins = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def pytest_collection_modifyitems(config, items): # Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit") for ite...
datasets-main
tests/conftest.py
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def mock_emitted_deprecation_warnings(monkeypatch): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings", set()) # Used by list_metrics @pytest.fixture def mock_hfh(monkeypatch): cla...
datasets-main
tests/test_warnings.py
from unittest.mock import patch import datasets from datasets import Dataset def test_enable_disable_progress_bar(): dset = Dataset.from_dict({"col_1": [3, 2, 0, 1]}) with patch("tqdm.auto.tqdm") as mock_tqdm: datasets.disable_progress_bar() dset.map(lambda x: {"col_2": x["col_1"] + 1}) ...
datasets-main
tests/test_logging.py
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( "kwargs, expected", [ ({"num_shards": 0, "max_num_jobs": 1}, []), ({"num_shards": 10, "max_num_jobs": 1}, [range(10)]), ({"num_shards": 10...
datasets-main
tests/test_sharding_utils.py
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size", [None, 400 * 2**20, 600 * 2**20]) @pytest.mark.parametrize("input_in_memory_max_size", ["default", 0, 100 * 2**20, 900 * 2**20]) def test_is_small_dataset(dataset_size, input_in_memory...
datasets-main
tests/test_info_utils.py
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def test_patch_submodule(): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from os.path impor...
datasets-main
tests/test_patching.py
import contextlib import copy import itertools import json import os import pickle import re import sys import tempfile from functools import partial from pathlib import Path from unittest import TestCase from unittest.mock import MagicMock, patch import numpy as np import numpy.testing as npt import pandas as pd impo...
datasets-main
tests/test_arrow_dataset.py
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): example_yaml_structure = yaml.safe_load( """\ name: "" allow_empty: false allow_empty_text: true subsections: - name: "Dataset Card for X" # ...
datasets-main
tests/test_readme_util.py
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def test_offline_with_timeout(): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT): with pytest.raises(Reques...
datasets-main
tests/test_offline_util.py
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict", [ SplitDict(), SplitDict({"train": SplitInfo(name="train", num_bytes=1337, num_examples=42, dataset_name="my_dataset")}), SplitDict({"train...
datasets-main
tests/test_splits.py
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, temp_...
datasets-main
tests/test_py_utils.py