1{ buildPythonPackage
2, stdenv
3, fetchFromGitHub
4, boto3
5, filelock
6, regex
7, requests
8, numpy
9, sacremoses
10, sentencepiece
11, timeout-decorator
12, tokenizers
13, tqdm
14, pytestCheckHook
15}:
16
17buildPythonPackage rec {
18 pname = "transformers";
19 version = "3.1.0";
20
21 src = fetchFromGitHub {
22 owner = "huggingface";
23 repo = pname;
24 rev = "v${version}";
25 sha256 = "0wg36qrcljmpsyhjaxpqw3s1r6276yg8cq0bjrf52l4zlc5k4xzk";
26 };
27
28 propagatedBuildInputs = [
29 boto3
30 filelock
31 numpy
32 regex
33 requests
34 sacremoses
35 sentencepiece
36 tokenizers
37 tqdm
38 ];
39
40 checkInputs = [
41 pytestCheckHook
42 timeout-decorator
43 ];
44
45 postPatch = ''
46 substituteInPlace setup.py \
47 --replace "tokenizers == 0.8.1.rc2" "tokenizers>=0.8"
48 '';
49
50 preCheck = ''
51 export HOME="$TMPDIR"
52 cd tests
53
54 # This test requires the nlp module, which we haven't
55 # packaged yet. However, nlp is optional for transformers
56 # itself
57 rm test_trainer.py
58 '';
59
60 # Disable tests that require network access.
61 disabledTests = [
62 "PegasusTokenizationTest"
63 "T5TokenizationTest"
64 "test_all_tokenizers"
65 "test_batch_encoding_is_fast"
66 "test_batch_encoding_pickle"
67 "test_config_from_model_shortcut"
68 "test_config_model_type_from_model_identifier"
69 "test_from_pretrained_use_fast_toggle"
70 "test_hf_api"
71 "test_outputs_can_be_shorter"
72 "test_outputs_not_longer_than_maxlen"
73 "test_padding_accepts_tensors"
74 "test_pretokenized_tokenizers"
75 "test_tokenizer_equivalence_en_de"
76 "test_tokenizer_from_model_type"
77 "test_tokenizer_from_model_type"
78 "test_tokenizer_from_pretrained"
79 "test_tokenizer_identifier_with_correct_config"
80 ];
81
82 meta = with stdenv.lib; {
83 homepage = "https://github.com/huggingface/transformers";
84 description = "State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch";
85 changelog = "https://github.com/huggingface/transformers/releases/tag/v${version}";
86 license = licenses.asl20;
87 platforms = platforms.unix;
88 maintainers = with maintainers; [ danieldk pashashocky ];
89 };
90}