python3Packages.transformers: 4.1.1 -> 4.2.1

Changelog:
https://github.com/huggingface/transformers/releases/tag/v4.2.0
https://github.com/huggingface/transformers/releases/tag/v4.2.1

Changes to the derivation:

- Enable on Python 3.9.
- Disable checks and use pythonImportsCheck instead. The list of
  excluded tests was getting silly. The vast majority of tests
  require internet access (to download models). I guess at this
  point we just have to accept that it is not practical to run
  the tests.
This commit is contained in:
Daniël de Kok 2021-01-16 11:01:21 +01:00
parent bcdca92787
commit 483ce5ce9c

View File

@ -1,32 +1,28 @@
{ buildPythonPackage { buildPythonPackage
, lib, stdenv , lib, stdenv
, fetchFromGitHub , fetchFromGitHub
, isPy39 , pythonOlder
, cookiecutter , cookiecutter
, filelock , filelock
, importlib-metadata
, regex , regex
, requests , requests
, numpy , numpy
, pandas
, parameterized
, protobuf , protobuf
, sacremoses , sacremoses
, timeout-decorator
, tokenizers , tokenizers
, tqdm , tqdm
, pytestCheckHook
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "transformers"; pname = "transformers";
version = "4.1.1"; version = "4.2.1";
disabled = isPy39;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "huggingface"; owner = "huggingface";
repo = pname; repo = pname;
rev = "v${version}"; rev = "v${version}";
sha256 = "1l1gxdsakjmzsgggypq45pnwm87brhlccjfzafs43460pz0wbd6k"; sha256 = "0yf5s878i6v298wxm4cwkb33qyxz5bdr75jmsnldpdw4ml31c3nn";
}; };
propagatedBuildInputs = [ propagatedBuildInputs = [
@ -39,63 +35,17 @@ buildPythonPackage rec {
sacremoses sacremoses
tokenizers tokenizers
tqdm tqdm
]; ] ++ stdenv.lib.optionals (pythonOlder "3.8") [ importlib-metadata ];
checkInputs = [ # Many tests require internet access.
pandas doCheck = false;
parameterized
pytestCheckHook
timeout-decorator
];
postPatch = '' postPatch = ''
substituteInPlace setup.py \ substituteInPlace setup.py \
--replace "tokenizers == 0.9.4" "tokenizers" --replace "tokenizers == 0.9.4" "tokenizers"
''; '';
preCheck = '' pythonImportsCheck = [ "transformers" ];
export HOME="$TMPDIR"
# This test requires the `datasets` module to download test
# data. However, since we cannot download in the Nix sandbox
# and `dataset` is an optional dependency for transformers
# itself, we will just remove the tests files that import
# `dataset`.
rm tests/test_retrieval_rag.py
rm tests/test_trainer.py
'';
# We have to run from the main directory for the tests. However,
# letting pytest discover tests leads to errors.
pytestFlagsArray = [ "tests" ];
# Disable tests that require network access.
disabledTests = [
"BlenderbotSmallTokenizerTest"
"Blenderbot3BTokenizerTests"
"GetFromCacheTests"
"TokenizationTest"
"TestTokenizationBart"
"test_all_tokenizers"
"test_batch_encoding_is_fast"
"test_batch_encoding_pickle"
"test_batch_encoding_word_to_tokens"
"test_config_from_model_shortcut"
"test_config_model_type_from_model_identifier"
"test_from_pretrained_use_fast_toggle"
"test_hf_api"
"test_outputs_can_be_shorter"
"test_outputs_not_longer_than_maxlen"
"test_padding_accepts_tensors"
"test_pretokenized_tokenizers"
"test_tokenizer_equivalence_en_de"
"test_tokenizer_from_model_type"
"test_tokenizer_from_model_type"
"test_tokenizer_from_pretrained"
"test_tokenizer_from_tokenizer_class"
"test_tokenizer_identifier_with_correct_config"
"test_tokenizer_identifier_non_existent"
];
meta = with lib; { meta = with lib; {
homepage = "https://github.com/huggingface/transformers"; homepage = "https://github.com/huggingface/transformers";