python_code
stringlengths
0
290k
repo_name
stringclasses
30 values
file_path
stringlengths
6
125
from allennlp.common import Params from allennlp.data import Instance, Token from allennlp.data.batch import Batch from allennlp.data.fields import TextField from allennlp.data.samplers import MaxTokensBatchSampler from allennlp.data.dataset_readers.dataset_reader import AllennlpDataset from allennlp.data.dataloader im...
allennlp-master
tests/data/samplers/max_tokens_batch_sampler_test.py
allennlp-master
tests/data/samplers/__init__.py
from typing import List, Iterable, Dict, Union from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Vocabulary, Instance, Token, Batch from allennlp.data.fields import TextField from allennlp.data.token_indexers import SingleIdTokenIndexer class LazyIterable: def __init__(self, instance...
allennlp-master
tests/data/samplers/sampler_test.py
from allennlp.common import Params from allennlp.data import Instance, Token from allennlp.data.batch import Batch from allennlp.data.fields import TextField from allennlp.data.samplers import BucketBatchSampler from allennlp.data.dataset_readers.dataset_reader import AllennlpDataset from allennlp.data.dataloader impor...
allennlp-master
tests/data/samplers/bucket_batch_sampler_test.py
import numpy import pytest from allennlp.common.checks import ConfigurationError from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Token from allennlp.data.fields import TextField, IndexField from allennlp.data.token_indexers import SingleIdTokenIndexer class TestIndexField(AllenNlpTestC...
allennlp-master
tests/data/fields/index_field_test.py
import numpy import torch from allennlp.common.testing.test_case import AllenNlpTestCase from allennlp.data.fields import ArrayField, ListField class TestArrayField(AllenNlpTestCase): def test_get_padding_lengths_correctly_returns_ordered_shape(self): shape = [3, 4, 5, 6] array = numpy.zeros(shap...
allennlp-master
tests/data/fields/array_field_test.py
from typing import Dict import numpy import torch from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Token, Vocabulary, Instance from allennlp.data.fields import TextField, LabelField, ListField, IndexField, SequenceLabelField from allennlp.data.token_indexers import SingleIdTokenIndexer, ...
allennlp-master
tests/data/fields/list_field_test.py
from collections import defaultdict from typing import Dict, List import numpy import pytest from allennlp.common.checks import ConfigurationError from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Token, Vocabulary from allennlp.data.fields import TextField from allennlp.data.token_indexe...
allennlp-master
tests/data/fields/text_field_test.py
allennlp-master
tests/data/fields/__init__.py
import logging import numpy import pytest from allennlp.common.checks import ConfigurationError from allennlp.common.testing import AllenNlpTestCase from allennlp.data.fields import MultiLabelField from allennlp.data.vocabulary import Vocabulary class TestMultiLabelField(AllenNlpTestCase): def test_as_tensor_re...
allennlp-master
tests/data/fields/multilabel_field_test.py
import logging import pytest from allennlp.common.checks import ConfigurationError from allennlp.common.testing import AllenNlpTestCase from allennlp.data.fields import LabelField from allennlp.data import Vocabulary class TestLabelField(AllenNlpTestCase): def test_as_tensor_returns_integer_tensor(self): ...
allennlp-master
tests/data/fields/label_field_test.py
import pytest import numpy from allennlp.common.checks import ConfigurationError from allennlp.common.testing import AllenNlpTestCase from allennlp.data.fields import AdjacencyField, TextField from allennlp.data.token_indexers import SingleIdTokenIndexer from allennlp.data import Vocabulary, Token class TestAdjacency...
allennlp-master
tests/data/fields/adjacency_field_test.py
import numpy import pytest from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Token from allennlp.data.fields import TextField, SpanField from allennlp.data.token_indexers import SingleIdTokenIndexer class TestSpanField(AllenNlpTestCase): def setup_method(self): super().setup_...
allennlp-master
tests/data/fields/span_field_test.py
from allennlp.data.fields import Field def test_eq_with_inheritance(): class SubField(Field): __slots__ = ["a"] def __init__(self, a): self.a = a class SubSubField(SubField): __slots__ = ["b"] def __init__(self, a, b): super().__init__(a) ...
allennlp-master
tests/data/fields/field_test.py
from collections import defaultdict import logging import pytest import numpy from allennlp.common.checks import ConfigurationError from allennlp.common.testing import AllenNlpTestCase from allennlp.data import Token, Vocabulary from allennlp.data.fields import TextField, SequenceLabelField from allennlp.data.token_i...
allennlp-master
tests/data/fields/sequence_label_field_test.py
import pytest from allennlp.common.testing.test_case import AllenNlpTestCase from allennlp.data.fields import MetadataField class TestMetadataField(AllenNlpTestCase): def test_mapping_works_with_dict(self): field = MetadataField({"a": 1, "b": [0]}) assert "a" in field assert field["a"] =...
allennlp-master
tests/data/fields/metadata_field_test.py
import pytest from allennlp.common.testing.test_case import AllenNlpTestCase from allennlp.data.fields import FlagField class TestFlagField(AllenNlpTestCase): def test_get_padding_lengths_returns_nothing(self): flag_field = FlagField(True) assert flag_field.get_padding_lengths() == {} def te...
allennlp-master
tests/data/fields/flag_field_test.py
allennlp-master
benchmarks/__init__.py
import torch from allennlp.nn import util from allennlp.common.testing import requires_gpu @requires_gpu def bench_add_sentence_boundary_token_ids(benchmark): device = torch.device("cuda") # shape: (32, 50) tensor = torch.tensor([[3] * 50] * 32, device=device) # shape: (32, 50) mask = torch.tenso...
allennlp-master
benchmarks/nn/util_bench.py
allennlp-master
benchmarks/data/__init__.py
allennlp-master
benchmarks/data/tokenizers/__init__.py
from allennlp.data.tokenizers import CharacterTokenizer tokenizer = CharacterTokenizer() passage = ( "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis " "nostrud exercitation ullamco laboris nisi ut...
allennlp-master
benchmarks/data/tokenizers/character_tokenizer_bench.py
# encoding: utf-8 """ Prepares markdown release notes for GitHub releases. """ import os from typing import List from allennlp.version import VERSION TAG = os.environ["TAG"] ADDED_HEADER = "### Added 🎉" CHANGED_HEADER = "### Changed ⚠️" FIXED_HEADER = "### Fixed ✅" REMOVED_HEADER = "### Removed 👋" def get_cha...
allennlp-master
scripts/release_notes.py
#!/usr/bin/env python """ This script is used to populate the table of contents for the API in the mkdocs config file. """ import argparse from pathlib import Path from typing import Any, List from ruamel.yaml import YAML from allennlp.version import VERSION API_TOC_KEY = "API" def parse_args(): parser = ar...
allennlp-master
scripts/build_docs_config.py
#!/usr/bin/env python import glob import logging import os import re import shutil import sys import tempfile sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir)))) from allennlp.commands.test_install import _get_module_root from allennlp.commands.train import train_model_from_file, t...
allennlp-master
scripts/train_fixtures.py
#!/usr/bin/env python # encoding: UTF-8 """ Goes through all the inline-links in markdown files and reports the breakages. """ import re import sys import pathlib import os from multiprocessing.dummy import Pool from typing import Tuple, NamedTuple, Optional import requests OK_STATUS_CODES = ( 200, 401, #...
allennlp-master
scripts/check_links.py
from datetime import datetime as dt import os from github import Github def main(): g = Github(os.environ["GITHUB_TOKEN"]) repo = g.get_repo("allenai/allennlp") open_issues = repo.get_issues(state="open") for issue in open_issues: if ( issue.milestone is None and issu...
allennlp-master
scripts/ping_issue_assignees.py
#!/usr/bin/env python import argparse from typing import Dict import requests def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("version_type", choices=["stable", "latest", "current"]) return parser.parse_args() def get_current_version() -> str: VERSION: Dict[str, str] = {} ...
allennlp-master
scripts/get_version.py
from datetime import datetime as dt import os from github import Github LABELS_TO_EXEMPT = ["contributions welcome", "merge when ready", "under development", "help wanted"] def main(): g = Github(os.environ["GITHUB_TOKEN"]) repo = g.get_repo("allenai/allennlp") open_issues = repo.get_issues(state="open...
allennlp-master
scripts/close_stale_issues.py
#!/usr/bin/env python """ Turn docstrings from a single module into a markdown file. We do this with PydocMarkdown, using custom processors and renderers defined here. """ import argparse from collections import OrderedDict from dataclasses import dataclass from enum import Enum import logging from multiprocessing i...
allennlp-master
scripts/py2md.py
from typing import Optional import pytest from allennlp.common.testing import AllenNlpTestCase from scripts.py2md import py2md, Param, DocstringError class TestPy2md(AllenNlpTestCase): def test_basic_example(self, capsys): py2md("scripts.tests.py2md.basic_example") captured = capsys.readouterr()...
allennlp-master
scripts/tests/py2md/py2md_test.py
""" This is a docstring. And this is a multi-line line: [http://example.com] (https://example.com/blah/blah/blah.html). """ from dataclasses import dataclass SOME_GLOBAL_VAR = "Ahhhh I'm a global var!!" """ This is a global var. """ def func_with_no_args(): """ This function has no args. """ return...
allennlp-master
scripts/tests/py2md/basic_example.py
import pytest import sqlite3 from unittest.mock import call, Mock from allennlp.common.testing import AllenNlpTestCase from scripts.ai2_internal.resume_daemon import ( BeakerStatus, create_table, handler, logger, resume, start_autoresume, ) # Don't spam the log in tests. logger.removeHandler(...
allennlp-master
scripts/tests/ai2_internal/resume_daemon_test.py
#! /usr/bin/env python3 # Tool to automatically resume preemptible beaker experiments created with run_with_beaker.py. # # Examples # -------- # # Ensure an experiment will be resumed: # resume_daemon.py --action=start --experiment-id=$YOUR_EXPERIMENT_ID # # Stop resuming an experiment: # resume_daemon.py --action=sto...
allennlp-master
scripts/ai2_internal/resume_daemon.py
#! /usr/bin/env python # Script to launch AllenNLP Beaker jobs. import argparse import os import json import random import tempfile import subprocess import sys # This has to happen before we import spacy (even indirectly), because for some crazy reason spacy # thought it was a good idea to set the random seed on im...
allennlp-master
scripts/ai2_internal/run_with_beaker.py
import argparse import json from dotenv import load_dotenv import plotly import shutil import smtplib import ssl import sys import textwrap from data_measurements import dataset_statistics from data_measurements.zipf import zipf from huggingface_hub import create_repo, Repository, hf_api from os import getenv from os.p...
data-measurements-tool-main
run_data_measurements.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
app.py
data-measurements-tool-main
lengths/__init__.py
import evaluate from evaluate.utils import launch_gradio_widget module = evaluate.load("npmi", module_type= "measurement") launch_gradio_widget(module)
data-measurements-tool-main
npmi/app.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
npmi/npmi.py
import logging import os from pathlib import Path def prepare_logging(fid): # Create the directory for log files (if it doesn't exist) Path('./log_files').mkdir(exist_ok=True) log_fid = Path(fid).stem logs = logging.getLogger(log_fid) logs.setLevel(logging.DEBUG) logs.propagate = False lo...
data-measurements-tool-main
utils/__init__.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
utils/dataset_utils.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
utils/gradio_utils.py
data-measurements-tool-main
data_measurements/__init__.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
data_measurements/dataset_statistics.py
import pandas as pd import utils from sklearn.feature_extraction.text import CountVectorizer logs = utils.prepare_logging(__file__) TEXT = "text" TOKENIZED_TEXT = "tokenized_text" class Tokenize: def __init__(self, text_dset, feature=TEXT, tok_feature=TOKENIZED_TEXT, lowercase=True): s...
data-measurements-tool-main
data_measurements/tokenize.py
data-measurements-tool-main
data_measurements/lengths/__init__.py
import logging import matplotlib.image as mpimg import matplotlib.pyplot as plt from matplotlib.figure import Figure from PIL import Image import seaborn as sns import statistics from os.path import join as pjoin import pandas as pd import utils from utils import dataset_utils as ds_utils from collections import Coun...
data-measurements-tool-main
data_measurements/lengths/lengths.py
data-measurements-tool-main
data_measurements/text_duplicates/__init__.py
import evaluate import logging import os import pandas as pd import plotly.express as px import utils import utils.dataset_utils as ds_utils from collections import Counter from os.path import exists, isdir from os.path import join as pjoin TEXT = "text" # These are string constants defined in the evaluate library. # ...
data-measurements-tool-main
data_measurements/text_duplicates/text_duplicates.py
data-measurements-tool-main
data_measurements/embeddings/__init__.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
data_measurements/embeddings/embeddings.py
data-measurements-tool-main
data_measurements/npmi/__init__.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
data_measurements/npmi/npmi.py
import evaluate import logging import os import pandas as pd import plotly.express as px import utils import utils.dataset_utils as ds_utils from collections import Counter from os.path import exists, isdir from os.path import join as pjoin LABEL_FIELD = "labels" LABEL_NAMES = "label_names" LABEL_LIST = "label_list" L...
data-measurements-tool-main
data_measurements/labels/labels.py
data-measurements-tool-main
data_measurements/labels/__init__.py
import logging import pandas as pd from datasets import load_metric from os.path import exists from os.path import join as pjoin import utils from utils import dataset_utils as ds_utils logs = utils.prepare_logging(__file__) TOK_MODEL = "gpt2" PERPLEXITY = load_metric("perplexity") PERPLEXITY_FIELD = "perplexity" c...
data-measurements-tool-main
data_measurements/perplexity/perplexity.py
data-measurements-tool-main
data_measurements/perplexity/__init__.py
data-measurements-tool-main
data_measurements/zipf/__init__.py
# Copyright 2021 The HuggingFace 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/LICENSE-2.0 # # Unless required by applicabl...
data-measurements-tool-main
data_measurements/zipf/zipf.py
import gradio as gr from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls import utils import utils.dataset_utils as ds_utils logs = utils.prepare_logging(__file__) class Duplicates(Widget): def __init__(self): duplicates_text = f"...
data-measurements-tool-main
widgets/duplicates.py
import gradio as gr import pandas as pd from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls import utils logs = utils.prepare_logging(__file__) class GeneralStats(Widget): def __init__(self): self.general_stats = gr.Markdown(rend...
data-measurements-tool-main
widgets/general_stats.py
import gradio as gr from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls import utils logs = utils.prepare_logging(__file__) class TextLengths(Widget): def __init__(self): self.text_length_distribution_plot = gr.Image(render=False...
data-measurements-tool-main
widgets/text_lengths.py
from widgets.widget_base import Widget from widgets.dataset_description import DatasetDescription from widgets.general_stats import GeneralStats from widgets.label_distribution import LabelDistribution from widgets.npmi import Npmi from widgets.text_lengths import TextLengths from widgets.zipf import Zipf from widgets....
data-measurements-tool-main
widgets/__init__.py
from abc import ABC, abstractmethod import gradio as gr from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls class Widget(ABC): @abstractmethod def render(self): pass @abstractmethod def update(self, dstats: dmt_cls): pass @property @abstr...
data-measurements-tool-main
widgets/widget_base.py
import gradio as gr import pandas as pd from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls from utils.dataset_utils import HF_DESC_FIELD import utils logs = utils.prepare_logging(__file__) class DatasetDescription(Widget): def __init__(...
data-measurements-tool-main
widgets/dataset_description.py
import gradio as gr import pandas as pd from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls import utils logs = utils.prepare_logging(__file__) class Npmi(Widget): def __init__(self): self.npmi_first_word = gr.Dropdown( ...
data-measurements-tool-main
widgets/npmi.py
import gradio as gr import pandas as pd from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls import utils logs = utils.prepare_logging(__file__) class Zipf(Widget): def __init__(self): self.zipf_table = gr.DataFrame(render=False) ...
data-measurements-tool-main
widgets/zipf.py
import gradio as gr from widgets.widget_base import Widget from data_measurements.dataset_statistics import DatasetStatisticsCacheClass as dmt_cls import utils logs = utils.prepare_logging(__file__) class LabelDistribution(Widget): def __init__(self): self.label_dist_plot = gr.Plot(render=False, visible...
data-measurements-tool-main
widgets/label_distribution.py
import argparse import os import re import nbformat import shutil import yaml from pathlib import Path re_framework_test = re.compile(r"^{#if\s+fw\s+===\s+'([^']+)'}\s*$") re_framework_else = re.compile(r"^{:else}\s*$") re_framework_end = re.compile(r"^{/if}\s*$") re_html_line = re.compile(r"^<[^>]*/>\s*$") re_html_...
course-main
utils/generate_notebooks.py
import re import argparse from pathlib import Path PATTERN_TIMESTAMP = re.compile( "^[0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9]" ) PATTERN_NUM = re.compile("\\d+") def convert(input_file, output_file): """ Convert bilingual caption file to monoli...
course-main
utils/convert_bilingual_monolingual.py
import argparse import black import os import re from pathlib import Path def blackify(filename, check_only=False): # Read the content of the file with open(filename, "r", encoding="utf-8") as f: content = f.read() lines = content.split("\n") # Split the content into code samples in py or pyt...
course-main
utils/code_formatter.py
import pandas as pd from youtube_transcript_api import YouTubeTranscriptApi from youtube_transcript_api.formatters import SRTFormatter from youtubesearchpython import Playlist from pathlib import Path import argparse COURSE_VIDEOS_PLAYLIST = "https://youtube.com/playlist?list=PLo2EIpI_JMQvWfQndUesu0nPBAtZ9gP1o" TASK_V...
course-main
utils/generate_subtitles.py
import argparse import os import yaml from pathlib import Path PATH_TO_COURSE = Path("chapters/") def load_sections(language: str): toc = yaml.safe_load(open(os.path.join(PATH_TO_COURSE / language, "_toctree.yml"), "r")) sections = [] for chapter in toc: for section in chapter["sections"]: ...
course-main
utils/validate_translation.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors, the AllenNLP library authors. # All rights reserved. """ Script to close stale issue. Taken in part from the AllenNLP repository. https://github.com/allenai/allennlp. Copied from https://github.com/huggingface/transformers """ from datetim...
datasets-server-main
tools/stale.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. from typing import Optional import pytest from mongoengine import Document from mongoengine.fields import StringField from pymongo.errors import ServerSelectionTimeoutError from libcommon.resources import ( CacheMongoResource, Me...
datasets-server-main
libs/libcommon/tests/test_resources.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import pytest from libcommon.utils import inputs_to_string, is_image_url @pytest.mark.parametrize( "dataset,revision,config,split,prefix,expected", [ ("dataset", None, None, None, None, "dataset"), ("dataset", "r...
datasets-server-main
libs/libcommon/tests/test_utils.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. from collections.abc import Iterator from pathlib import Path from environs import Env from pytest import fixture from libcommon.queue import _clean_queue_database from libcommon.resources import CacheMongoResource, QueueMongoResource fro...
datasets-server-main
libs/libcommon/tests/conftest.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. from collections.abc import Mapping from datetime import datetime from http import HTTPStatus from time import process_time from typing import Any, Optional, TypedDict import pytest from pymongo.errors import DocumentTooLarge from libcom...
datasets-server-main
libs/libcommon/tests/test_simple_cache.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import pytest from libcommon.config import ProcessingGraphConfig from libcommon.processing_graph import ( ProcessingGraph, ProcessingGraphSpecification, ProcessingStep, ) def assert_lists_are_equal(a: list[ProcessingStep], b...
datasets-server-main
libs/libcommon/tests/test_processing_graph.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors.
datasets-server-main
libs/libcommon/tests/__init__.py
import os import time from dataclasses import dataclass from http import HTTPStatus from pathlib import Path from typing import Optional import pytest from libcommon.prometheus import ( ASSETS_DISK_USAGE, QUEUE_JOBS_TOTAL, RESPONSES_IN_CACHE_TOTAL, Prometheus, StepProfiler, update_assets_disk_...
datasets-server-main
libs/libcommon/tests/test_prometheus.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2023 The HuggingFace Authors. from http import HTTPStatus from typing import Optional import pytest from libcommon.queue import Queue from libcommon.resources import CacheMongoResource, QueueMongoResource from libcommon.simple_cache import ( delete_response, ...
datasets-server-main
libs/libcommon/tests/test_state.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2023 The HuggingFace Authors. from http import HTTPStatus import pytest from libcommon.orchestrator import AfterJobPlan, DatasetOrchestrator from libcommon.processing_graph import Artifact, ProcessingGraph from libcommon.queue import JobDocument, Queue from libcommon...
datasets-server-main
libs/libcommon/tests/test_orchestrator.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. from pathlib import Path from typing import Optional import pytest from libcommon.constants import ASSETS_CACHE_APPNAME from libcommon.storage import StrPath, init_assets_dir, init_dir, remove_dir @pytest.mark.parametrize( "has_dir...
datasets-server-main
libs/libcommon/tests/test_storage.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import json import os import random import time from datetime import datetime, timedelta from multiprocessing import Pool from pathlib import Path from typing import Optional from unittest.mock import patch import pytest import pytz from...
datasets-server-main
libs/libcommon/tests/test_queue.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2023 The HuggingFace Authors. from datetime import datetime from http import HTTPStatus from typing import Any, Optional from libcommon.orchestrator import DatasetBackfillPlan from libcommon.processing_graph import Artifact, ProcessingGraph from libcommon.queue import...
datasets-server-main
libs/libcommon/tests/utils.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import pytest from libcommon.dataset import get_dataset_git_revision from libcommon.exceptions import DatasetInfoHubRequestError @pytest.mark.real_dataset def test_get_dataset_git_revision() -> None: dataset = "glue" hf_endpoint...
datasets-server-main
libs/libcommon/tests/test_dataset.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. from libcommon.config import LogConfig def test_log_config() -> None: log_config = LogConfig() assert log_config.level == 20
datasets-server-main
libs/libcommon/tests/test_config.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2023 The HuggingFace Authors. from datetime import datetime from typing import Optional import pytest from libcommon.processing_graph import ProcessingGraph from libcommon.queue import Queue from libcommon.resources import CacheMongoResource, QueueMongoResource from ...
datasets-server-main
libs/libcommon/tests/test_backfill.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2023 The HuggingFace Authors. from http import HTTPStatus import pytest from libcommon.config import ProcessingGraphConfig from libcommon.constants import PROCESSING_STEP_DATASET_CONFIG_NAMES_VERSION from libcommon.processing_graph import ProcessingGraph from libcomm...
datasets-server-main
libs/libcommon/tests/test_backfill_on_real_graph.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import datetime from collections.abc import Mapping from pathlib import Path from typing import Any, Optional import numpy as np import pandas as pd import pytest from datasets import ( Array2D, Array3D, Array4D, Array5D, ...
datasets-server-main
libs/libcommon/tests/fixtures/datasets.py
datasets-server-main
libs/libcommon/tests/fixtures/__init__.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import datetime from collections.abc import Mapping from typing import Any from zoneinfo import ZoneInfo import numpy as np import pytest from datasets import Audio, Dataset, Features, Image, Value from libcommon.storage import StrPath f...
datasets-server-main
libs/libcommon/tests/viewer_utils/test_features.py
datasets-server-main
libs/libcommon/tests/viewer_utils/__init__.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import contextlib import json import logging import time import types from collections import Counter from collections.abc import Sequence from datetime import datetime, timedelta from itertools import groupby from operator import itemgett...
datasets-server-main
libs/libcommon/src/libcommon/queue.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import logging from dataclasses import dataclass, field from typing import Optional from environs import Env from libcommon.constants import ( PROCESSING_STEP_CONFIG_INFO_VERSION, PROCESSING_STEP_CONFIG_IS_VALID_VERSION, PRO...
datasets-server-main
libs/libcommon/src/libcommon/config.py
import asyncio import logging import os from dataclasses import dataclass, field from functools import lru_cache from typing import Literal, Optional, TypedDict, Union import numpy as np import pyarrow as pa import pyarrow.parquet as pq from datasets import Features from datasets.features.features import FeatureType f...
datasets-server-main
libs/libcommon/src/libcommon/parquet_utils.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. import logging def init_logging(level: int = logging.INFO) -> None: logging.basicConfig(level=level, format="%(levelname)s: %(asctime)s - %(name)s - %(message)s") logging.debug(f"Log level set to: {logging.getLevelName(logging.ge...
datasets-server-main
libs/libcommon/src/libcommon/log.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2022 The HuggingFace Authors. ASSETS_CACHE_APPNAME = "datasets_server_assets" CACHE_COLLECTION_RESPONSES = "cachedResponsesBlue" CACHE_MONGOENGINE_ALIAS = "cache" CACHED_ASSETS_CACHE_APPNAME = "datasets_server_cached_assets" HF_DATASETS_CACHE_APPNAME = "hf_datasets_cac...
datasets-server-main
libs/libcommon/src/libcommon/constants.py