Amar-Aly commited on
Commit
6299998
·
verified ·
1 Parent(s): 210a8de

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/__init__.py +204 -0
  2. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/audio_classification.py +43 -0
  3. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/audio_to_audio.py +30 -0
  4. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +113 -0
  5. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/base.py +167 -0
  6. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/chat_completion.py +347 -0
  7. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/depth_estimation.py +28 -0
  8. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/document_question_answering.py +80 -0
  9. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/feature_extraction.py +36 -0
  10. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/fill_mask.py +47 -0
  11. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_classification.py +43 -0
  12. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_segmentation.py +51 -0
  13. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_text_to_image.py +67 -0
  14. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_text_to_video.py +65 -0
  15. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_to_image.py +60 -0
  16. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_to_video.py +60 -0
  17. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/object_detection.py +56 -0
  18. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/question_answering.py +72 -0
  19. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/sentence_similarity.py +27 -0
  20. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/summarization.py +41 -0
  21. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/table_question_answering.py +62 -0
  22. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/text2text_generation.py +42 -0
  23. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/text_generation.py +168 -0
  24. .cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/visual_question_answering.py +49 -0
  25. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/METADATA +1595 -0
  26. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/RECORD +39 -0
  27. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/WHEEL +5 -0
  28. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/entry_points.txt +2 -0
  29. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/licenses/LICENCE +49 -0
  30. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/top_level.txt +1 -0
  31. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/__init__.py +38 -0
  32. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/__main__.py +3 -0
  33. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_main.py +9 -0
  34. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_monitor.py +95 -0
  35. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm.py +9 -0
  36. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm_gui.py +9 -0
  37. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm_notebook.py +9 -0
  38. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm_pandas.py +24 -0
  39. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_utils.py +11 -0
  40. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/asyncio.py +93 -0
  41. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/auto.py +40 -0
  42. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/autonotebook.py +29 -0
  43. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/cli.py +324 -0
  44. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/completion.sh +19 -0
  45. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/__init__.py +91 -0
  46. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/bells.py +26 -0
  47. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/concurrent.py +105 -0
  48. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/discord.py +156 -0
  49. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/itertools.py +35 -0
  50. .cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/logging.py +126 -0
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/__init__.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is auto-generated by `utils/generate_inference_types.py`.
2
+ # Do not modify it manually.
3
+ #
4
+ # ruff: noqa: F401
5
+
6
+ from .audio_classification import (
7
+ AudioClassificationInput,
8
+ AudioClassificationOutputElement,
9
+ AudioClassificationOutputTransform,
10
+ AudioClassificationParameters,
11
+ )
12
+ from .audio_to_audio import AudioToAudioInput, AudioToAudioOutputElement
13
+ from .automatic_speech_recognition import (
14
+ AutomaticSpeechRecognitionEarlyStoppingEnum,
15
+ AutomaticSpeechRecognitionGenerationParameters,
16
+ AutomaticSpeechRecognitionInput,
17
+ AutomaticSpeechRecognitionOutput,
18
+ AutomaticSpeechRecognitionOutputChunk,
19
+ AutomaticSpeechRecognitionParameters,
20
+ )
21
+ from .base import BaseInferenceType
22
+ from .chat_completion import (
23
+ ChatCompletionInput,
24
+ ChatCompletionInputFunctionDefinition,
25
+ ChatCompletionInputFunctionName,
26
+ ChatCompletionInputGrammarType,
27
+ ChatCompletionInputJSONSchema,
28
+ ChatCompletionInputMessage,
29
+ ChatCompletionInputMessageChunk,
30
+ ChatCompletionInputMessageChunkType,
31
+ ChatCompletionInputResponseFormatJSONObject,
32
+ ChatCompletionInputResponseFormatJSONSchema,
33
+ ChatCompletionInputResponseFormatText,
34
+ ChatCompletionInputStreamOptions,
35
+ ChatCompletionInputTool,
36
+ ChatCompletionInputToolCall,
37
+ ChatCompletionInputToolChoiceClass,
38
+ ChatCompletionInputToolChoiceEnum,
39
+ ChatCompletionInputURL,
40
+ ChatCompletionOutput,
41
+ ChatCompletionOutputComplete,
42
+ ChatCompletionOutputFunctionDefinition,
43
+ ChatCompletionOutputLogprob,
44
+ ChatCompletionOutputLogprobs,
45
+ ChatCompletionOutputMessage,
46
+ ChatCompletionOutputToolCall,
47
+ ChatCompletionOutputTopLogprob,
48
+ ChatCompletionOutputUsage,
49
+ ChatCompletionStreamOutput,
50
+ ChatCompletionStreamOutputChoice,
51
+ ChatCompletionStreamOutputDelta,
52
+ ChatCompletionStreamOutputDeltaToolCall,
53
+ ChatCompletionStreamOutputFunction,
54
+ ChatCompletionStreamOutputLogprob,
55
+ ChatCompletionStreamOutputLogprobs,
56
+ ChatCompletionStreamOutputTopLogprob,
57
+ ChatCompletionStreamOutputUsage,
58
+ )
59
+ from .depth_estimation import DepthEstimationInput, DepthEstimationOutput
60
+ from .document_question_answering import (
61
+ DocumentQuestionAnsweringInput,
62
+ DocumentQuestionAnsweringInputData,
63
+ DocumentQuestionAnsweringOutputElement,
64
+ DocumentQuestionAnsweringParameters,
65
+ )
66
+ from .feature_extraction import FeatureExtractionInput, FeatureExtractionInputTruncationDirection
67
+ from .fill_mask import FillMaskInput, FillMaskOutputElement, FillMaskParameters
68
+ from .image_classification import (
69
+ ImageClassificationInput,
70
+ ImageClassificationOutputElement,
71
+ ImageClassificationOutputTransform,
72
+ ImageClassificationParameters,
73
+ )
74
+ from .image_segmentation import (
75
+ ImageSegmentationInput,
76
+ ImageSegmentationOutputElement,
77
+ ImageSegmentationParameters,
78
+ ImageSegmentationSubtask,
79
+ )
80
+ from .image_text_to_image import (
81
+ ImageTextToImageInput,
82
+ ImageTextToImageOutput,
83
+ ImageTextToImageParameters,
84
+ ImageTextToImageTargetSize,
85
+ )
86
+ from .image_text_to_video import (
87
+ ImageTextToVideoInput,
88
+ ImageTextToVideoOutput,
89
+ ImageTextToVideoParameters,
90
+ ImageTextToVideoTargetSize,
91
+ )
92
+ from .image_to_image import ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToImageTargetSize
93
+ from .image_to_text import (
94
+ ImageToTextEarlyStoppingEnum,
95
+ ImageToTextGenerationParameters,
96
+ ImageToTextInput,
97
+ ImageToTextOutput,
98
+ ImageToTextParameters,
99
+ )
100
+ from .image_to_video import ImageToVideoInput, ImageToVideoOutput, ImageToVideoParameters, ImageToVideoTargetSize
101
+ from .object_detection import (
102
+ ObjectDetectionBoundingBox,
103
+ ObjectDetectionInput,
104
+ ObjectDetectionOutputElement,
105
+ ObjectDetectionParameters,
106
+ )
107
+ from .question_answering import (
108
+ QuestionAnsweringInput,
109
+ QuestionAnsweringInputData,
110
+ QuestionAnsweringOutputElement,
111
+ QuestionAnsweringParameters,
112
+ )
113
+ from .sentence_similarity import SentenceSimilarityInput, SentenceSimilarityInputData
114
+ from .summarization import (
115
+ SummarizationInput,
116
+ SummarizationOutput,
117
+ SummarizationParameters,
118
+ SummarizationTruncationStrategy,
119
+ )
120
+ from .table_question_answering import (
121
+ Padding,
122
+ TableQuestionAnsweringInput,
123
+ TableQuestionAnsweringInputData,
124
+ TableQuestionAnsweringOutputElement,
125
+ TableQuestionAnsweringParameters,
126
+ )
127
+ from .text2text_generation import (
128
+ Text2TextGenerationInput,
129
+ Text2TextGenerationOutput,
130
+ Text2TextGenerationParameters,
131
+ Text2TextGenerationTruncationStrategy,
132
+ )
133
+ from .text_classification import (
134
+ TextClassificationInput,
135
+ TextClassificationOutputElement,
136
+ TextClassificationOutputTransform,
137
+ TextClassificationParameters,
138
+ )
139
+ from .text_generation import (
140
+ TextGenerationInput,
141
+ TextGenerationInputGenerateParameters,
142
+ TextGenerationInputGrammarType,
143
+ TextGenerationOutput,
144
+ TextGenerationOutputBestOfSequence,
145
+ TextGenerationOutputDetails,
146
+ TextGenerationOutputFinishReason,
147
+ TextGenerationOutputPrefillToken,
148
+ TextGenerationOutputToken,
149
+ TextGenerationStreamOutput,
150
+ TextGenerationStreamOutputStreamDetails,
151
+ TextGenerationStreamOutputToken,
152
+ TypeEnum,
153
+ )
154
+ from .text_to_audio import (
155
+ TextToAudioEarlyStoppingEnum,
156
+ TextToAudioGenerationParameters,
157
+ TextToAudioInput,
158
+ TextToAudioOutput,
159
+ TextToAudioParameters,
160
+ )
161
+ from .text_to_image import TextToImageInput, TextToImageOutput, TextToImageParameters
162
+ from .text_to_speech import (
163
+ TextToSpeechEarlyStoppingEnum,
164
+ TextToSpeechGenerationParameters,
165
+ TextToSpeechInput,
166
+ TextToSpeechOutput,
167
+ TextToSpeechParameters,
168
+ )
169
+ from .text_to_video import TextToVideoInput, TextToVideoOutput, TextToVideoParameters
170
+ from .token_classification import (
171
+ TokenClassificationAggregationStrategy,
172
+ TokenClassificationInput,
173
+ TokenClassificationOutputElement,
174
+ TokenClassificationParameters,
175
+ )
176
+ from .translation import TranslationInput, TranslationOutput, TranslationParameters, TranslationTruncationStrategy
177
+ from .video_classification import (
178
+ VideoClassificationInput,
179
+ VideoClassificationOutputElement,
180
+ VideoClassificationOutputTransform,
181
+ VideoClassificationParameters,
182
+ )
183
+ from .visual_question_answering import (
184
+ VisualQuestionAnsweringInput,
185
+ VisualQuestionAnsweringInputData,
186
+ VisualQuestionAnsweringOutputElement,
187
+ VisualQuestionAnsweringParameters,
188
+ )
189
+ from .zero_shot_classification import (
190
+ ZeroShotClassificationInput,
191
+ ZeroShotClassificationOutputElement,
192
+ ZeroShotClassificationParameters,
193
+ )
194
+ from .zero_shot_image_classification import (
195
+ ZeroShotImageClassificationInput,
196
+ ZeroShotImageClassificationOutputElement,
197
+ ZeroShotImageClassificationParameters,
198
+ )
199
+ from .zero_shot_object_detection import (
200
+ ZeroShotObjectDetectionBoundingBox,
201
+ ZeroShotObjectDetectionInput,
202
+ ZeroShotObjectDetectionOutputElement,
203
+ ZeroShotObjectDetectionParameters,
204
+ )
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/audio_classification.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ AudioClassificationOutputTransform = Literal["sigmoid", "softmax", "none"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class AudioClassificationParameters(BaseInferenceType):
16
+ """Additional inference parameters for Audio Classification"""
17
+
18
+ function_to_apply: Optional["AudioClassificationOutputTransform"] = None
19
+ """The function to apply to the model outputs in order to retrieve the scores."""
20
+ top_k: int | None = None
21
+ """When specified, limits the output to the top K most probable classes."""
22
+
23
+
24
+ @dataclass_with_extra
25
+ class AudioClassificationInput(BaseInferenceType):
26
+ """Inputs for Audio Classification inference"""
27
+
28
+ inputs: str
29
+ """The input audio data as a base64-encoded string. If no `parameters` are provided, you can
30
+ also provide the audio data as a raw bytes payload.
31
+ """
32
+ parameters: AudioClassificationParameters | None = None
33
+ """Additional inference parameters for Audio Classification"""
34
+
35
+
36
+ @dataclass_with_extra
37
+ class AudioClassificationOutputElement(BaseInferenceType):
38
+ """Outputs for Audio Classification inference"""
39
+
40
+ label: str
41
+ """The predicted class label."""
42
+ score: float
43
+ """The corresponding probability."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/audio_to_audio.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class AudioToAudioInput(BaseInferenceType):
13
+ """Inputs for Audio to Audio inference"""
14
+
15
+ inputs: Any
16
+ """The input audio data"""
17
+
18
+
19
+ @dataclass_with_extra
20
+ class AudioToAudioOutputElement(BaseInferenceType):
21
+ """Outputs of inference for the Audio To Audio task
22
+ A generated audio file with its label.
23
+ """
24
+
25
+ blob: Any
26
+ """The generated audio file."""
27
+ content_type: str
28
+ """The content type of audio file."""
29
+ label: str
30
+ """The label of the audio file."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/automatic_speech_recognition.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Literal, Union
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ AutomaticSpeechRecognitionEarlyStoppingEnum = Literal["never"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class AutomaticSpeechRecognitionGenerationParameters(BaseInferenceType):
16
+ """Parametrization of the text generation process"""
17
+
18
+ do_sample: bool | None = None
19
+ """Whether to use sampling instead of greedy decoding when generating new tokens."""
20
+ early_stopping: Union[bool, "AutomaticSpeechRecognitionEarlyStoppingEnum"] | None = None
21
+ """Controls the stopping condition for beam-based methods."""
22
+ epsilon_cutoff: float | None = None
23
+ """If set to float strictly between 0 and 1, only tokens with a conditional probability
24
+ greater than epsilon_cutoff will be sampled. In the paper, suggested values range from
25
+ 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language
26
+ Model Desmoothing](https://hf.co/papers/2210.15191) for more details.
27
+ """
28
+ eta_cutoff: float | None = None
29
+ """Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to
30
+ float strictly between 0 and 1, a token is only considered if it is greater than either
31
+ eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter
32
+ term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In
33
+ the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
34
+ See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191)
35
+ for more details.
36
+ """
37
+ max_length: int | None = None
38
+ """The maximum length (in tokens) of the generated text, including the input."""
39
+ max_new_tokens: int | None = None
40
+ """The maximum number of tokens to generate. Takes precedence over max_length."""
41
+ min_length: int | None = None
42
+ """The minimum length (in tokens) of the generated text, including the input."""
43
+ min_new_tokens: int | None = None
44
+ """The minimum number of tokens to generate. Takes precedence over min_length."""
45
+ num_beam_groups: int | None = None
46
+ """Number of groups to divide num_beams into in order to ensure diversity among different
47
+ groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
48
+ """
49
+ num_beams: int | None = None
50
+ """Number of beams to use for beam search."""
51
+ penalty_alpha: float | None = None
52
+ """The value balances the model confidence and the degeneration penalty in contrastive
53
+ search decoding.
54
+ """
55
+ temperature: float | None = None
56
+ """The value used to modulate the next token probabilities."""
57
+ top_k: int | None = None
58
+ """The number of highest probability vocabulary tokens to keep for top-k-filtering."""
59
+ top_p: float | None = None
60
+ """If set to float < 1, only the smallest set of most probable tokens with probabilities
61
+ that add up to top_p or higher are kept for generation.
62
+ """
63
+ typical_p: float | None = None
64
+ """Local typicality measures how similar the conditional probability of predicting a target
65
+ token next is to the expected conditional probability of predicting a random token next,
66
+ given the partial text already generated. If set to float < 1, the smallest set of the
67
+ most locally typical tokens with probabilities that add up to typical_p or higher are
68
+ kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details.
69
+ """
70
+ use_cache: bool | None = None
71
+ """Whether the model should use the past last key/values attentions to speed up decoding"""
72
+
73
+
74
+ @dataclass_with_extra
75
+ class AutomaticSpeechRecognitionParameters(BaseInferenceType):
76
+ """Additional inference parameters for Automatic Speech Recognition"""
77
+
78
+ generation_parameters: AutomaticSpeechRecognitionGenerationParameters | None = None
79
+ """Parametrization of the text generation process"""
80
+ return_timestamps: bool | None = None
81
+ """Whether to output corresponding timestamps with the generated text"""
82
+
83
+
84
+ @dataclass_with_extra
85
+ class AutomaticSpeechRecognitionInput(BaseInferenceType):
86
+ """Inputs for Automatic Speech Recognition inference"""
87
+
88
+ inputs: str
89
+ """The input audio data as a base64-encoded string. If no `parameters` are provided, you can
90
+ also provide the audio data as a raw bytes payload.
91
+ """
92
+ parameters: AutomaticSpeechRecognitionParameters | None = None
93
+ """Additional inference parameters for Automatic Speech Recognition"""
94
+
95
+
96
+ @dataclass_with_extra
97
+ class AutomaticSpeechRecognitionOutputChunk(BaseInferenceType):
98
+ text: str
99
+ """A chunk of text identified by the model"""
100
+ timestamp: list[float]
101
+ """The start and end timestamps corresponding with the text"""
102
+
103
+
104
+ @dataclass_with_extra
105
+ class AutomaticSpeechRecognitionOutput(BaseInferenceType):
106
+ """Outputs of inference for the Automatic Speech Recognition task"""
107
+
108
+ text: str
109
+ """The recognized text."""
110
+ chunks: list[AutomaticSpeechRecognitionOutputChunk] | None = None
111
+ """When returnTimestamps is enabled, chunks contains a list of audio chunks identified by
112
+ the model.
113
+ """
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/base.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 The HuggingFace Team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Contains a base class for all inference types."""
15
+
16
+ import inspect
17
+ import json
18
+ import types
19
+ from dataclasses import asdict, dataclass
20
+ from typing import Any, TypeVar, get_args
21
+
22
+ from typing_extensions import dataclass_transform
23
+
24
+
25
+ T = TypeVar("T", bound="BaseInferenceType")
26
+
27
+
28
+ def _repr_with_extra(self):
29
+ fields = list(self.__dataclass_fields__.keys())
30
+ other_fields = list(k for k in self.__dict__ if k not in fields)
31
+ return f"{self.__class__.__name__}({', '.join(f'{k}={self.__dict__[k]!r}' for k in fields + other_fields)})"
32
+
33
+
34
+ @dataclass_transform()
35
+ def dataclass_with_extra(cls: type[T]) -> type[T]:
36
+ """Decorator to add a custom __repr__ method to a dataclass, showing all fields, including extra ones.
37
+
38
+ This decorator only works with dataclasses that inherit from `BaseInferenceType`.
39
+ """
40
+ cls = dataclass(cls)
41
+ cls.__repr__ = _repr_with_extra # type: ignore[method-assign]
42
+ return cls
43
+
44
+
45
+ @dataclass
46
+ class BaseInferenceType(dict):
47
+ """Base class for all inference types.
48
+
49
+ Object is a dataclass and a dict for backward compatibility but plan is to remove the dict part in the future.
50
+
51
+ Handle parsing from dict, list and json strings in a permissive way to ensure future-compatibility (e.g. all fields
52
+ are made optional, and non-expected fields are added as dict attributes).
53
+ """
54
+
55
+ @classmethod
56
+ def parse_obj_as_list(cls: type[T], data: bytes | str | list | dict) -> list[T]:
57
+ """Alias to parse server response and return a single instance.
58
+
59
+ See `parse_obj` for more details.
60
+ """
61
+ output = cls.parse_obj(data)
62
+ if not isinstance(output, list):
63
+ raise ValueError(f"Invalid input data for {cls}. Expected a list, but got {type(output)}.")
64
+ return output
65
+
66
+ @classmethod
67
+ def parse_obj_as_instance(cls: type[T], data: bytes | str | list | dict) -> T:
68
+ """Alias to parse server response and return a single instance.
69
+
70
+ See `parse_obj` for more details.
71
+ """
72
+ output = cls.parse_obj(data)
73
+ if isinstance(output, list):
74
+ raise ValueError(f"Invalid input data for {cls}. Expected a single instance, but got a list.")
75
+ return output
76
+
77
+ @classmethod
78
+ def parse_obj(cls: type[T], data: bytes | str | list | dict) -> list[T] | T:
79
+ """Parse server response as a dataclass or list of dataclasses.
80
+
81
+ To enable future-compatibility, we want to handle cases where the server return more fields than expected.
82
+ In such cases, we don't want to raise an error but still create the dataclass object. Remaining fields are
83
+ added as dict attributes.
84
+ """
85
+ # Parse server response (from bytes)
86
+ if isinstance(data, bytes):
87
+ data = data.decode()
88
+ if isinstance(data, str):
89
+ data = json.loads(data)
90
+
91
+ # If a list, parse each item individually
92
+ if isinstance(data, list):
93
+ return [cls.parse_obj(d) for d in data] # type: ignore
94
+
95
+ # At this point, we expect a dict
96
+ if not isinstance(data, dict):
97
+ raise ValueError(f"Invalid data type: {type(data)}")
98
+
99
+ init_values = {}
100
+ other_values = {}
101
+ for key, value in data.items():
102
+ key = normalize_key(key)
103
+ if key in cls.__dataclass_fields__ and cls.__dataclass_fields__[key].init:
104
+ if isinstance(value, dict) or isinstance(value, list):
105
+ field_type = cls.__dataclass_fields__[key].type
106
+
107
+ # if `field_type` is a `BaseInferenceType`, parse it
108
+ if inspect.isclass(field_type) and issubclass(field_type, BaseInferenceType):
109
+ value = field_type.parse_obj(value)
110
+
111
+ # otherwise, recursively parse nested dataclasses (if possible)
112
+ # `get_args` returns handle Union and Optional for us
113
+ else:
114
+ expected_types = get_args(field_type)
115
+ for expected_type in expected_types:
116
+ if (
117
+ isinstance(expected_type, types.GenericAlias) and expected_type.__origin__ is list
118
+ ) or getattr(expected_type, "_name", None) == "List":
119
+ expected_type = get_args(expected_type)[
120
+ 0
121
+ ] # assume same type for all items in the list
122
+ if inspect.isclass(expected_type) and issubclass(expected_type, BaseInferenceType):
123
+ value = expected_type.parse_obj(value)
124
+ break
125
+ init_values[key] = value
126
+ else:
127
+ other_values[key] = value
128
+
129
+ # Make all missing fields default to None
130
+ # => ensure that dataclass initialization will never fail even if the server does not return all fields.
131
+ for key in cls.__dataclass_fields__:
132
+ if key not in init_values:
133
+ init_values[key] = None
134
+
135
+ # Initialize dataclass with expected values
136
+ item = cls(**init_values)
137
+
138
+ # Add remaining fields as dict attributes
139
+ item.update(other_values)
140
+
141
+ # Add remaining fields as extra dataclass fields.
142
+ # They won't be part of the dataclass fields but will be accessible as attributes.
143
+ # Use @dataclass_with_extra to show them in __repr__.
144
+ item.__dict__.update(other_values)
145
+ return item
146
+
147
+ def __post_init__(self):
148
+ self.update(asdict(self))
149
+
150
+ def __setitem__(self, __key: Any, __value: Any) -> None:
151
+ # Hacky way to keep dataclass values in sync when dict is updated
152
+ super().__setitem__(__key, __value)
153
+ if __key in self.__dataclass_fields__ and getattr(self, __key, None) != __value:
154
+ self.__setattr__(__key, __value)
155
+ return
156
+
157
+ def __setattr__(self, __name: str, __value: Any) -> None:
158
+ # Hacky way to keep dict values is sync when dataclass is updated
159
+ super().__setattr__(__name, __value)
160
+ if self.get(__name) != __value:
161
+ self[__name] = __value
162
+ return
163
+
164
+
165
+ def normalize_key(key: str) -> str:
166
+ # e.g "content-type" -> "content_type", "Accept" -> "accept"
167
+ return key.replace("-", "_").replace(" ", "_").lower()
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/chat_completion.py ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any, Literal, Union
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class ChatCompletionInputURL(BaseInferenceType):
13
+ url: str
14
+
15
+
16
+ ChatCompletionInputMessageChunkType = Literal["text", "image_url"]
17
+
18
+
19
+ @dataclass_with_extra
20
+ class ChatCompletionInputMessageChunk(BaseInferenceType):
21
+ type: "ChatCompletionInputMessageChunkType"
22
+ image_url: ChatCompletionInputURL | None = None
23
+ text: str | None = None
24
+
25
+
26
+ @dataclass_with_extra
27
+ class ChatCompletionInputFunctionDefinition(BaseInferenceType):
28
+ name: str
29
+ parameters: Any
30
+ description: str | None = None
31
+
32
+
33
+ @dataclass_with_extra
34
+ class ChatCompletionInputToolCall(BaseInferenceType):
35
+ function: ChatCompletionInputFunctionDefinition
36
+ id: str
37
+ type: str
38
+
39
+
40
+ @dataclass_with_extra
41
+ class ChatCompletionInputMessage(BaseInferenceType):
42
+ role: str
43
+ content: list[ChatCompletionInputMessageChunk] | str | None = None
44
+ name: str | None = None
45
+ tool_calls: list[ChatCompletionInputToolCall] | None = None
46
+
47
+
48
+ @dataclass_with_extra
49
+ class ChatCompletionInputJSONSchema(BaseInferenceType):
50
+ name: str
51
+ """
52
+ The name of the response format.
53
+ """
54
+ description: str | None = None
55
+ """
56
+ A description of what the response format is for, used by the model to determine
57
+ how to respond in the format.
58
+ """
59
+ schema: dict[str, object] | None = None
60
+ """
61
+ The schema for the response format, described as a JSON Schema object. Learn how
62
+ to build JSON schemas [here](https://json-schema.org/).
63
+ """
64
+ strict: bool | None = None
65
+ """
66
+ Whether to enable strict schema adherence when generating the output. If set to
67
+ true, the model will always follow the exact schema defined in the `schema`
68
+ field.
69
+ """
70
+
71
+
72
+ @dataclass_with_extra
73
+ class ChatCompletionInputResponseFormatText(BaseInferenceType):
74
+ type: Literal["text"]
75
+
76
+
77
+ @dataclass_with_extra
78
+ class ChatCompletionInputResponseFormatJSONSchema(BaseInferenceType):
79
+ type: Literal["json_schema"]
80
+ json_schema: ChatCompletionInputJSONSchema
81
+
82
+
83
+ @dataclass_with_extra
84
+ class ChatCompletionInputResponseFormatJSONObject(BaseInferenceType):
85
+ type: Literal["json_object"]
86
+
87
+
88
+ ChatCompletionInputGrammarType = Union[
89
+ ChatCompletionInputResponseFormatText,
90
+ ChatCompletionInputResponseFormatJSONSchema,
91
+ ChatCompletionInputResponseFormatJSONObject,
92
+ ]
93
+
94
+
95
+ @dataclass_with_extra
96
+ class ChatCompletionInputStreamOptions(BaseInferenceType):
97
+ include_usage: bool | None = None
98
+ """If set, an additional chunk will be streamed before the data: [DONE] message. The usage
99
+ field on this chunk shows the token usage statistics for the entire request, and the
100
+ choices field will always be an empty array. All other chunks will also include a usage
101
+ field, but with a null value.
102
+ """
103
+
104
+
105
+ @dataclass_with_extra
106
+ class ChatCompletionInputFunctionName(BaseInferenceType):
107
+ name: str
108
+
109
+
110
+ @dataclass_with_extra
111
+ class ChatCompletionInputToolChoiceClass(BaseInferenceType):
112
+ function: ChatCompletionInputFunctionName
113
+
114
+
115
+ ChatCompletionInputToolChoiceEnum = Literal["auto", "none", "required"]
116
+
117
+
118
+ @dataclass_with_extra
119
+ class ChatCompletionInputTool(BaseInferenceType):
120
+ function: ChatCompletionInputFunctionDefinition
121
+ type: str
122
+
123
+
124
+ @dataclass_with_extra
125
+ class ChatCompletionInput(BaseInferenceType):
126
+ """Chat Completion Input.
127
+ Auto-generated from TGI specs.
128
+ For more details, check out
129
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
130
+ """
131
+
132
+ messages: list[ChatCompletionInputMessage]
133
+ """A list of messages comprising the conversation so far."""
134
+ frequency_penalty: float | None = None
135
+ """Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing
136
+ frequency in the text so far,
137
+ decreasing the model's likelihood to repeat the same line verbatim.
138
+ """
139
+ logit_bias: list[float] | None = None
140
+ """UNUSED
141
+ Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON
142
+ object that maps tokens
143
+ (specified by their token ID in the tokenizer) to an associated bias value from -100 to
144
+ 100. Mathematically,
145
+ the bias is added to the logits generated by the model prior to sampling. The exact
146
+ effect will vary per model,
147
+ but values between -1 and 1 should decrease or increase likelihood of selection; values
148
+ like -100 or 100 should
149
+ result in a ban or exclusive selection of the relevant token.
150
+ """
151
+ logprobs: bool | None = None
152
+ """Whether to return log probabilities of the output tokens or not. If true, returns the log
153
+ probabilities of each
154
+ output token returned in the content of message.
155
+ """
156
+ max_tokens: int | None = None
157
+ """The maximum number of tokens that can be generated in the chat completion."""
158
+ model: str | None = None
159
+ """[UNUSED] ID of the model to use. See the model endpoint compatibility table for details
160
+ on which models work with the Chat API.
161
+ """
162
+ n: int | None = None
163
+ """UNUSED
164
+ How many chat completion choices to generate for each input message. Note that you will
165
+ be charged based on the
166
+ number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
167
+ """
168
+ presence_penalty: float | None = None
169
+ """Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they
170
+ appear in the text so far,
171
+ increasing the model's likelihood to talk about new topics
172
+ """
173
+ response_format: ChatCompletionInputGrammarType | None = None
174
+ seed: int | None = None
175
+ stop: list[str] | None = None
176
+ """Up to 4 sequences where the API will stop generating further tokens."""
177
+ stream: bool | None = None
178
+ stream_options: ChatCompletionInputStreamOptions | None = None
179
+ temperature: float | None = None
180
+ """What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
181
+ output more random, while
182
+ lower values like 0.2 will make it more focused and deterministic.
183
+ We generally recommend altering this or `top_p` but not both.
184
+ """
185
+ tool_choice: Union[ChatCompletionInputToolChoiceClass, "ChatCompletionInputToolChoiceEnum"] | None = None
186
+ tool_prompt: str | None = None
187
+ """A prompt to be appended before the tools"""
188
+ tools: list[ChatCompletionInputTool] | None = None
189
+ """A list of tools the model may call. Currently, only functions are supported as a tool.
190
+ Use this to provide a list of
191
+ functions the model may generate JSON inputs for.
192
+ """
193
+ top_logprobs: int | None = None
194
+ """An integer between 0 and 5 specifying the number of most likely tokens to return at each
195
+ token position, each with
196
+ an associated log probability. logprobs must be set to true if this parameter is used.
197
+ """
198
+ top_p: float | None = None
199
+ """An alternative to sampling with temperature, called nucleus sampling, where the model
200
+ considers the results of the
201
+ tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%
202
+ probability mass are considered.
203
+ """
204
+
205
+
206
+ @dataclass_with_extra
207
+ class ChatCompletionOutputTopLogprob(BaseInferenceType):
208
+ logprob: float
209
+ token: str
210
+
211
+
212
+ @dataclass_with_extra
213
+ class ChatCompletionOutputLogprob(BaseInferenceType):
214
+ logprob: float
215
+ token: str
216
+ top_logprobs: list[ChatCompletionOutputTopLogprob]
217
+
218
+
219
+ @dataclass_with_extra
220
+ class ChatCompletionOutputLogprobs(BaseInferenceType):
221
+ content: list[ChatCompletionOutputLogprob]
222
+
223
+
224
+ @dataclass_with_extra
225
+ class ChatCompletionOutputFunctionDefinition(BaseInferenceType):
226
+ arguments: str
227
+ name: str
228
+ description: str | None = None
229
+
230
+
231
+ @dataclass_with_extra
232
+ class ChatCompletionOutputToolCall(BaseInferenceType):
233
+ function: ChatCompletionOutputFunctionDefinition
234
+ id: str
235
+ type: str
236
+
237
+
238
+ @dataclass_with_extra
239
+ class ChatCompletionOutputMessage(BaseInferenceType):
240
+ role: str
241
+ content: str | None = None
242
+ reasoning: str | None = None
243
+ tool_call_id: str | None = None
244
+ tool_calls: list[ChatCompletionOutputToolCall] | None = None
245
+
246
+
247
+ @dataclass_with_extra
248
+ class ChatCompletionOutputComplete(BaseInferenceType):
249
+ finish_reason: str
250
+ index: int
251
+ message: ChatCompletionOutputMessage
252
+ logprobs: ChatCompletionOutputLogprobs | None = None
253
+
254
+
255
+ @dataclass_with_extra
256
+ class ChatCompletionOutputUsage(BaseInferenceType):
257
+ completion_tokens: int
258
+ prompt_tokens: int
259
+ total_tokens: int
260
+
261
+
262
+ @dataclass_with_extra
263
+ class ChatCompletionOutput(BaseInferenceType):
264
+ """Chat Completion Output.
265
+ Auto-generated from TGI specs.
266
+ For more details, check out
267
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
268
+ """
269
+
270
+ choices: list[ChatCompletionOutputComplete]
271
+ created: int
272
+ id: str
273
+ model: str
274
+ system_fingerprint: str
275
+ usage: ChatCompletionOutputUsage
276
+
277
+
278
+ @dataclass_with_extra
279
+ class ChatCompletionStreamOutputFunction(BaseInferenceType):
280
+ arguments: str
281
+ name: str | None = None
282
+
283
+
284
+ @dataclass_with_extra
285
+ class ChatCompletionStreamOutputDeltaToolCall(BaseInferenceType):
286
+ function: ChatCompletionStreamOutputFunction
287
+ id: str
288
+ index: int
289
+ type: str
290
+
291
+
292
+ @dataclass_with_extra
293
+ class ChatCompletionStreamOutputDelta(BaseInferenceType):
294
+ role: str
295
+ content: str | None = None
296
+ reasoning: str | None = None
297
+ tool_call_id: str | None = None
298
+ tool_calls: list[ChatCompletionStreamOutputDeltaToolCall] | None = None
299
+
300
+
301
+ @dataclass_with_extra
302
+ class ChatCompletionStreamOutputTopLogprob(BaseInferenceType):
303
+ logprob: float
304
+ token: str
305
+
306
+
307
+ @dataclass_with_extra
308
+ class ChatCompletionStreamOutputLogprob(BaseInferenceType):
309
+ logprob: float
310
+ token: str
311
+ top_logprobs: list[ChatCompletionStreamOutputTopLogprob]
312
+
313
+
314
+ @dataclass_with_extra
315
+ class ChatCompletionStreamOutputLogprobs(BaseInferenceType):
316
+ content: list[ChatCompletionStreamOutputLogprob]
317
+
318
+
319
+ @dataclass_with_extra
320
+ class ChatCompletionStreamOutputChoice(BaseInferenceType):
321
+ delta: ChatCompletionStreamOutputDelta
322
+ index: int
323
+ finish_reason: str | None = None
324
+ logprobs: ChatCompletionStreamOutputLogprobs | None = None
325
+
326
+
327
+ @dataclass_with_extra
328
+ class ChatCompletionStreamOutputUsage(BaseInferenceType):
329
+ completion_tokens: int
330
+ prompt_tokens: int
331
+ total_tokens: int
332
+
333
+
334
+ @dataclass_with_extra
335
+ class ChatCompletionStreamOutput(BaseInferenceType):
336
+ """Chat Completion Stream Output.
337
+ Auto-generated from TGI specs.
338
+ For more details, check out
339
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
340
+ """
341
+
342
+ choices: list[ChatCompletionStreamOutputChoice]
343
+ created: int
344
+ id: str
345
+ model: str
346
+ system_fingerprint: str
347
+ usage: ChatCompletionStreamOutputUsage | None = None
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/depth_estimation.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class DepthEstimationInput(BaseInferenceType):
13
+ """Inputs for Depth Estimation inference"""
14
+
15
+ inputs: Any
16
+ """The input image data"""
17
+ parameters: dict[str, Any] | None = None
18
+ """Additional inference parameters for Depth Estimation"""
19
+
20
+
21
+ @dataclass_with_extra
22
+ class DepthEstimationOutput(BaseInferenceType):
23
+ """Outputs of inference for the Depth Estimation task"""
24
+
25
+ depth: Any
26
+ """The predicted depth as an image"""
27
+ predicted_depth: Any
28
+ """The predicted depth as a tensor"""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/document_question_answering.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class DocumentQuestionAnsweringInputData(BaseInferenceType):
13
+ """One (document, question) pair to answer"""
14
+
15
+ image: Any
16
+ """The image on which the question is asked"""
17
+ question: str
18
+ """A question to ask of the document"""
19
+
20
+
21
+ @dataclass_with_extra
22
+ class DocumentQuestionAnsweringParameters(BaseInferenceType):
23
+ """Additional inference parameters for Document Question Answering"""
24
+
25
+ doc_stride: int | None = None
26
+ """If the words in the document are too long to fit with the question for the model, it will
27
+ be split in several chunks with some overlap. This argument controls the size of that
28
+ overlap.
29
+ """
30
+ handle_impossible_answer: bool | None = None
31
+ """Whether to accept impossible as an answer"""
32
+ lang: str | None = None
33
+ """Language to use while running OCR. Defaults to english."""
34
+ max_answer_len: int | None = None
35
+ """The maximum length of predicted answers (e.g., only answers with a shorter length are
36
+ considered).
37
+ """
38
+ max_question_len: int | None = None
39
+ """The maximum length of the question after tokenization. It will be truncated if needed."""
40
+ max_seq_len: int | None = None
41
+ """The maximum length of the total sentence (context + question) in tokens of each chunk
42
+ passed to the model. The context will be split in several chunks (using doc_stride as
43
+ overlap) if needed.
44
+ """
45
+ top_k: int | None = None
46
+ """The number of answers to return (will be chosen by order of likelihood). Can return less
47
+ than top_k answers if there are not enough options available within the context.
48
+ """
49
+ word_boxes: list[list[float] | str] | None = None
50
+ """A list of words and bounding boxes (normalized 0->1000). If provided, the inference will
51
+ skip the OCR step and use the provided bounding boxes instead.
52
+ """
53
+
54
+
55
+ @dataclass_with_extra
56
+ class DocumentQuestionAnsweringInput(BaseInferenceType):
57
+ """Inputs for Document Question Answering inference"""
58
+
59
+ inputs: DocumentQuestionAnsweringInputData
60
+ """One (document, question) pair to answer"""
61
+ parameters: DocumentQuestionAnsweringParameters | None = None
62
+ """Additional inference parameters for Document Question Answering"""
63
+
64
+
65
+ @dataclass_with_extra
66
+ class DocumentQuestionAnsweringOutputElement(BaseInferenceType):
67
+ """Outputs of inference for the Document Question Answering task"""
68
+
69
+ answer: str
70
+ """The answer to the question."""
71
+ end: int
72
+ """The end word index of the answer (in the OCR’d version of the input or provided word
73
+ boxes).
74
+ """
75
+ score: float
76
+ """The probability associated to the answer."""
77
+ start: int
78
+ """The start word index of the answer (in the OCR’d version of the input or provided word
79
+ boxes).
80
+ """
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/feature_extraction.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ FeatureExtractionInputTruncationDirection = Literal["left", "right"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class FeatureExtractionInput(BaseInferenceType):
16
+ """Feature Extraction Input.
17
+ Auto-generated from TEI specs.
18
+ For more details, check out
19
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tei-import.ts.
20
+ """
21
+
22
+ inputs: list[str] | str
23
+ """The text or list of texts to embed."""
24
+ normalize: bool | None = None
25
+ prompt_name: str | None = None
26
+ """The name of the prompt that should be used by for encoding. If not set, no prompt
27
+ will be applied.
28
+ Must be a key in the `sentence-transformers` configuration `prompts` dictionary.
29
+ For example if ``prompt_name`` is "query" and the ``prompts`` is {"query": "query: ",
30
+ ...},
31
+ then the sentence "What is the capital of France?" will be encoded as
32
+ "query: What is the capital of France?" because the prompt text will be prepended before
33
+ any text to encode.
34
+ """
35
+ truncate: bool | None = None
36
+ truncation_direction: Optional["FeatureExtractionInputTruncationDirection"] = None
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/fill_mask.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class FillMaskParameters(BaseInferenceType):
13
+ """Additional inference parameters for Fill Mask"""
14
+
15
+ targets: list[str] | None = None
16
+ """When passed, the model will limit the scores to the passed targets instead of looking up
17
+ in the whole vocabulary. If the provided targets are not in the model vocab, they will be
18
+ tokenized and the first resulting token will be used (with a warning, and that might be
19
+ slower).
20
+ """
21
+ top_k: int | None = None
22
+ """When passed, overrides the number of predictions to return."""
23
+
24
+
25
+ @dataclass_with_extra
26
+ class FillMaskInput(BaseInferenceType):
27
+ """Inputs for Fill Mask inference"""
28
+
29
+ inputs: str
30
+ """The text with masked tokens"""
31
+ parameters: FillMaskParameters | None = None
32
+ """Additional inference parameters for Fill Mask"""
33
+
34
+
35
+ @dataclass_with_extra
36
+ class FillMaskOutputElement(BaseInferenceType):
37
+ """Outputs of inference for the Fill Mask task"""
38
+
39
+ score: float
40
+ """The corresponding probability"""
41
+ sequence: str
42
+ """The corresponding input with the mask token prediction."""
43
+ token: int
44
+ """The predicted token id (to replace the masked one)."""
45
+ token_str: Any
46
+ fill_mask_output_token_str: str | None = None
47
+ """The predicted token (to replace the masked one)."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_classification.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ ImageClassificationOutputTransform = Literal["sigmoid", "softmax", "none"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class ImageClassificationParameters(BaseInferenceType):
16
+ """Additional inference parameters for Image Classification"""
17
+
18
+ function_to_apply: Optional["ImageClassificationOutputTransform"] = None
19
+ """The function to apply to the model outputs in order to retrieve the scores."""
20
+ top_k: int | None = None
21
+ """When specified, limits the output to the top K most probable classes."""
22
+
23
+
24
+ @dataclass_with_extra
25
+ class ImageClassificationInput(BaseInferenceType):
26
+ """Inputs for Image Classification inference"""
27
+
28
+ inputs: str
29
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
30
+ also provide the image data as a raw bytes payload.
31
+ """
32
+ parameters: ImageClassificationParameters | None = None
33
+ """Additional inference parameters for Image Classification"""
34
+
35
+
36
+ @dataclass_with_extra
37
+ class ImageClassificationOutputElement(BaseInferenceType):
38
+ """Outputs of inference for the Image Classification task"""
39
+
40
+ label: str
41
+ """The predicted class label."""
42
+ score: float
43
+ """The corresponding probability."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_segmentation.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ ImageSegmentationSubtask = Literal["instance", "panoptic", "semantic"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class ImageSegmentationParameters(BaseInferenceType):
16
+ """Additional inference parameters for Image Segmentation"""
17
+
18
+ mask_threshold: float | None = None
19
+ """Threshold to use when turning the predicted masks into binary values."""
20
+ overlap_mask_area_threshold: float | None = None
21
+ """Mask overlap threshold to eliminate small, disconnected segments."""
22
+ subtask: Optional["ImageSegmentationSubtask"] = None
23
+ """Segmentation task to be performed, depending on model capabilities."""
24
+ threshold: float | None = None
25
+ """Probability threshold to filter out predicted masks."""
26
+
27
+
28
+ @dataclass_with_extra
29
+ class ImageSegmentationInput(BaseInferenceType):
30
+ """Inputs for Image Segmentation inference"""
31
+
32
+ inputs: str
33
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
34
+ also provide the image data as a raw bytes payload.
35
+ """
36
+ parameters: ImageSegmentationParameters | None = None
37
+ """Additional inference parameters for Image Segmentation"""
38
+
39
+
40
+ @dataclass_with_extra
41
+ class ImageSegmentationOutputElement(BaseInferenceType):
42
+ """Outputs of inference for the Image Segmentation task
43
+ A predicted mask / segment
44
+ """
45
+
46
+ label: str
47
+ """The label of the predicted segment."""
48
+ mask: str
49
+ """The corresponding mask as a black-and-white image (base64-encoded)."""
50
+ score: float | None = None
51
+ """The score or confidence degree the model has."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_text_to_image.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class ImageTextToImageTargetSize(BaseInferenceType):
13
+ """The size in pixels of the output image. This parameter is only supported by some
14
+ providers and for specific models. It will be ignored when unsupported.
15
+ """
16
+
17
+ height: int
18
+ width: int
19
+
20
+
21
+ @dataclass_with_extra
22
+ class ImageTextToImageParameters(BaseInferenceType):
23
+ """Additional inference parameters for Image Text To Image"""
24
+
25
+ guidance_scale: float | None = None
26
+ """For diffusion models. A higher guidance scale value encourages the model to generate
27
+ images closely linked to the text prompt at the expense of lower image quality.
28
+ """
29
+ negative_prompt: str | None = None
30
+ """One prompt to guide what NOT to include in image generation."""
31
+ num_inference_steps: int | None = None
32
+ """For diffusion models. The number of denoising steps. More denoising steps usually lead to
33
+ a higher quality image at the expense of slower inference.
34
+ """
35
+ prompt: str | None = None
36
+ """The text prompt to guide the image generation. Either this or inputs (image) must be
37
+ provided.
38
+ """
39
+ seed: int | None = None
40
+ """Seed for the random number generator."""
41
+ target_size: ImageTextToImageTargetSize | None = None
42
+ """The size in pixels of the output image. This parameter is only supported by some
43
+ providers and for specific models. It will be ignored when unsupported.
44
+ """
45
+
46
+
47
+ @dataclass_with_extra
48
+ class ImageTextToImageInput(BaseInferenceType):
49
+ """Inputs for Image Text To Image inference. Either inputs (image) or prompt (in parameters)
50
+ must be provided, or both.
51
+ """
52
+
53
+ inputs: str | None = None
54
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
55
+ also provide the image data as a raw bytes payload. Either this or prompt must be
56
+ provided.
57
+ """
58
+ parameters: ImageTextToImageParameters | None = None
59
+ """Additional inference parameters for Image Text To Image"""
60
+
61
+
62
+ @dataclass_with_extra
63
+ class ImageTextToImageOutput(BaseInferenceType):
64
+ """Outputs of inference for the Image Text To Image task"""
65
+
66
+ image: Any
67
+ """The generated image returned as raw bytes in the payload."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_text_to_video.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class ImageTextToVideoTargetSize(BaseInferenceType):
13
+ """The size in pixel of the output video frames."""
14
+
15
+ height: int
16
+ width: int
17
+
18
+
19
+ @dataclass_with_extra
20
+ class ImageTextToVideoParameters(BaseInferenceType):
21
+ """Additional inference parameters for Image Text To Video"""
22
+
23
+ guidance_scale: float | None = None
24
+ """For diffusion models. A higher guidance scale value encourages the model to generate
25
+ videos closely linked to the text prompt at the expense of lower image quality.
26
+ """
27
+ negative_prompt: str | None = None
28
+ """One prompt to guide what NOT to include in video generation."""
29
+ num_frames: float | None = None
30
+ """The num_frames parameter determines how many video frames are generated."""
31
+ num_inference_steps: int | None = None
32
+ """The number of denoising steps. More denoising steps usually lead to a higher quality
33
+ video at the expense of slower inference.
34
+ """
35
+ prompt: str | None = None
36
+ """The text prompt to guide the video generation. Either this or inputs (image) must be
37
+ provided.
38
+ """
39
+ seed: int | None = None
40
+ """Seed for the random number generator."""
41
+ target_size: ImageTextToVideoTargetSize | None = None
42
+ """The size in pixel of the output video frames."""
43
+
44
+
45
+ @dataclass_with_extra
46
+ class ImageTextToVideoInput(BaseInferenceType):
47
+ """Inputs for Image Text To Video inference. Either inputs (image) or prompt (in parameters)
48
+ must be provided, or both.
49
+ """
50
+
51
+ inputs: str | None = None
52
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
53
+ also provide the image data as a raw bytes payload. Either this or prompt must be
54
+ provided.
55
+ """
56
+ parameters: ImageTextToVideoParameters | None = None
57
+ """Additional inference parameters for Image Text To Video"""
58
+
59
+
60
+ @dataclass_with_extra
61
+ class ImageTextToVideoOutput(BaseInferenceType):
62
+ """Outputs of inference for the Image Text To Video task"""
63
+
64
+ video: Any
65
+ """The generated video returned as raw bytes in the payload."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_to_image.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class ImageToImageTargetSize(BaseInferenceType):
13
+ """The size in pixels of the output image. This parameter is only supported by some
14
+ providers and for specific models. It will be ignored when unsupported.
15
+ """
16
+
17
+ height: int
18
+ width: int
19
+
20
+
21
+ @dataclass_with_extra
22
+ class ImageToImageParameters(BaseInferenceType):
23
+ """Additional inference parameters for Image To Image"""
24
+
25
+ guidance_scale: float | None = None
26
+ """For diffusion models. A higher guidance scale value encourages the model to generate
27
+ images closely linked to the text prompt at the expense of lower image quality.
28
+ """
29
+ negative_prompt: str | None = None
30
+ """One prompt to guide what NOT to include in image generation."""
31
+ num_inference_steps: int | None = None
32
+ """For diffusion models. The number of denoising steps. More denoising steps usually lead to
33
+ a higher quality image at the expense of slower inference.
34
+ """
35
+ prompt: str | None = None
36
+ """The text prompt to guide the image generation."""
37
+ target_size: ImageToImageTargetSize | None = None
38
+ """The size in pixels of the output image. This parameter is only supported by some
39
+ providers and for specific models. It will be ignored when unsupported.
40
+ """
41
+
42
+
43
+ @dataclass_with_extra
44
+ class ImageToImageInput(BaseInferenceType):
45
+ """Inputs for Image To Image inference"""
46
+
47
+ inputs: str
48
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
49
+ also provide the image data as a raw bytes payload.
50
+ """
51
+ parameters: ImageToImageParameters | None = None
52
+ """Additional inference parameters for Image To Image"""
53
+
54
+
55
+ @dataclass_with_extra
56
+ class ImageToImageOutput(BaseInferenceType):
57
+ """Outputs of inference for the Image To Image task"""
58
+
59
+ image: Any
60
+ """The output image returned as raw bytes in the payload."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/image_to_video.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class ImageToVideoTargetSize(BaseInferenceType):
13
+ """The size in pixel of the output video frames."""
14
+
15
+ height: int
16
+ width: int
17
+
18
+
19
+ @dataclass_with_extra
20
+ class ImageToVideoParameters(BaseInferenceType):
21
+ """Additional inference parameters for Image To Video"""
22
+
23
+ guidance_scale: float | None = None
24
+ """For diffusion models. A higher guidance scale value encourages the model to generate
25
+ videos closely linked to the text prompt at the expense of lower image quality.
26
+ """
27
+ negative_prompt: str | None = None
28
+ """One prompt to guide what NOT to include in video generation."""
29
+ num_frames: float | None = None
30
+ """The num_frames parameter determines how many video frames are generated."""
31
+ num_inference_steps: int | None = None
32
+ """The number of denoising steps. More denoising steps usually lead to a higher quality
33
+ video at the expense of slower inference.
34
+ """
35
+ prompt: str | None = None
36
+ """The text prompt to guide the video generation."""
37
+ seed: int | None = None
38
+ """Seed for the random number generator."""
39
+ target_size: ImageToVideoTargetSize | None = None
40
+ """The size in pixel of the output video frames."""
41
+
42
+
43
+ @dataclass_with_extra
44
+ class ImageToVideoInput(BaseInferenceType):
45
+ """Inputs for Image To Video inference"""
46
+
47
+ inputs: str
48
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
49
+ also provide the image data as a raw bytes payload.
50
+ """
51
+ parameters: ImageToVideoParameters | None = None
52
+ """Additional inference parameters for Image To Video"""
53
+
54
+
55
+ @dataclass_with_extra
56
+ class ImageToVideoOutput(BaseInferenceType):
57
+ """Outputs of inference for the Image To Video task"""
58
+
59
+ video: Any
60
+ """The generated video returned as raw bytes in the payload."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/object_detection.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from .base import BaseInferenceType, dataclass_with_extra
7
+
8
+
9
+ @dataclass_with_extra
10
+ class ObjectDetectionParameters(BaseInferenceType):
11
+ """Additional inference parameters for Object Detection"""
12
+
13
+ threshold: float | None = None
14
+ """The probability necessary to make a prediction."""
15
+
16
+
17
+ @dataclass_with_extra
18
+ class ObjectDetectionInput(BaseInferenceType):
19
+ """Inputs for Object Detection inference"""
20
+
21
+ inputs: str
22
+ """The input image data as a base64-encoded string. If no `parameters` are provided, you can
23
+ also provide the image data as a raw bytes payload.
24
+ """
25
+ parameters: ObjectDetectionParameters | None = None
26
+ """Additional inference parameters for Object Detection"""
27
+
28
+
29
+ @dataclass_with_extra
30
+ class ObjectDetectionBoundingBox(BaseInferenceType):
31
+ """The predicted bounding box. Coordinates are relative to the top left corner of the input
32
+ image.
33
+ """
34
+
35
+ xmax: int
36
+ """The x-coordinate of the bottom-right corner of the bounding box."""
37
+ xmin: int
38
+ """The x-coordinate of the top-left corner of the bounding box."""
39
+ ymax: int
40
+ """The y-coordinate of the bottom-right corner of the bounding box."""
41
+ ymin: int
42
+ """The y-coordinate of the top-left corner of the bounding box."""
43
+
44
+
45
+ @dataclass_with_extra
46
+ class ObjectDetectionOutputElement(BaseInferenceType):
47
+ """Outputs of inference for the Object Detection task"""
48
+
49
+ box: ObjectDetectionBoundingBox
50
+ """The predicted bounding box. Coordinates are relative to the top left corner of the input
51
+ image.
52
+ """
53
+ label: str
54
+ """The predicted label for the bounding box."""
55
+ score: float
56
+ """The associated score / probability."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/question_answering.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from .base import BaseInferenceType, dataclass_with_extra
7
+
8
+
9
+ @dataclass_with_extra
10
+ class QuestionAnsweringInputData(BaseInferenceType):
11
+ """One (context, question) pair to answer"""
12
+
13
+ context: str
14
+ """The context to be used for answering the question"""
15
+ question: str
16
+ """The question to be answered"""
17
+
18
+
19
+ @dataclass_with_extra
20
+ class QuestionAnsweringParameters(BaseInferenceType):
21
+ """Additional inference parameters for Question Answering"""
22
+
23
+ align_to_words: bool | None = None
24
+ """Attempts to align the answer to real words. Improves quality on space separated
25
+ languages. Might hurt on non-space-separated languages (like Japanese or Chinese)
26
+ """
27
+ doc_stride: int | None = None
28
+ """If the context is too long to fit with the question for the model, it will be split in
29
+ several chunks with some overlap. This argument controls the size of that overlap.
30
+ """
31
+ handle_impossible_answer: bool | None = None
32
+ """Whether to accept impossible as an answer."""
33
+ max_answer_len: int | None = None
34
+ """The maximum length of predicted answers (e.g., only answers with a shorter length are
35
+ considered).
36
+ """
37
+ max_question_len: int | None = None
38
+ """The maximum length of the question after tokenization. It will be truncated if needed."""
39
+ max_seq_len: int | None = None
40
+ """The maximum length of the total sentence (context + question) in tokens of each chunk
41
+ passed to the model. The context will be split in several chunks (using docStride as
42
+ overlap) if needed.
43
+ """
44
+ top_k: int | None = None
45
+ """The number of answers to return (will be chosen by order of likelihood). Note that we
46
+ return less than topk answers if there are not enough options available within the
47
+ context.
48
+ """
49
+
50
+
51
+ @dataclass_with_extra
52
+ class QuestionAnsweringInput(BaseInferenceType):
53
+ """Inputs for Question Answering inference"""
54
+
55
+ inputs: QuestionAnsweringInputData
56
+ """One (context, question) pair to answer"""
57
+ parameters: QuestionAnsweringParameters | None = None
58
+ """Additional inference parameters for Question Answering"""
59
+
60
+
61
+ @dataclass_with_extra
62
+ class QuestionAnsweringOutputElement(BaseInferenceType):
63
+ """Outputs of inference for the Question Answering task"""
64
+
65
+ answer: str
66
+ """The answer to the question."""
67
+ end: int
68
+ """The character position in the input where the answer ends."""
69
+ score: float
70
+ """The probability associated to the answer."""
71
+ start: int
72
+ """The character position in the input where the answer begins."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/sentence_similarity.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class SentenceSimilarityInputData(BaseInferenceType):
13
+ sentences: list[str]
14
+ """A list of strings which will be compared against the source_sentence."""
15
+ source_sentence: str
16
+ """The string that you wish to compare the other strings with. This can be a phrase,
17
+ sentence, or longer passage, depending on the model being used.
18
+ """
19
+
20
+
21
+ @dataclass_with_extra
22
+ class SentenceSimilarityInput(BaseInferenceType):
23
+ """Inputs for Sentence similarity inference"""
24
+
25
+ inputs: SentenceSimilarityInputData
26
+ parameters: dict[str, Any] | None = None
27
+ """Additional inference parameters for Sentence Similarity"""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/summarization.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any, Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ SummarizationTruncationStrategy = Literal["do_not_truncate", "longest_first", "only_first", "only_second"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class SummarizationParameters(BaseInferenceType):
16
+ """Additional inference parameters for summarization."""
17
+
18
+ clean_up_tokenization_spaces: bool | None = None
19
+ """Whether to clean up the potential extra spaces in the text output."""
20
+ generate_parameters: dict[str, Any] | None = None
21
+ """Additional parametrization of the text generation algorithm."""
22
+ truncation: Optional["SummarizationTruncationStrategy"] = None
23
+ """The truncation strategy to use."""
24
+
25
+
26
+ @dataclass_with_extra
27
+ class SummarizationInput(BaseInferenceType):
28
+ """Inputs for Summarization inference"""
29
+
30
+ inputs: str
31
+ """The input text to summarize."""
32
+ parameters: SummarizationParameters | None = None
33
+ """Additional inference parameters for summarization."""
34
+
35
+
36
+ @dataclass_with_extra
37
+ class SummarizationOutput(BaseInferenceType):
38
+ """Outputs of inference for the Summarization task"""
39
+
40
+ summary_text: str
41
+ """The summarized text."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/table_question_answering.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class TableQuestionAnsweringInputData(BaseInferenceType):
13
+ """One (table, question) pair to answer"""
14
+
15
+ question: str
16
+ """The question to be answered about the table"""
17
+ table: dict[str, list[str]]
18
+ """The table to serve as context for the questions"""
19
+
20
+
21
+ Padding = Literal["do_not_pad", "longest", "max_length"]
22
+
23
+
24
+ @dataclass_with_extra
25
+ class TableQuestionAnsweringParameters(BaseInferenceType):
26
+ """Additional inference parameters for Table Question Answering"""
27
+
28
+ padding: Optional["Padding"] = None
29
+ """Activates and controls padding."""
30
+ sequential: bool | None = None
31
+ """Whether to do inference sequentially or as a batch. Batching is faster, but models like
32
+ SQA require the inference to be done sequentially to extract relations within sequences,
33
+ given their conversational nature.
34
+ """
35
+ truncation: bool | None = None
36
+ """Activates and controls truncation."""
37
+
38
+
39
+ @dataclass_with_extra
40
+ class TableQuestionAnsweringInput(BaseInferenceType):
41
+ """Inputs for Table Question Answering inference"""
42
+
43
+ inputs: TableQuestionAnsweringInputData
44
+ """One (table, question) pair to answer"""
45
+ parameters: TableQuestionAnsweringParameters | None = None
46
+ """Additional inference parameters for Table Question Answering"""
47
+
48
+
49
+ @dataclass_with_extra
50
+ class TableQuestionAnsweringOutputElement(BaseInferenceType):
51
+ """Outputs of inference for the Table Question Answering task"""
52
+
53
+ answer: str
54
+ """The answer of the question given the table. If there is an aggregator, the answer will be
55
+ preceded by `AGGREGATOR >`.
56
+ """
57
+ cells: list[str]
58
+ """list of strings made up of the answer cell values."""
59
+ coordinates: list[list[int]]
60
+ """Coordinates of the cells of the answers."""
61
+ aggregator: str | None = None
62
+ """If the model has an aggregator, this returns the aggregator."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/text2text_generation.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any, Literal, Optional
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ Text2TextGenerationTruncationStrategy = Literal["do_not_truncate", "longest_first", "only_first", "only_second"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class Text2TextGenerationParameters(BaseInferenceType):
16
+ """Additional inference parameters for Text2text Generation"""
17
+
18
+ clean_up_tokenization_spaces: bool | None = None
19
+ """Whether to clean up the potential extra spaces in the text output."""
20
+ generate_parameters: dict[str, Any] | None = None
21
+ """Additional parametrization of the text generation algorithm"""
22
+ truncation: Optional["Text2TextGenerationTruncationStrategy"] = None
23
+ """The truncation strategy to use"""
24
+
25
+
26
+ @dataclass_with_extra
27
+ class Text2TextGenerationInput(BaseInferenceType):
28
+ """Inputs for Text2text Generation inference"""
29
+
30
+ inputs: str
31
+ """The input text data"""
32
+ parameters: Text2TextGenerationParameters | None = None
33
+ """Additional inference parameters for Text2text Generation"""
34
+
35
+
36
+ @dataclass_with_extra
37
+ class Text2TextGenerationOutput(BaseInferenceType):
38
+ """Outputs of inference for the Text2text Generation task"""
39
+
40
+ generated_text: Any
41
+ text2_text_generation_output_generated_text: str | None = None
42
+ """The generated text."""
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/text_generation.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any, Literal
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ TypeEnum = Literal["json", "regex", "json_schema"]
12
+
13
+
14
+ @dataclass_with_extra
15
+ class TextGenerationInputGrammarType(BaseInferenceType):
16
+ type: "TypeEnum"
17
+ value: Any
18
+ """A string that represents a [JSON Schema](https://json-schema.org/).
19
+ JSON Schema is a declarative language that allows to annotate JSON documents
20
+ with types and descriptions.
21
+ """
22
+
23
+
24
+ @dataclass_with_extra
25
+ class TextGenerationInputGenerateParameters(BaseInferenceType):
26
+ adapter_id: str | None = None
27
+ """Lora adapter id"""
28
+ best_of: int | None = None
29
+ """Generate best_of sequences and return the one if the highest token logprobs."""
30
+ decoder_input_details: bool | None = None
31
+ """Whether to return decoder input token logprobs and ids."""
32
+ details: bool | None = None
33
+ """Whether to return generation details."""
34
+ do_sample: bool | None = None
35
+ """Activate logits sampling."""
36
+ frequency_penalty: float | None = None
37
+ """The parameter for frequency penalty. 1.0 means no penalty
38
+ Penalize new tokens based on their existing frequency in the text so far,
39
+ decreasing the model's likelihood to repeat the same line verbatim.
40
+ """
41
+ grammar: TextGenerationInputGrammarType | None = None
42
+ max_new_tokens: int | None = None
43
+ """Maximum number of tokens to generate."""
44
+ repetition_penalty: float | None = None
45
+ """The parameter for repetition penalty. 1.0 means no penalty.
46
+ See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.
47
+ """
48
+ return_full_text: bool | None = None
49
+ """Whether to prepend the prompt to the generated text"""
50
+ seed: int | None = None
51
+ """Random sampling seed."""
52
+ stop: list[str] | None = None
53
+ """Stop generating tokens if a member of `stop` is generated."""
54
+ temperature: float | None = None
55
+ """The value used to module the logits distribution."""
56
+ top_k: int | None = None
57
+ """The number of highest probability vocabulary tokens to keep for top-k-filtering."""
58
+ top_n_tokens: int | None = None
59
+ """The number of highest probability vocabulary tokens to keep for top-n-filtering."""
60
+ top_p: float | None = None
61
+ """Top-p value for nucleus sampling."""
62
+ truncate: int | None = None
63
+ """Truncate inputs tokens to the given size."""
64
+ typical_p: float | None = None
65
+ """Typical Decoding mass
66
+ See [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666)
67
+ for more information.
68
+ """
69
+ watermark: bool | None = None
70
+ """Watermarking with [A Watermark for Large Language
71
+ Models](https://arxiv.org/abs/2301.10226).
72
+ """
73
+
74
+
75
+ @dataclass_with_extra
76
+ class TextGenerationInput(BaseInferenceType):
77
+ """Text Generation Input.
78
+ Auto-generated from TGI specs.
79
+ For more details, check out
80
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
81
+ """
82
+
83
+ inputs: str
84
+ parameters: TextGenerationInputGenerateParameters | None = None
85
+ stream: bool | None = None
86
+
87
+
88
+ TextGenerationOutputFinishReason = Literal["length", "eos_token", "stop_sequence"]
89
+
90
+
91
+ @dataclass_with_extra
92
+ class TextGenerationOutputPrefillToken(BaseInferenceType):
93
+ id: int
94
+ logprob: float
95
+ text: str
96
+
97
+
98
+ @dataclass_with_extra
99
+ class TextGenerationOutputToken(BaseInferenceType):
100
+ id: int
101
+ logprob: float
102
+ special: bool
103
+ text: str
104
+
105
+
106
+ @dataclass_with_extra
107
+ class TextGenerationOutputBestOfSequence(BaseInferenceType):
108
+ finish_reason: "TextGenerationOutputFinishReason"
109
+ generated_text: str
110
+ generated_tokens: int
111
+ prefill: list[TextGenerationOutputPrefillToken]
112
+ tokens: list[TextGenerationOutputToken]
113
+ seed: int | None = None
114
+ top_tokens: list[list[TextGenerationOutputToken]] | None = None
115
+
116
+
117
+ @dataclass_with_extra
118
+ class TextGenerationOutputDetails(BaseInferenceType):
119
+ finish_reason: "TextGenerationOutputFinishReason"
120
+ generated_tokens: int
121
+ prefill: list[TextGenerationOutputPrefillToken]
122
+ tokens: list[TextGenerationOutputToken]
123
+ best_of_sequences: list[TextGenerationOutputBestOfSequence] | None = None
124
+ seed: int | None = None
125
+ top_tokens: list[list[TextGenerationOutputToken]] | None = None
126
+
127
+
128
+ @dataclass_with_extra
129
+ class TextGenerationOutput(BaseInferenceType):
130
+ """Text Generation Output.
131
+ Auto-generated from TGI specs.
132
+ For more details, check out
133
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
134
+ """
135
+
136
+ generated_text: str
137
+ details: TextGenerationOutputDetails | None = None
138
+
139
+
140
+ @dataclass_with_extra
141
+ class TextGenerationStreamOutputStreamDetails(BaseInferenceType):
142
+ finish_reason: "TextGenerationOutputFinishReason"
143
+ generated_tokens: int
144
+ input_length: int
145
+ seed: int | None = None
146
+
147
+
148
+ @dataclass_with_extra
149
+ class TextGenerationStreamOutputToken(BaseInferenceType):
150
+ id: int
151
+ logprob: float
152
+ special: bool
153
+ text: str
154
+
155
+
156
+ @dataclass_with_extra
157
+ class TextGenerationStreamOutput(BaseInferenceType):
158
+ """Text Generation Stream Output.
159
+ Auto-generated from TGI specs.
160
+ For more details, check out
161
+ https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
162
+ """
163
+
164
+ index: int
165
+ token: TextGenerationStreamOutputToken
166
+ details: TextGenerationStreamOutputStreamDetails | None = None
167
+ generated_text: str | None = None
168
+ top_tokens: list[TextGenerationStreamOutputToken] | None = None
.cache/uv/archive-v0/4GZLBJvk803hh_euIbHls/huggingface_hub/inference/_generated/types/visual_question_answering.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inference code generated from the JSON schema spec in @huggingface/tasks.
2
+ #
3
+ # See:
4
+ # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
5
+ # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
6
+ from typing import Any
7
+
8
+ from .base import BaseInferenceType, dataclass_with_extra
9
+
10
+
11
+ @dataclass_with_extra
12
+ class VisualQuestionAnsweringInputData(BaseInferenceType):
13
+ """One (image, question) pair to answer"""
14
+
15
+ image: Any
16
+ """The image."""
17
+ question: str
18
+ """The question to answer based on the image."""
19
+
20
+
21
+ @dataclass_with_extra
22
+ class VisualQuestionAnsweringParameters(BaseInferenceType):
23
+ """Additional inference parameters for Visual Question Answering"""
24
+
25
+ top_k: int | None = None
26
+ """The number of answers to return (will be chosen by order of likelihood). Note that we
27
+ return less than topk answers if there are not enough options available within the
28
+ context.
29
+ """
30
+
31
+
32
+ @dataclass_with_extra
33
+ class VisualQuestionAnsweringInput(BaseInferenceType):
34
+ """Inputs for Visual Question Answering inference"""
35
+
36
+ inputs: VisualQuestionAnsweringInputData
37
+ """One (image, question) pair to answer"""
38
+ parameters: VisualQuestionAnsweringParameters | None = None
39
+ """Additional inference parameters for Visual Question Answering"""
40
+
41
+
42
+ @dataclass_with_extra
43
+ class VisualQuestionAnsweringOutputElement(BaseInferenceType):
44
+ """Outputs of inference for the Visual Question Answering task"""
45
+
46
+ score: float
47
+ """The associated score / probability"""
48
+ answer: str | None = None
49
+ """The answer to the question"""
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/METADATA ADDED
@@ -0,0 +1,1595 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: tqdm
3
+ Version: 4.67.3
4
+ Summary: Fast, Extensible Progress Meter
5
+ Maintainer-email: tqdm developers <devs@tqdm.ml>
6
+ License: MPL-2.0 AND MIT
7
+ Project-URL: homepage, https://tqdm.github.io
8
+ Project-URL: repository, https://github.com/tqdm/tqdm
9
+ Project-URL: changelog, https://tqdm.github.io/releases
10
+ Project-URL: wiki, https://github.com/tqdm/tqdm/wiki
11
+ Keywords: progressbar,progressmeter,progress,bar,meter,rate,eta,console,terminal,time
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Environment :: MacOS X
15
+ Classifier: Environment :: Other Environment
16
+ Classifier: Environment :: Win32 (MS Windows)
17
+ Classifier: Environment :: X11 Applications
18
+ Classifier: Framework :: IPython
19
+ Classifier: Framework :: Jupyter
20
+ Classifier: Intended Audience :: Developers
21
+ Classifier: Intended Audience :: Education
22
+ Classifier: Intended Audience :: End Users/Desktop
23
+ Classifier: Intended Audience :: Other Audience
24
+ Classifier: Intended Audience :: System Administrators
25
+ Classifier: Operating System :: MacOS
26
+ Classifier: Operating System :: MacOS :: MacOS X
27
+ Classifier: Operating System :: Microsoft
28
+ Classifier: Operating System :: Microsoft :: MS-DOS
29
+ Classifier: Operating System :: Microsoft :: Windows
30
+ Classifier: Operating System :: POSIX
31
+ Classifier: Operating System :: POSIX :: BSD
32
+ Classifier: Operating System :: POSIX :: BSD :: FreeBSD
33
+ Classifier: Operating System :: POSIX :: Linux
34
+ Classifier: Operating System :: POSIX :: SunOS/Solaris
35
+ Classifier: Operating System :: Unix
36
+ Classifier: Programming Language :: Python
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.7
39
+ Classifier: Programming Language :: Python :: 3.8
40
+ Classifier: Programming Language :: Python :: 3.9
41
+ Classifier: Programming Language :: Python :: 3.10
42
+ Classifier: Programming Language :: Python :: 3.11
43
+ Classifier: Programming Language :: Python :: 3.12
44
+ Classifier: Programming Language :: Python :: 3.13
45
+ Classifier: Programming Language :: Python :: 3 :: Only
46
+ Classifier: Programming Language :: Python :: Implementation
47
+ Classifier: Programming Language :: Python :: Implementation :: IronPython
48
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
49
+ Classifier: Programming Language :: Unix Shell
50
+ Classifier: Topic :: Desktop Environment
51
+ Classifier: Topic :: Education :: Computer Aided Instruction (CAI)
52
+ Classifier: Topic :: Education :: Testing
53
+ Classifier: Topic :: Office/Business
54
+ Classifier: Topic :: Other/Nonlisted Topic
55
+ Classifier: Topic :: Software Development :: Build Tools
56
+ Classifier: Topic :: Software Development :: Libraries
57
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
58
+ Classifier: Topic :: Software Development :: Pre-processors
59
+ Classifier: Topic :: Software Development :: User Interfaces
60
+ Classifier: Topic :: System :: Installation/Setup
61
+ Classifier: Topic :: System :: Logging
62
+ Classifier: Topic :: System :: Monitoring
63
+ Classifier: Topic :: System :: Shells
64
+ Classifier: Topic :: Terminals
65
+ Classifier: Topic :: Utilities
66
+ Requires-Python: >=3.7
67
+ Description-Content-Type: text/x-rst
68
+ License-File: LICENCE
69
+ Requires-Dist: colorama; platform_system == "Windows"
70
+ Requires-Dist: importlib_metadata; python_version < "3.8"
71
+ Provides-Extra: dev
72
+ Requires-Dist: pytest>=6; extra == "dev"
73
+ Requires-Dist: pytest-cov; extra == "dev"
74
+ Requires-Dist: pytest-timeout; extra == "dev"
75
+ Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
76
+ Requires-Dist: nbval; extra == "dev"
77
+ Provides-Extra: discord
78
+ Requires-Dist: requests; extra == "discord"
79
+ Provides-Extra: slack
80
+ Requires-Dist: slack-sdk; extra == "slack"
81
+ Provides-Extra: telegram
82
+ Requires-Dist: requests; extra == "telegram"
83
+ Provides-Extra: notebook
84
+ Requires-Dist: ipywidgets>=6; extra == "notebook"
85
+ Dynamic: license-file
86
+
87
+ |Logo|
88
+
89
+ tqdm
90
+ ====
91
+
92
+ |Py-Versions| |Versions| |Conda-Forge-Status| |Docker| |Snapcraft|
93
+
94
+ |Build-Status| |Coverage-Status| |Branch-Coverage-Status| |Codacy-Grade| |Libraries-Rank| |PyPI-Downloads|
95
+
96
+ |LICENCE| |OpenHub-Status| |binder-demo| |awesome-python|
97
+
98
+ ``tqdm`` derives from the Arabic word *taqaddum* (تقدّم) which can mean "progress,"
99
+ and is an abbreviation for "I love you so much" in Spanish (*te quiero demasiado*).
100
+
101
+ Instantly make your loops show a smart progress meter - just wrap any
102
+ iterable with ``tqdm(iterable)``, and you're done!
103
+
104
+ .. code:: python
105
+
106
+ from tqdm import tqdm
107
+ for i in tqdm(range(10000)):
108
+ ...
109
+
110
+ ``76%|████████████████████████        | 7568/10000 [00:33<00:10, 229.00it/s]``
111
+
112
+ ``trange(N)`` can be also used as a convenient shortcut for
113
+ ``tqdm(range(N))``.
114
+
115
+ |Screenshot|
116
+ |Video| |Slides| |Merch|
117
+
118
+ It can also be executed as a module with pipes:
119
+
120
+ .. code:: sh
121
+
122
+ $ seq 9999999 | tqdm --bytes | wc -l
123
+ 75.2MB [00:00, 217MB/s]
124
+ 9999999
125
+
126
+ $ tar -zcf - docs/ | tqdm --bytes --total `du -sb docs/ | cut -f1` \
127
+ > backup.tgz
128
+ 32%|██████████▍ | 8.89G/27.9G [00:42<01:31, 223MB/s]
129
+
130
+ Overhead is low -- about 60ns per iteration (80ns with ``tqdm.gui``), and is
131
+ unit tested against performance regression.
132
+ By comparison, the well-established
133
+ `ProgressBar <https://github.com/niltonvolpato/python-progressbar>`__ has
134
+ an 800ns/iter overhead.
135
+
136
+ In addition to its low overhead, ``tqdm`` uses smart algorithms to predict
137
+ the remaining time and to skip unnecessary iteration displays, which allows
138
+ for a negligible overhead in most cases.
139
+
140
+ ``tqdm`` works on any platform
141
+ (Linux, Windows, Mac, FreeBSD, NetBSD, Solaris/SunOS),
142
+ in any console or in a GUI, and is also friendly with IPython/Jupyter notebooks.
143
+
144
+ ``tqdm`` does not require any dependencies (not even ``curses``!), just
145
+ Python and an environment supporting ``carriage return \r`` and
146
+ ``line feed \n`` control characters.
147
+
148
+ ------------------------------------------
149
+
150
+ .. contents:: Table of contents
151
+ :backlinks: top
152
+ :local:
153
+
154
+
155
+ Installation
156
+ ------------
157
+
158
+ Latest PyPI stable release
159
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
160
+
161
+ |Versions| |PyPI-Downloads| |Libraries-Dependents|
162
+
163
+ .. code:: sh
164
+
165
+ pip install tqdm
166
+
167
+ Latest development release on GitHub
168
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169
+
170
+ |GitHub-Status| |GitHub-Stars| |GitHub-Commits| |GitHub-Forks| |GitHub-Updated|
171
+
172
+ Pull and install pre-release ``devel`` branch:
173
+
174
+ .. code:: sh
175
+
176
+ pip install "git+https://github.com/tqdm/tqdm.git@devel#egg=tqdm"
177
+
178
+ Latest Conda release
179
+ ~~~~~~~~~~~~~~~~~~~~
180
+
181
+ |Conda-Forge-Status|
182
+
183
+ .. code:: sh
184
+
185
+ conda install -c conda-forge tqdm
186
+
187
+ Latest Snapcraft release
188
+ ~~~~~~~~~~~~~~~~~~~~~~~~
189
+
190
+ |Snapcraft|
191
+
192
+ There are 3 channels to choose from:
193
+
194
+ .. code:: sh
195
+
196
+ snap install tqdm # implies --stable, i.e. latest tagged release
197
+ snap install tqdm --candidate # master branch
198
+ snap install tqdm --edge # devel branch
199
+
200
+ Note that ``snap`` binaries are purely for CLI use (not ``import``-able), and
201
+ automatically set up ``bash`` tab-completion.
202
+
203
+ Latest Docker release
204
+ ~~~~~~~~~~~~~~~~~~~~~
205
+
206
+ |Docker|
207
+
208
+ .. code:: sh
209
+
210
+ docker pull tqdm/tqdm
211
+ docker run -i --rm tqdm/tqdm --help
212
+
213
+ Other
214
+ ~~~~~
215
+
216
+ There are other (unofficial) places where ``tqdm`` may be downloaded, particularly for CLI use:
217
+
218
+ |Repology|
219
+
220
+ .. |Repology| image:: https://repology.org/badge/tiny-repos/python:tqdm.svg
221
+ :target: https://repology.org/project/python:tqdm/versions
222
+
223
+ Changelog
224
+ ---------
225
+
226
+ The list of all changes is available either on GitHub's Releases:
227
+ |GitHub-Status|, on the
228
+ `wiki <https://github.com/tqdm/tqdm/wiki/Releases>`__, or on the
229
+ `website <https://tqdm.github.io/releases>`__.
230
+
231
+
232
+ Usage
233
+ -----
234
+
235
+ ``tqdm`` is very versatile and can be used in a number of ways.
236
+ The three main ones are given below.
237
+
238
+ Iterable-based
239
+ ~~~~~~~~~~~~~~
240
+
241
+ Wrap ``tqdm()`` around any iterable:
242
+
243
+ .. code:: python
244
+
245
+ from tqdm import tqdm
246
+ from time import sleep
247
+
248
+ text = ""
249
+ for char in tqdm(["a", "b", "c", "d"]):
250
+ sleep(0.25)
251
+ text = text + char
252
+
253
+ ``trange(i)`` is a special optimised instance of ``tqdm(range(i))``:
254
+
255
+ .. code:: python
256
+
257
+ from tqdm import trange
258
+
259
+ for i in trange(100):
260
+ sleep(0.01)
261
+
262
+ Instantiation outside of the loop allows for manual control over ``tqdm()``:
263
+
264
+ .. code:: python
265
+
266
+ pbar = tqdm(["a", "b", "c", "d"])
267
+ for char in pbar:
268
+ sleep(0.25)
269
+ pbar.set_description("Processing %s" % char)
270
+
271
+ Manual
272
+ ~~~~~~
273
+
274
+ Manual control of ``tqdm()`` updates using a ``with`` statement:
275
+
276
+ .. code:: python
277
+
278
+ with tqdm(total=100) as pbar:
279
+ for i in range(10):
280
+ sleep(0.1)
281
+ pbar.update(10)
282
+
283
+ If the optional variable ``total`` (or an iterable with ``len()``) is
284
+ provided, predictive stats are displayed.
285
+
286
+ ``with`` is also optional (you can just assign ``tqdm()`` to a variable,
287
+ but in this case don't forget to ``del`` or ``close()`` at the end:
288
+
289
+ .. code:: python
290
+
291
+ pbar = tqdm(total=100)
292
+ for i in range(10):
293
+ sleep(0.1)
294
+ pbar.update(10)
295
+ pbar.close()
296
+
297
+ Module
298
+ ~~~~~~
299
+
300
+ Perhaps the most wonderful use of ``tqdm`` is in a script or on the command
301
+ line. Simply inserting ``tqdm`` (or ``python -m tqdm``) between pipes will pass
302
+ through all ``stdin`` to ``stdout`` while printing progress to ``stderr``.
303
+
304
+ The example below demonstrate counting the number of lines in all Python files
305
+ in the current directory, with timing information included.
306
+
307
+ .. code:: sh
308
+
309
+ $ time find . -name '*.py' -type f -exec cat \{} \; | wc -l
310
+ 857365
311
+
312
+ real 0m3.458s
313
+ user 0m0.274s
314
+ sys 0m3.325s
315
+
316
+ $ time find . -name '*.py' -type f -exec cat \{} \; | tqdm | wc -l
317
+ 857366it [00:03, 246471.31it/s]
318
+ 857365
319
+
320
+ real 0m3.585s
321
+ user 0m0.862s
322
+ sys 0m3.358s
323
+
324
+ Note that the usual arguments for ``tqdm`` can also be specified.
325
+
326
+ .. code:: sh
327
+
328
+ $ find . -name '*.py' -type f -exec cat \{} \; |
329
+ tqdm --unit loc --unit_scale --total 857366 >> /dev/null
330
+ 100%|█████████████████████████████████| 857K/857K [00:04<00:00, 246Kloc/s]
331
+
332
+ Backing up a large directory?
333
+
334
+ .. code:: sh
335
+
336
+ $ tar -zcf - docs/ | tqdm --bytes --total `du -sb docs/ | cut -f1` \
337
+ > backup.tgz
338
+ 44%|██████████████▊ | 153M/352M [00:14<00:18, 11.0MB/s]
339
+
340
+ This can be beautified further:
341
+
342
+ .. code:: sh
343
+
344
+ $ BYTES=$(du -sb docs/ | cut -f1)
345
+ $ tar -cf - docs/ \
346
+ | tqdm --bytes --total "$BYTES" --desc Processing | gzip \
347
+ | tqdm --bytes --total "$BYTES" --desc Compressed --position 1 \
348
+ > ~/backup.tgz
349
+ Processing: 100%|██████████████████████| 352M/352M [00:14<00:00, 30.2MB/s]
350
+ Compressed: 42%|█████████▎ | 148M/352M [00:14<00:19, 10.9MB/s]
351
+
352
+ Or done on a file level using 7-zip:
353
+
354
+ .. code:: sh
355
+
356
+ $ 7z a -bd -r backup.7z docs/ | grep Compressing \
357
+ | tqdm --total $(find docs/ -type f | wc -l) --unit files \
358
+ | grep -v Compressing
359
+ 100%|██████████████████████████▉| 15327/15327 [01:00<00:00, 712.96files/s]
360
+
361
+ Pre-existing CLI programs already outputting basic progress information will
362
+ benefit from ``tqdm``'s ``--update`` and ``--update_to`` flags:
363
+
364
+ .. code:: sh
365
+
366
+ $ seq 3 0.1 5 | tqdm --total 5 --update_to --null
367
+ 100%|████████████████████████████████████| 5.0/5 [00:00<00:00, 9673.21it/s]
368
+ $ seq 10 | tqdm --update --null # 1 + 2 + ... + 10 = 55 iterations
369
+ 55it [00:00, 90006.52it/s]
370
+
371
+ FAQ and Known Issues
372
+ --------------------
373
+
374
+ |GitHub-Issues|
375
+
376
+ The most common issues relate to excessive output on multiple lines, instead
377
+ of a neat one-line progress bar.
378
+
379
+ - Consoles in general: require support for carriage return (``CR``, ``\r``).
380
+
381
+ * Some cloud logging consoles which don't support ``\r`` properly
382
+ (`cloudwatch <https://github.com/tqdm/tqdm/issues/966>`__,
383
+ `K8s <https://github.com/tqdm/tqdm/issues/1319>`__) may benefit from
384
+ ``export TQDM_POSITION=-1``.
385
+
386
+ - Nested progress bars:
387
+
388
+ * Consoles in general: require support for moving cursors up to the
389
+ previous line. For example,
390
+ `IDLE <https://github.com/tqdm/tqdm/issues/191#issuecomment-230168030>`__,
391
+ `ConEmu <https://github.com/tqdm/tqdm/issues/254>`__ and
392
+ `PyCharm <https://github.com/tqdm/tqdm/issues/203>`__ (also
393
+ `here <https://github.com/tqdm/tqdm/issues/208>`__,
394
+ `here <https://github.com/tqdm/tqdm/issues/307>`__, and
395
+ `here <https://github.com/tqdm/tqdm/issues/454#issuecomment-335416815>`__)
396
+ lack full support.
397
+ * Windows: additionally may require the Python module ``colorama``
398
+ to ensure nested bars stay within their respective lines.
399
+
400
+ - Unicode:
401
+
402
+ * Environments which report that they support unicode will have solid smooth
403
+ progressbars. The fallback is an ``ascii``-only bar.
404
+ * Windows consoles often only partially support unicode and thus
405
+ `often require explicit ascii=True <https://github.com/tqdm/tqdm/issues/454#issuecomment-335416815>`__
406
+ (also `here <https://github.com/tqdm/tqdm/issues/499>`__). This is due to
407
+ either normal-width unicode characters being incorrectly displayed as
408
+ "wide", or some unicode characters not rendering.
409
+
410
+ - Wrapping generators:
411
+
412
+ * Generator wrapper functions tend to hide the length of iterables.
413
+ ``tqdm`` does not.
414
+ * Replace ``tqdm(enumerate(...))`` with ``enumerate(tqdm(...))`` or
415
+ ``tqdm(enumerate(x), total=len(x), ...)``.
416
+ The same applies to ``numpy.ndenumerate``.
417
+ * Replace ``tqdm(zip(a, b))`` with ``zip(tqdm(a), b)`` or even
418
+ ``zip(tqdm(a), tqdm(b))``.
419
+ * The same applies to ``itertools``.
420
+ * Some useful convenience functions can be found under ``tqdm.contrib``.
421
+
422
+ - `No intermediate output in docker-compose <https://github.com/tqdm/tqdm/issues/771>`__:
423
+ use ``docker-compose run`` instead of ``docker-compose up`` and ``tty: true``.
424
+
425
+ - Overriding defaults via environment variables:
426
+ e.g. in CI/cloud jobs, ``export TQDM_MININTERVAL=5`` to avoid log spam.
427
+ This override logic is handled by the ``tqdm.utils.envwrap`` decorator
428
+ (useful independent of ``tqdm``).
429
+
430
+ If you come across any other difficulties, browse and file |GitHub-Issues|.
431
+
432
+ Documentation
433
+ -------------
434
+
435
+ |Py-Versions| |README-Hits| (Since 19 May 2016)
436
+
437
+ .. code:: python
438
+
439
+ class tqdm():
440
+ """
441
+ Decorate an iterable object, returning an iterator which acts exactly
442
+ like the original iterable, but prints a dynamically updating
443
+ progressbar every time a value is requested.
444
+ """
445
+
446
+ @envwrap("TQDM_") # override defaults via env vars
447
+ def __init__(self, iterable=None, desc=None, total=None, leave=True,
448
+ file=None, ncols=None, mininterval=0.1,
449
+ maxinterval=10.0, miniters=None, ascii=None, disable=False,
450
+ unit='it', unit_scale=False, dynamic_ncols=False,
451
+ smoothing=0.3, bar_format=None, initial=0, position=None,
452
+ postfix=None, unit_divisor=1000, write_bytes=False,
453
+ lock_args=None, nrows=None, colour=None, delay=0):
454
+
455
+ Parameters
456
+ ~~~~~~~~~~
457
+
458
+ * iterable : iterable, optional
459
+ Iterable to decorate with a progressbar.
460
+ Leave blank to manually manage the updates.
461
+ * desc : str, optional
462
+ Prefix for the progressbar.
463
+ * total : int or float, optional
464
+ The number of expected iterations. If unspecified,
465
+ len(iterable) is used if possible. If float("inf") or as a last
466
+ resort, only basic progress statistics are displayed
467
+ (no ETA, no progressbar).
468
+ If ``gui`` is True and this parameter needs subsequent updating,
469
+ specify an initial arbitrary large positive number,
470
+ e.g. 9e9.
471
+ * leave : bool, optional
472
+ If [default: True], keeps all traces of the progressbar
473
+ upon termination of iteration.
474
+ If ``None``, will leave only if ``position`` is ``0``.
475
+ * file : ``io.TextIOWrapper`` or ``io.StringIO``, optional
476
+ Specifies where to output the progress messages
477
+ (default: sys.stderr). Uses ``file.write(str)`` and ``file.flush()``
478
+ methods. For encoding, see ``write_bytes``.
479
+ * ncols : int, optional
480
+ The width of the entire output message. If specified,
481
+ dynamically resizes the progressbar to stay within this bound.
482
+ If unspecified, attempts to use environment width. The
483
+ fallback is a meter width of 10 and no limit for the counter and
484
+ statistics. If 0, will not print any meter (only stats).
485
+ * mininterval : float, optional
486
+ Minimum progress display update interval [default: 0.1] seconds.
487
+ * maxinterval : float, optional
488
+ Maximum progress display update interval [default: 10] seconds.
489
+ Automatically adjusts ``miniters`` to correspond to ``mininterval``
490
+ after long display update lag. Only works if ``dynamic_miniters``
491
+ or monitor thread is enabled.
492
+ * miniters : int or float, optional
493
+ Minimum progress display update interval, in iterations.
494
+ If 0 and ``dynamic_miniters``, will automatically adjust to equal
495
+ ``mininterval`` (more CPU efficient, good for tight loops).
496
+ If > 0, will skip display of specified number of iterations.
497
+ Tweak this and ``mininterval`` to get very efficient loops.
498
+ If your progress is erratic with both fast and slow iterations
499
+ (network, skipping items, etc) you should set miniters=1.
500
+ * ascii : bool or str, optional
501
+ If unspecified or False, use unicode (smooth blocks) to fill
502
+ the meter. The fallback is to use ASCII characters " 123456789#".
503
+ * disable : bool, optional
504
+ Whether to disable the entire progressbar wrapper
505
+ [default: False]. If set to None, disable on non-TTY.
506
+ * unit : str, optional
507
+ String that will be used to define the unit of each iteration
508
+ [default: it].
509
+ * unit_scale : bool or int or float, optional
510
+ If 1 or True, the number of iterations will be reduced/scaled
511
+ automatically and a metric prefix following the
512
+ International System of Units standard will be added
513
+ (kilo, mega, etc.) [default: False]. If any other non-zero
514
+ number, will scale ``total`` and ``n``.
515
+ * dynamic_ncols : bool, optional
516
+ If set, constantly alters ``ncols`` and ``nrows`` to the
517
+ environment (allowing for window resizes) [default: False].
518
+ * smoothing : float, optional
519
+ Exponential moving average smoothing factor for speed estimates
520
+ (ignored in GUI mode). Ranges from 0 (average speed) to 1
521
+ (current/instantaneous speed) [default: 0.3].
522
+ * bar_format : str, optional
523
+ Specify a custom bar string formatting. May impact performance.
524
+ [default: '{l_bar}{bar}{r_bar}'], where
525
+ l_bar='{desc}: {percentage:3.0f}%|' and
526
+ r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
527
+ '{rate_fmt}{postfix}]'
528
+ Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
529
+ percentage, elapsed, elapsed_s, ncols, nrows, desc, unit,
530
+ rate, rate_fmt, rate_noinv, rate_noinv_fmt,
531
+ rate_inv, rate_inv_fmt, postfix, unit_divisor,
532
+ remaining, remaining_s, eta.
533
+ Note that a trailing ": " is automatically removed after {desc}
534
+ if the latter is empty.
535
+ * initial : int or float, optional
536
+ The initial counter value. Useful when restarting a progress
537
+ bar [default: 0]. If using float, consider specifying ``{n:.3f}``
538
+ or similar in ``bar_format``, or specifying ``unit_scale``.
539
+ * position : int, optional
540
+ Specify the line offset to print this bar (starting from 0)
541
+ Automatic if unspecified.
542
+ Useful to manage multiple bars at once (eg, from threads).
543
+ * postfix : dict or ``*``, optional
544
+ Specify additional stats to display at the end of the bar.
545
+ Calls ``set_postfix(**postfix)`` if possible (dict).
546
+ * unit_divisor : float, optional
547
+ [default: 1000], ignored unless ``unit_scale`` is True.
548
+ * write_bytes : bool, optional
549
+ Whether to write bytes. If (default: False) will write unicode.
550
+ * lock_args : tuple, optional
551
+ Passed to ``refresh`` for intermediate output
552
+ (initialisation, iterating, and updating).
553
+ * nrows : int, optional
554
+ The screen height. If specified, hides nested bars outside this
555
+ bound. If unspecified, attempts to use environment height.
556
+ The fallback is 20.
557
+ * colour : str, optional
558
+ Bar colour (e.g. 'green', '#00ff00').
559
+ * delay : float, optional
560
+ Don't display until [default: 0] seconds have elapsed.
561
+
562
+ Extra CLI Options
563
+ ~~~~~~~~~~~~~~~~~
564
+
565
+ * delim : chr, optional
566
+ Delimiting character [default: '\n']. Use '\0' for null.
567
+ N.B.: on Windows systems, Python converts '\n' to '\r\n'.
568
+ * buf_size : int, optional
569
+ String buffer size in bytes [default: 256]
570
+ used when ``delim`` is specified.
571
+ * bytes : bool, optional
572
+ If true, will count bytes, ignore ``delim``, and default
573
+ ``unit_scale`` to True, ``unit_divisor`` to 1024, and ``unit`` to 'B'.
574
+ * tee : bool, optional
575
+ If true, passes ``stdin`` to both ``stderr`` and ``stdout``.
576
+ * update : bool, optional
577
+ If true, will treat input as newly elapsed iterations,
578
+ i.e. numbers to pass to ``update()``. Note that this is slow
579
+ (~2e5 it/s) since every input must be decoded as a number.
580
+ * update_to : bool, optional
581
+ If true, will treat input as total elapsed iterations,
582
+ i.e. numbers to assign to ``self.n``. Note that this is slow
583
+ (~2e5 it/s) since every input must be decoded as a number.
584
+ * null : bool, optional
585
+ If true, will discard input (no stdout).
586
+ * manpath : str, optional
587
+ Directory in which to install tqdm man pages.
588
+ * comppath : str, optional
589
+ Directory in which to place tqdm completion.
590
+ * log : str, optional
591
+ CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET.
592
+
593
+ Returns
594
+ ~~~~~~~
595
+
596
+ * out : decorated iterator.
597
+
598
+ .. code:: python
599
+
600
+ class tqdm():
601
+ def update(self, n=1):
602
+ """
603
+ Manually update the progress bar, useful for streams
604
+ such as reading files.
605
+ E.g.:
606
+ >>> t = tqdm(total=filesize) # Initialise
607
+ >>> for current_buffer in stream:
608
+ ... ...
609
+ ... t.update(len(current_buffer))
610
+ >>> t.close()
611
+ The last line is highly recommended, but possibly not necessary if
612
+ ``t.update()`` will be called in such a way that ``filesize`` will be
613
+ exactly reached and printed.
614
+
615
+ Parameters
616
+ ----------
617
+ n : int or float, optional
618
+ Increment to add to the internal counter of iterations
619
+ [default: 1]. If using float, consider specifying ``{n:.3f}``
620
+ or similar in ``bar_format``, or specifying ``unit_scale``.
621
+
622
+ Returns
623
+ -------
624
+ out : bool or None
625
+ True if a ``display()`` was triggered.
626
+ """
627
+
628
+ def close(self):
629
+ """Cleanup and (if leave=False) close the progressbar."""
630
+
631
+ def clear(self, nomove=False):
632
+ """Clear current bar display."""
633
+
634
+ def refresh(self):
635
+ """
636
+ Force refresh the display of this bar.
637
+
638
+ Parameters
639
+ ----------
640
+ nolock : bool, optional
641
+ If ``True``, does not lock.
642
+ If [default: ``False``]: calls ``acquire()`` on internal lock.
643
+ lock_args : tuple, optional
644
+ Passed to internal lock's ``acquire()``.
645
+ If specified, will only ``display()`` if ``acquire()`` returns ``True``.
646
+ """
647
+
648
+ def unpause(self):
649
+ """Restart tqdm timer from last print time."""
650
+
651
+ def reset(self, total=None):
652
+ """
653
+ Resets to 0 iterations for repeated use.
654
+
655
+ Consider combining with ``leave=True``.
656
+
657
+ Parameters
658
+ ----------
659
+ total : int or float, optional. Total to use for the new bar.
660
+ """
661
+
662
+ def set_description(self, desc=None, refresh=True):
663
+ """
664
+ Set/modify description of the progress bar.
665
+
666
+ Parameters
667
+ ----------
668
+ desc : str, optional
669
+ refresh : bool, optional
670
+ Forces refresh [default: True].
671
+ """
672
+
673
+ def set_postfix(self, ordered_dict=None, refresh=True, **tqdm_kwargs):
674
+ """
675
+ Set/modify postfix (additional stats)
676
+ with automatic formatting based on datatype.
677
+
678
+ Parameters
679
+ ----------
680
+ ordered_dict : dict or OrderedDict, optional
681
+ refresh : bool, optional
682
+ Forces refresh [default: True].
683
+ kwargs : dict, optional
684
+ """
685
+
686
+ @classmethod
687
+ def write(cls, s, file=sys.stdout, end="\n"):
688
+ """Print a message via tqdm (without overlap with bars)."""
689
+
690
+ @property
691
+ def format_dict(self):
692
+ """Public API for read-only member access."""
693
+
694
+ def display(self, msg=None, pos=None):
695
+ """
696
+ Use ``self.sp`` to display ``msg`` in the specified ``pos``.
697
+
698
+ Consider overloading this function when inheriting to use e.g.:
699
+ ``self.some_frontend(**self.format_dict)`` instead of ``self.sp``.
700
+
701
+ Parameters
702
+ ----------
703
+ msg : str, optional. What to display (default: ``repr(self)``).
704
+ pos : int, optional. Position to ``moveto``
705
+ (default: ``abs(self.pos)``).
706
+ """
707
+
708
+ @classmethod
709
+ @contextmanager
710
+ def wrapattr(cls, stream, method, total=None, bytes=True, **tqdm_kwargs):
711
+ """
712
+ stream : file-like object.
713
+ method : str, "read" or "write". The result of ``read()`` and
714
+ the first argument of ``write()`` should have a ``len()``.
715
+
716
+ >>> with tqdm.wrapattr(file_obj, "read", total=file_obj.size) as fobj:
717
+ ... while True:
718
+ ... chunk = fobj.read(chunk_size)
719
+ ... if not chunk:
720
+ ... break
721
+ """
722
+
723
+ @classmethod
724
+ def pandas(cls, *targs, **tqdm_kwargs):
725
+ """Registers the current `tqdm` class with `pandas`."""
726
+
727
+ def trange(*args, **tqdm_kwargs):
728
+ """Shortcut for `tqdm(range(*args), **tqdm_kwargs)`."""
729
+
730
+ Convenience Functions
731
+ ~~~~~~~~~~~~~~~~~~~~~
732
+
733
+ .. code:: python
734
+
735
+ def tqdm.contrib.tenumerate(iterable, start=0, total=None,
736
+ tqdm_class=tqdm.auto.tqdm, **tqdm_kwargs):
737
+ """Equivalent of `numpy.ndenumerate` or builtin `enumerate`."""
738
+
739
+ def tqdm.contrib.tzip(iter1, *iter2plus, **tqdm_kwargs):
740
+ """Equivalent of builtin `zip`."""
741
+
742
+ def tqdm.contrib.tmap(function, *sequences, **tqdm_kwargs):
743
+ """Equivalent of builtin `map`."""
744
+
745
+ Submodules
746
+ ~~~~~~~~~~
747
+
748
+ .. code:: python
749
+
750
+ class tqdm.notebook.tqdm(tqdm.tqdm):
751
+ """IPython/Jupyter Notebook widget."""
752
+
753
+ class tqdm.auto.tqdm(tqdm.tqdm):
754
+ """Automatically chooses beween `tqdm.notebook` and `tqdm.tqdm`."""
755
+
756
+ class tqdm.asyncio.tqdm(tqdm.tqdm):
757
+ """Asynchronous version."""
758
+ @classmethod
759
+ def as_completed(cls, fs, *, loop=None, timeout=None, total=None,
760
+ **tqdm_kwargs):
761
+ """Wrapper for `asyncio.as_completed`."""
762
+
763
+ class tqdm.gui.tqdm(tqdm.tqdm):
764
+ """Matplotlib GUI version."""
765
+
766
+ class tqdm.tk.tqdm(tqdm.tqdm):
767
+ """Tkinter GUI version."""
768
+
769
+ class tqdm.rich.tqdm(tqdm.tqdm):
770
+ """`rich.progress` version."""
771
+
772
+ class tqdm.keras.TqdmCallback(keras.callbacks.Callback):
773
+ """Keras callback for epoch and batch progress."""
774
+
775
+ class tqdm.dask.TqdmCallback(dask.callbacks.Callback):
776
+ """Dask callback for task progress."""
777
+
778
+
779
+ ``contrib``
780
+ +++++++++++
781
+
782
+ The ``tqdm.contrib`` package also contains experimental modules:
783
+
784
+ - ``tqdm.contrib.itertools``: Thin wrappers around ``itertools``
785
+ - ``tqdm.contrib.concurrent``: Thin wrappers around ``concurrent.futures``
786
+ - ``tqdm.contrib.slack``: Posts to `Slack <https://slack.com>`__ bots
787
+ - ``tqdm.contrib.discord``: Posts to `Discord <https://discord.com>`__ bots
788
+ - ``tqdm.contrib.telegram``: Posts to `Telegram <https://telegram.org>`__ bots
789
+ - ``tqdm.contrib.bells``: Automagically enables all optional features
790
+
791
+ * ``auto``, ``pandas``, ``slack``, ``discord``, ``telegram``
792
+
793
+ Examples and Advanced Usage
794
+ ---------------------------
795
+
796
+ - See the `examples <https://github.com/tqdm/tqdm/tree/master/examples>`__
797
+ folder;
798
+ - import the module and run ``help()``;
799
+ - consult the `wiki <https://github.com/tqdm/tqdm/wiki>`__;
800
+
801
+ * this has an
802
+ `excellent article <https://github.com/tqdm/tqdm/wiki/How-to-make-a-great-Progress-Bar>`__
803
+ on how to make a **great** progressbar;
804
+
805
+ - check out the `slides from PyData London <https://tqdm.github.io/PyData2019/slides.html>`__, or
806
+ - run the |binder-demo|.
807
+
808
+ Description and additional stats
809
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
810
+
811
+ Custom information can be displayed and updated dynamically on ``tqdm`` bars
812
+ with the ``desc`` and ``postfix`` arguments:
813
+
814
+ .. code:: python
815
+
816
+ from tqdm import tqdm, trange
817
+ from random import random, randint
818
+ from time import sleep
819
+
820
+ with trange(10) as t:
821
+ for i in t:
822
+ # Description will be displayed on the left
823
+ t.set_description('GEN %i' % i)
824
+ # Postfix will be displayed on the right,
825
+ # formatted automatically based on argument's datatype
826
+ t.set_postfix(loss=random(), gen=randint(1,999), str='h',
827
+ lst=[1, 2])
828
+ sleep(0.1)
829
+
830
+ with tqdm(total=10, bar_format="{postfix[0]} {postfix[1][value]:>8.2g}",
831
+ postfix=["Batch", {"value": 0}]) as t:
832
+ for i in range(10):
833
+ sleep(0.1)
834
+ t.postfix[1]["value"] = i / 2
835
+ t.update()
836
+
837
+ Points to remember when using ``{postfix[...]}`` in the ``bar_format`` string:
838
+
839
+ - ``postfix`` also needs to be passed as an initial argument in a compatible
840
+ format, and
841
+ - ``postfix`` will be auto-converted to a string if it is a ``dict``-like
842
+ object. To prevent this behaviour, insert an extra item into the dictionary
843
+ where the key is not a string.
844
+
845
+ Additional ``bar_format`` parameters may also be defined by overriding
846
+ ``format_dict``, and the bar itself may be modified using ``ascii``:
847
+
848
+ .. code:: python
849
+
850
+ from tqdm import tqdm
851
+ class TqdmExtraFormat(tqdm):
852
+ """Provides a `total_time` format parameter"""
853
+ @property
854
+ def format_dict(self):
855
+ d = super().format_dict
856
+ total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1)
857
+ d.update(total_time=self.format_interval(total_time) + " in total")
858
+ return d
859
+
860
+ for i in TqdmExtraFormat(
861
+ range(9), ascii=" .oO0",
862
+ bar_format="{total_time}: {percentage:.0f}%|{bar}{r_bar}"):
863
+ if i == 4:
864
+ break
865
+
866
+ .. code::
867
+
868
+ 00:00 in total: 44%|0000. | 4/9 [00:00<00:00, 962.93it/s]
869
+
870
+ Note that ``{bar}`` also supports a format specifier ``[width][type]``.
871
+
872
+ - ``width``
873
+
874
+ * unspecified (default): automatic to fill ``ncols``
875
+ * ``int >= 0``: fixed width overriding ``ncols`` logic
876
+ * ``int < 0``: subtract from the automatic default
877
+
878
+ - ``type``
879
+
880
+ * ``a``: ascii (``ascii=True`` override)
881
+ * ``u``: unicode (``ascii=False`` override)
882
+ * ``b``: blank (``ascii=" "`` override)
883
+
884
+ This means a fixed bar with right-justified text may be created by using:
885
+ ``bar_format="{l_bar}{bar:10}|{bar:-10b}right-justified"``
886
+
887
+ Nested progress bars
888
+ ~~~~~~~~~~~~~~~~~~~~
889
+
890
+ ``tqdm`` supports nested progress bars. Here's an example:
891
+
892
+ .. code:: python
893
+
894
+ from tqdm.auto import trange
895
+ from time import sleep
896
+
897
+ for i in trange(4, desc='1st loop'):
898
+ for j in trange(5, desc='2nd loop'):
899
+ for k in trange(50, desc='3rd loop', leave=False):
900
+ sleep(0.01)
901
+
902
+ For manual control over positioning (e.g. for multi-processing use),
903
+ you may specify ``position=n`` where ``n=0`` for the outermost bar,
904
+ ``n=1`` for the next, and so on.
905
+ However, it's best to check if ``tqdm`` can work without manual ``position``
906
+ first.
907
+
908
+ .. code:: python
909
+
910
+ from time import sleep
911
+ from tqdm import trange, tqdm
912
+ from multiprocessing import Pool, RLock, freeze_support
913
+
914
+ L = list(range(9))
915
+
916
+ def progresser(n):
917
+ interval = 0.001 / (n + 2)
918
+ total = 5000
919
+ text = f"#{n}, est. {interval * total:<04.2}s"
920
+ for _ in trange(total, desc=text, position=n):
921
+ sleep(interval)
922
+
923
+ if __name__ == '__main__':
924
+ freeze_support() # for Windows support
925
+ tqdm.set_lock(RLock()) # for managing output contention
926
+ p = Pool(initializer=tqdm.set_lock, initargs=(tqdm.get_lock(),))
927
+ p.map(progresser, L)
928
+
929
+ Note that in Python 3, ``tqdm.write`` is thread-safe:
930
+
931
+ .. code:: python
932
+
933
+ from time import sleep
934
+ from tqdm import tqdm, trange
935
+ from concurrent.futures import ThreadPoolExecutor
936
+
937
+ L = list(range(9))
938
+
939
+ def progresser(n):
940
+ interval = 0.001 / (n + 2)
941
+ total = 5000
942
+ text = f"#{n}, est. {interval * total:<04.2}s"
943
+ for _ in trange(total, desc=text):
944
+ sleep(interval)
945
+ if n == 6:
946
+ tqdm.write("n == 6 completed.")
947
+ tqdm.write("`tqdm.write()` is thread-safe in py3!")
948
+
949
+ if __name__ == '__main__':
950
+ with ThreadPoolExecutor() as p:
951
+ p.map(progresser, L)
952
+
953
+ Hooks and callbacks
954
+ ~~~~~~~~~~~~~~~~~~~
955
+
956
+ ``tqdm`` can easily support callbacks/hooks and manual updates.
957
+ Here's an example with ``urllib``:
958
+
959
+ **``urllib.urlretrieve`` documentation**
960
+
961
+ | [...]
962
+ | If present, the hook function will be called once
963
+ | on establishment of the network connection and once after each block read
964
+ | thereafter. The hook will be passed three arguments; a count of blocks
965
+ | transferred so far, a block size in bytes, and the total size of the file.
966
+ | [...]
967
+
968
+ .. code:: python
969
+
970
+ import urllib, os
971
+ from tqdm import tqdm
972
+ urllib = getattr(urllib, 'request', urllib)
973
+
974
+ class TqdmUpTo(tqdm):
975
+ """Provides `update_to(n)` which uses `tqdm.update(delta_n)`."""
976
+ def update_to(self, b=1, bsize=1, tsize=None):
977
+ """
978
+ b : int, optional
979
+ Number of blocks transferred so far [default: 1].
980
+ bsize : int, optional
981
+ Size of each block (in tqdm units) [default: 1].
982
+ tsize : int, optional
983
+ Total size (in tqdm units). If [default: None] remains unchanged.
984
+ """
985
+ if tsize is not None:
986
+ self.total = tsize
987
+ return self.update(b * bsize - self.n) # also sets self.n = b * bsize
988
+
989
+ eg_link = "https://caspersci.uk.to/matryoshka.zip"
990
+ with TqdmUpTo(unit='B', unit_scale=True, unit_divisor=1024, miniters=1,
991
+ desc=eg_link.split('/')[-1]) as t: # all optional kwargs
992
+ urllib.urlretrieve(eg_link, filename=os.devnull,
993
+ reporthook=t.update_to, data=None)
994
+ t.total = t.n
995
+
996
+ Inspired by `twine#242 <https://github.com/pypa/twine/pull/242>`__.
997
+ Functional alternative in
998
+ `examples/tqdm_wget.py <https://github.com/tqdm/tqdm/blob/master/examples/tqdm_wget.py>`__.
999
+
1000
+ It is recommend to use ``miniters=1`` whenever there is potentially
1001
+ large differences in iteration speed (e.g. downloading a file over
1002
+ a patchy connection).
1003
+
1004
+ **Wrapping read/write methods**
1005
+
1006
+ To measure throughput through a file-like object's ``read`` or ``write``
1007
+ methods, use ``CallbackIOWrapper``:
1008
+
1009
+ .. code:: python
1010
+
1011
+ from tqdm.auto import tqdm
1012
+ from tqdm.utils import CallbackIOWrapper
1013
+
1014
+ with tqdm(total=file_obj.size,
1015
+ unit='B', unit_scale=True, unit_divisor=1024) as t:
1016
+ fobj = CallbackIOWrapper(t.update, file_obj, "read")
1017
+ while True:
1018
+ chunk = fobj.read(chunk_size)
1019
+ if not chunk:
1020
+ break
1021
+ t.reset()
1022
+ # ... continue to use `t` for something else
1023
+
1024
+ Alternatively, use the even simpler ``wrapattr`` convenience function,
1025
+ which would condense both the ``urllib`` and ``CallbackIOWrapper`` examples
1026
+ down to:
1027
+
1028
+ .. code:: python
1029
+
1030
+ import urllib, os
1031
+ from tqdm import tqdm
1032
+
1033
+ eg_link = "https://caspersci.uk.to/matryoshka.zip"
1034
+ response = getattr(urllib, 'request', urllib).urlopen(eg_link)
1035
+ with tqdm.wrapattr(open(os.devnull, "wb"), "write",
1036
+ miniters=1, desc=eg_link.split('/')[-1],
1037
+ total=getattr(response, 'length', None)) as fout:
1038
+ for chunk in response:
1039
+ fout.write(chunk)
1040
+
1041
+ The ``requests`` equivalent is nearly identical:
1042
+
1043
+ .. code:: python
1044
+
1045
+ import requests, os
1046
+ from tqdm import tqdm
1047
+
1048
+ eg_link = "https://caspersci.uk.to/matryoshka.zip"
1049
+ response = requests.get(eg_link, stream=True)
1050
+ with tqdm.wrapattr(open(os.devnull, "wb"), "write",
1051
+ miniters=1, desc=eg_link.split('/')[-1],
1052
+ total=int(response.headers.get('content-length', 0))) as fout:
1053
+ for chunk in response.iter_content(chunk_size=4096):
1054
+ fout.write(chunk)
1055
+
1056
+ **Custom callback**
1057
+
1058
+ ``tqdm`` is known for intelligently skipping unnecessary displays. To make a
1059
+ custom callback take advantage of this, simply use the return value of
1060
+ ``update()``. This is set to ``True`` if a ``display()`` was triggered.
1061
+
1062
+ .. code:: python
1063
+
1064
+ from tqdm.auto import tqdm as std_tqdm
1065
+
1066
+ def external_callback(*args, **kwargs):
1067
+ ...
1068
+
1069
+ class TqdmExt(std_tqdm):
1070
+ def update(self, n=1):
1071
+ displayed = super().update(n)
1072
+ if displayed:
1073
+ external_callback(**self.format_dict)
1074
+ return displayed
1075
+
1076
+ ``asyncio``
1077
+ ~~~~~~~~~~~
1078
+
1079
+ Note that ``break`` isn't currently caught by asynchronous iterators.
1080
+ This means that ``tqdm`` cannot clean up after itself in this case:
1081
+
1082
+ .. code:: python
1083
+
1084
+ from tqdm.asyncio import tqdm
1085
+
1086
+ async for i in tqdm(range(9)):
1087
+ if i == 2:
1088
+ break
1089
+
1090
+ Instead, either call ``pbar.close()`` manually or use the context manager syntax:
1091
+
1092
+ .. code:: python
1093
+
1094
+ from tqdm.asyncio import tqdm
1095
+
1096
+ with tqdm(range(9)) as pbar:
1097
+ async for i in pbar:
1098
+ if i == 2:
1099
+ break
1100
+
1101
+ Pandas Integration
1102
+ ~~~~~~~~~~~~~~~~~~
1103
+
1104
+ Due to popular demand we've added support for ``pandas`` -- here's an example
1105
+ for ``DataFrame.progress_apply`` and ``DataFrameGroupBy.progress_apply``:
1106
+
1107
+ .. code:: python
1108
+
1109
+ import pandas as pd
1110
+ import numpy as np
1111
+ from tqdm import tqdm
1112
+
1113
+ df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
1114
+
1115
+ # Register `pandas.progress_apply` and `pandas.Series.map_apply` with `tqdm`
1116
+ # (can use `tqdm.gui.tqdm`, `tqdm.notebook.tqdm`, optional kwargs, etc.)
1117
+ tqdm.pandas(desc="my bar!")
1118
+
1119
+ # Now you can use `progress_apply` instead of `apply`
1120
+ # and `progress_map` instead of `map`
1121
+ df.progress_apply(lambda x: x**2)
1122
+ # can also groupby:
1123
+ # df.groupby(0).progress_apply(lambda x: x**2)
1124
+
1125
+ In case you're interested in how this works (and how to modify it for your
1126
+ own callbacks), see the
1127
+ `examples <https://github.com/tqdm/tqdm/tree/master/examples>`__
1128
+ folder or import the module and run ``help()``.
1129
+
1130
+ Keras Integration
1131
+ ~~~~~~~~~~~~~~~~~
1132
+
1133
+ A ``keras`` callback is also available:
1134
+
1135
+ .. code:: python
1136
+
1137
+ from tqdm.keras import TqdmCallback
1138
+
1139
+ ...
1140
+
1141
+ model.fit(..., verbose=0, callbacks=[TqdmCallback()])
1142
+
1143
+ Dask Integration
1144
+ ~~~~~~~~~~~~~~~~
1145
+
1146
+ A ``dask`` callback is also available:
1147
+
1148
+ .. code:: python
1149
+
1150
+ from tqdm.dask import TqdmCallback
1151
+
1152
+ with TqdmCallback(desc="compute"):
1153
+ ...
1154
+ arr.compute()
1155
+
1156
+ # or use callback globally
1157
+ cb = TqdmCallback(desc="global")
1158
+ cb.register()
1159
+ arr.compute()
1160
+
1161
+ IPython/Jupyter Integration
1162
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1163
+
1164
+ IPython/Jupyter is supported via the ``tqdm.notebook`` submodule:
1165
+
1166
+ .. code:: python
1167
+
1168
+ from tqdm.notebook import trange, tqdm
1169
+ from time import sleep
1170
+
1171
+ for i in trange(3, desc='1st loop'):
1172
+ for j in tqdm(range(100), desc='2nd loop'):
1173
+ sleep(0.01)
1174
+
1175
+ In addition to ``tqdm`` features, the submodule provides a native Jupyter
1176
+ widget (compatible with IPython v1-v4 and Jupyter), fully working nested bars
1177
+ and colour hints (blue: normal, green: completed, red: error/interrupt,
1178
+ light blue: no ETA); as demonstrated below.
1179
+
1180
+ |Screenshot-Jupyter1|
1181
+ |Screenshot-Jupyter2|
1182
+ |Screenshot-Jupyter3|
1183
+
1184
+ The ``notebook`` version supports percentage or pixels for overall width
1185
+ (e.g.: ``ncols='100%'`` or ``ncols='480px'``).
1186
+
1187
+ It is also possible to let ``tqdm`` automatically choose between
1188
+ console or notebook versions by using the ``autonotebook`` submodule:
1189
+
1190
+ .. code:: python
1191
+
1192
+ from tqdm.autonotebook import tqdm
1193
+ tqdm.pandas()
1194
+
1195
+ Note that this will issue a ``TqdmExperimentalWarning`` if run in a notebook
1196
+ since it is not meant to be possible to distinguish between ``jupyter notebook``
1197
+ and ``jupyter console``. Use ``auto`` instead of ``autonotebook`` to suppress
1198
+ this warning.
1199
+
1200
+ Note that notebooks will display the bar in the cell where it was created.
1201
+ This may be a different cell from the one where it is used.
1202
+ If this is not desired, either
1203
+
1204
+ - delay the creation of the bar to the cell where it must be displayed, or
1205
+ - create the bar with ``display=False``, and in a later cell call
1206
+ ``display(bar.container)``:
1207
+
1208
+ .. code:: python
1209
+
1210
+ from tqdm.notebook import tqdm
1211
+ pbar = tqdm(..., display=False)
1212
+
1213
+ .. code:: python
1214
+
1215
+ # different cell
1216
+ display(pbar.container)
1217
+
1218
+ The ``keras`` callback has a ``display()`` method which can be used likewise:
1219
+
1220
+ .. code:: python
1221
+
1222
+ from tqdm.keras import TqdmCallback
1223
+ cbk = TqdmCallback(display=False)
1224
+
1225
+ .. code:: python
1226
+
1227
+ # different cell
1228
+ cbk.display()
1229
+ model.fit(..., verbose=0, callbacks=[cbk])
1230
+
1231
+ Another possibility is to have a single bar (near the top of the notebook)
1232
+ which is constantly re-used (using ``reset()`` rather than ``close()``).
1233
+ For this reason, the notebook version (unlike the CLI version) does not
1234
+ automatically call ``close()`` upon ``Exception``.
1235
+
1236
+ .. code:: python
1237
+
1238
+ from tqdm.notebook import tqdm
1239
+ pbar = tqdm()
1240
+
1241
+ .. code:: python
1242
+
1243
+ # different cell
1244
+ iterable = range(100)
1245
+ pbar.reset(total=len(iterable)) # initialise with new `total`
1246
+ for i in iterable:
1247
+ pbar.update()
1248
+ pbar.refresh() # force print final status but don't `close()`
1249
+
1250
+ Custom Integration
1251
+ ~~~~~~~~~~~~~~~~~~
1252
+
1253
+ To change the default arguments (such as making ``dynamic_ncols=True``),
1254
+ simply use built-in Python magic:
1255
+
1256
+ .. code:: python
1257
+
1258
+ from functools import partial
1259
+ from tqdm import tqdm as std_tqdm
1260
+ tqdm = partial(std_tqdm, dynamic_ncols=True)
1261
+
1262
+ For further customisation,
1263
+ ``tqdm`` may be inherited from to create custom callbacks (as with the
1264
+ ``TqdmUpTo`` example `above <#hooks-and-callbacks>`__) or for custom frontends
1265
+ (e.g. GUIs such as notebook or plotting packages). In the latter case:
1266
+
1267
+ 1. ``def __init__()`` to call ``super().__init__(..., gui=True)`` to disable
1268
+ terminal ``status_printer`` creation.
1269
+ 2. Redefine: ``close()``, ``clear()``, ``display()``.
1270
+
1271
+ Consider overloading ``display()`` to use e.g.
1272
+ ``self.frontend(**self.format_dict)`` instead of ``self.sp(repr(self))``.
1273
+
1274
+ Some submodule examples of inheritance:
1275
+
1276
+ - `tqdm/notebook.py <https://github.com/tqdm/tqdm/blob/master/tqdm/notebook.py>`__
1277
+ - `tqdm/gui.py <https://github.com/tqdm/tqdm/blob/master/tqdm/gui.py>`__
1278
+ - `tqdm/tk.py <https://github.com/tqdm/tqdm/blob/master/tqdm/tk.py>`__
1279
+ - `tqdm/contrib/slack.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/slack.py>`__
1280
+ - `tqdm/contrib/discord.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/discord.py>`__
1281
+ - `tqdm/contrib/telegram.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/telegram.py>`__
1282
+
1283
+ Dynamic Monitor/Meter
1284
+ ~~~~~~~~~~~~~~~~~~~~~
1285
+
1286
+ You can use a ``tqdm`` as a meter which is not monotonically increasing.
1287
+ This could be because ``n`` decreases (e.g. a CPU usage monitor) or ``total``
1288
+ changes.
1289
+
1290
+ One example would be recursively searching for files. The ``total`` is the
1291
+ number of objects found so far, while ``n`` is the number of those objects which
1292
+ are files (rather than folders):
1293
+
1294
+ .. code:: python
1295
+
1296
+ from tqdm import tqdm
1297
+ import os.path
1298
+
1299
+ def find_files_recursively(path, show_progress=True):
1300
+ files = []
1301
+ # total=1 assumes `path` is a file
1302
+ t = tqdm(total=1, unit="file", disable=not show_progress)
1303
+ if not os.path.exists(path):
1304
+ raise IOError("Cannot find:" + path)
1305
+
1306
+ def append_found_file(f):
1307
+ files.append(f)
1308
+ t.update()
1309
+
1310
+ def list_found_dir(path):
1311
+ """returns os.listdir(path) assuming os.path.isdir(path)"""
1312
+ listing = os.listdir(path)
1313
+ # subtract 1 since a "file" we found was actually this directory
1314
+ t.total += len(listing) - 1
1315
+ # fancy way to give info without forcing a refresh
1316
+ t.set_postfix(dir=path[-10:], refresh=False)
1317
+ t.update(0) # may trigger a refresh
1318
+ return listing
1319
+
1320
+ def recursively_search(path):
1321
+ if os.path.isdir(path):
1322
+ for f in list_found_dir(path):
1323
+ recursively_search(os.path.join(path, f))
1324
+ else:
1325
+ append_found_file(path)
1326
+
1327
+ recursively_search(path)
1328
+ t.set_postfix(dir=path)
1329
+ t.close()
1330
+ return files
1331
+
1332
+ Using ``update(0)`` is a handy way to let ``tqdm`` decide when to trigger a
1333
+ display refresh to avoid console spamming.
1334
+
1335
+ Writing messages
1336
+ ~~~~~~~~~~~~~~~~
1337
+
1338
+ This is a work in progress (see
1339
+ `#737 <https://github.com/tqdm/tqdm/issues/737>`__).
1340
+
1341
+ Since ``tqdm`` uses a simple printing mechanism to display progress bars,
1342
+ you should not write any message in the terminal using ``print()`` while
1343
+ a progressbar is open.
1344
+
1345
+ To write messages in the terminal without any collision with ``tqdm`` bar
1346
+ display, a ``.write()`` method is provided:
1347
+
1348
+ .. code:: python
1349
+
1350
+ from tqdm.auto import tqdm, trange
1351
+ from time import sleep
1352
+
1353
+ bar = trange(10)
1354
+ for i in bar:
1355
+ # Print using tqdm class method .write()
1356
+ sleep(0.1)
1357
+ if not (i % 3):
1358
+ tqdm.write("Done task %i" % i)
1359
+ # Can also use bar.write()
1360
+
1361
+ By default, this will print to standard output ``sys.stdout``. but you can
1362
+ specify any file-like object using the ``file`` argument. For example, this
1363
+ can be used to redirect the messages writing to a log file or class.
1364
+
1365
+ Redirecting writing
1366
+ ~~~~~~~~~~~~~~~~~~~
1367
+
1368
+ If using a library that can print messages to the console, editing the library
1369
+ by replacing ``print()`` with ``tqdm.write()`` may not be desirable.
1370
+ In that case, redirecting ``sys.stdout`` to ``tqdm.write()`` is an option.
1371
+
1372
+ To redirect ``sys.stdout``, create a file-like class that will write
1373
+ any input string to ``tqdm.write()``, and supply the arguments
1374
+ ``file=sys.stdout, dynamic_ncols=True``.
1375
+
1376
+ A reusable canonical example is given below:
1377
+
1378
+ .. code:: python
1379
+
1380
+ from time import sleep
1381
+ import contextlib
1382
+ import sys
1383
+ from tqdm import tqdm
1384
+ from tqdm.contrib import DummyTqdmFile
1385
+
1386
+
1387
+ @contextlib.contextmanager
1388
+ def std_out_err_redirect_tqdm():
1389
+ orig_out_err = sys.stdout, sys.stderr
1390
+ try:
1391
+ sys.stdout, sys.stderr = map(DummyTqdmFile, orig_out_err)
1392
+ yield orig_out_err[0]
1393
+ # Relay exceptions
1394
+ except Exception as exc:
1395
+ raise exc
1396
+ # Always restore sys.stdout/err if necessary
1397
+ finally:
1398
+ sys.stdout, sys.stderr = orig_out_err
1399
+
1400
+ def some_fun(i):
1401
+ print("Fee, fi, fo,".split()[i])
1402
+
1403
+ # Redirect stdout to tqdm.write() (don't forget the `as save_stdout`)
1404
+ with std_out_err_redirect_tqdm() as orig_stdout:
1405
+ # tqdm needs the original stdout
1406
+ # and dynamic_ncols=True to autodetect console width
1407
+ for i in tqdm(range(3), file=orig_stdout, dynamic_ncols=True):
1408
+ sleep(.5)
1409
+ some_fun(i)
1410
+
1411
+ # After the `with`, printing is restored
1412
+ print("Done!")
1413
+
1414
+ Redirecting ``logging``
1415
+ ~~~~~~~~~~~~~~~~~~~~~~~
1416
+
1417
+ Similar to ``sys.stdout``/``sys.stderr`` as detailed above, console ``logging``
1418
+ may also be redirected to ``tqdm.write()``.
1419
+
1420
+ Warning: if also redirecting ``sys.stdout``/``sys.stderr``, make sure to
1421
+ redirect ``logging`` first if needed.
1422
+
1423
+ Helper methods are available in ``tqdm.contrib.logging``. For example:
1424
+
1425
+ .. code:: python
1426
+
1427
+ import logging
1428
+ from tqdm import trange
1429
+ from tqdm.contrib.logging import logging_redirect_tqdm
1430
+
1431
+ LOG = logging.getLogger(__name__)
1432
+
1433
+ if __name__ == '__main__':
1434
+ logging.basicConfig(level=logging.INFO)
1435
+ with logging_redirect_tqdm():
1436
+ for i in trange(9):
1437
+ if i == 4:
1438
+ LOG.info("console logging redirected to `tqdm.write()`")
1439
+ # logging restored
1440
+
1441
+ Monitoring thread, intervals and miniters
1442
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1443
+
1444
+ ``tqdm`` implements a few tricks to increase efficiency and reduce overhead.
1445
+
1446
+ - Avoid unnecessary frequent bar refreshing: ``mininterval`` defines how long
1447
+ to wait between each refresh. ``tqdm`` always gets updated in the background,
1448
+ but it will display only every ``mininterval``.
1449
+ - Reduce number of calls to check system clock/time.
1450
+ - ``mininterval`` is more intuitive to configure than ``miniters``.
1451
+ A clever adjustment system ``dynamic_miniters`` will automatically adjust
1452
+ ``miniters`` to the amount of iterations that fit into time ``mininterval``.
1453
+ Essentially, ``tqdm`` will check if it's time to print without actually
1454
+ checking time. This behaviour can be still be bypassed by manually setting
1455
+ ``miniters``.
1456
+
1457
+ However, consider a case with a combination of fast and slow iterations.
1458
+ After a few fast iterations, ``dynamic_miniters`` will set ``miniters`` to a
1459
+ large number. When iteration rate subsequently slows, ``miniters`` will
1460
+ remain large and thus reduce display update frequency. To address this:
1461
+
1462
+ - ``maxinterval`` defines the maximum time between display refreshes.
1463
+ A concurrent monitoring thread checks for overdue updates and forces one
1464
+ where necessary.
1465
+
1466
+ The monitoring thread should not have a noticeable overhead, and guarantees
1467
+ updates at least every 10 seconds by default.
1468
+ This value can be directly changed by setting the ``monitor_interval`` of
1469
+ any ``tqdm`` instance (i.e. ``t = tqdm.tqdm(...); t.monitor_interval = 2``).
1470
+ The monitor thread may be disabled application-wide by setting
1471
+ ``tqdm.tqdm.monitor_interval = 0`` before instantiation of any ``tqdm`` bar.
1472
+
1473
+
1474
+ Merch
1475
+ -----
1476
+
1477
+ You can buy `tqdm branded merch <https://tqdm.github.io/merch>`__ now!
1478
+
1479
+ Contributions
1480
+ -------------
1481
+
1482
+ |GitHub-Commits| |GitHub-Issues| |GitHub-PRs| |OpenHub-Status| |GitHub-Contributions| |CII Best Practices|
1483
+
1484
+ All source code is hosted on `GitHub <https://github.com/tqdm/tqdm>`__.
1485
+ Contributions are welcome.
1486
+
1487
+ See the
1488
+ `CONTRIBUTING <https://github.com/tqdm/tqdm/blob/master/CONTRIBUTING.md>`__
1489
+ file for more information.
1490
+
1491
+ Developers who have made significant contributions, ranked by *SLoC*
1492
+ (surviving lines of code,
1493
+ `git fame <https://github.com/casperdcl/git-fame>`__ ``-wMC --excl '\.(png|gif|jpg)$'``),
1494
+ are:
1495
+
1496
+ ==================== ======================================================== ==== ================================
1497
+ Name ID SLoC Notes
1498
+ ==================== ======================================================== ==== ================================
1499
+ Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~80% primary maintainer |Gift-Casper|
1500
+ Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~9% team member
1501
+ Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~3%
1502
+ Daniel Ecer `de-code <https://github.com/de-code>`__ ~2%
1503
+ Richard Sheridan `richardsheridan <https://github.com/richardsheridan>`__ ~1%
1504
+ Guangshuo Chen `chengs <https://github.com/chengs>`__ ~1%
1505
+ Helio Machado `0x2b3bfa0 <https://github.com/0x2b3bfa0>`__ ~1%
1506
+ Kyle Altendorf `altendky <https://github.com/altendky>`__ <1%
1507
+ Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author
1508
+ Matthew Stevens `mjstevens777 <https://github.com/mjstevens777>`__ <1%
1509
+ Hadrien Mary `hadim <https://github.com/hadim>`__ <1% team member
1510
+ Mikhail Korobov `kmike <https://github.com/kmike>`__ <1% team member
1511
+ ==================== ======================================================== ==== ================================
1512
+
1513
+ Ports to Other Languages
1514
+ ~~~~~~~~~~~~~~~~~~~~~~~~
1515
+
1516
+ A list is available on
1517
+ `this wiki page <https://github.com/tqdm/tqdm/wiki/tqdm-ports>`__.
1518
+
1519
+
1520
+ LICENCE
1521
+ -------
1522
+
1523
+ Open Source (OSI approved): |LICENCE|
1524
+
1525
+ Citation information: |DOI|
1526
+
1527
+ |README-Hits| (Since 19 May 2016)
1528
+
1529
+ .. |Logo| image:: https://tqdm.github.io/img/logo.gif
1530
+ .. |Screenshot| image:: https://tqdm.github.io/img/tqdm.gif
1531
+ .. |Video| image:: https://tqdm.github.io/img/video.jpg
1532
+ :target: https://tqdm.github.io/video
1533
+ .. |Slides| image:: https://tqdm.github.io/img/slides.jpg
1534
+ :target: https://tqdm.github.io/PyData2019/slides.html
1535
+ .. |Merch| image:: https://tqdm.github.io/img/merch.jpg
1536
+ :target: https://tqdm.github.io/merch
1537
+ .. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/tqdm/tqdm/test.yml?branch=master&label=tqdm&logo=GitHub
1538
+ :target: https://github.com/tqdm/tqdm/actions/workflows/test.yml
1539
+ .. |Coverage-Status| image:: https://img.shields.io/coveralls/github/tqdm/tqdm/master?logo=coveralls
1540
+ :target: https://coveralls.io/github/tqdm/tqdm
1541
+ .. |Branch-Coverage-Status| image:: https://codecov.io/gh/tqdm/tqdm/branch/master/graph/badge.svg
1542
+ :target: https://codecov.io/gh/tqdm/tqdm
1543
+ .. |Codacy-Grade| image:: https://app.codacy.com/project/badge/Grade/3f965571598f44549c7818f29cdcf177
1544
+ :target: https://www.codacy.com/gh/tqdm/tqdm/dashboard
1545
+ .. |CII Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/3264/badge
1546
+ :target: https://bestpractices.coreinfrastructure.org/projects/3264
1547
+ .. |GitHub-Status| image:: https://img.shields.io/github/tag/tqdm/tqdm.svg?maxAge=86400&logo=github&logoColor=white
1548
+ :target: https://github.com/tqdm/tqdm/releases
1549
+ .. |GitHub-Forks| image:: https://img.shields.io/github/forks/tqdm/tqdm.svg?logo=github&logoColor=white
1550
+ :target: https://github.com/tqdm/tqdm/network
1551
+ .. |GitHub-Stars| image:: https://img.shields.io/github/stars/tqdm/tqdm.svg?logo=github&logoColor=white
1552
+ :target: https://github.com/tqdm/tqdm/stargazers
1553
+ .. |GitHub-Commits| image:: https://img.shields.io/github/commit-activity/y/tqdm/tqdm.svg?logo=git&logoColor=white
1554
+ :target: https://github.com/tqdm/tqdm/graphs/commit-activity
1555
+ .. |GitHub-Issues| image:: https://img.shields.io/github/issues-closed/tqdm/tqdm.svg?logo=github&logoColor=white
1556
+ :target: https://github.com/tqdm/tqdm/issues?q=
1557
+ .. |GitHub-PRs| image:: https://img.shields.io/github/issues-pr-closed/tqdm/tqdm.svg?logo=github&logoColor=white
1558
+ :target: https://github.com/tqdm/tqdm/pulls
1559
+ .. |GitHub-Contributions| image:: https://img.shields.io/github/contributors/tqdm/tqdm.svg?logo=github&logoColor=white
1560
+ :target: https://github.com/tqdm/tqdm/graphs/contributors
1561
+ .. |GitHub-Updated| image:: https://img.shields.io/github/last-commit/tqdm/tqdm/master.svg?logo=github&logoColor=white&label=pushed
1562
+ :target: https://github.com/tqdm/tqdm/pulse
1563
+ .. |Gift-Casper| image:: https://img.shields.io/badge/dynamic/json.svg?color=ff69b4&label=gifts%20received&prefix=%C2%A3&query=%24..sum&url=https%3A%2F%2Fcaspersci.uk.to%2Fgifts.json
1564
+ :target: https://cdcl.ml/sponsor
1565
+ .. |Versions| image:: https://img.shields.io/pypi/v/tqdm.svg
1566
+ :target: https://tqdm.github.io/releases
1567
+ .. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/tqdm.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
1568
+ :target: https://pepy.tech/project/tqdm
1569
+ .. |Py-Versions| image:: https://img.shields.io/pypi/pyversions/tqdm.svg?logo=python&logoColor=white
1570
+ :target: https://pypi.org/project/tqdm
1571
+ .. |Conda-Forge-Status| image:: https://img.shields.io/conda/v/conda-forge/tqdm.svg?label=conda-forge&logo=conda-forge
1572
+ :target: https://anaconda.org/conda-forge/tqdm
1573
+ .. |Snapcraft| image:: https://img.shields.io/badge/snap-install-82BEA0.svg?logo=snapcraft
1574
+ :target: https://snapcraft.io/tqdm
1575
+ .. |Docker| image:: https://img.shields.io/badge/docker-pull-blue.svg?logo=docker&logoColor=white
1576
+ :target: https://hub.docker.com/r/tqdm/tqdm
1577
+ .. |Libraries-Rank| image:: https://img.shields.io/librariesio/sourcerank/pypi/tqdm.svg?logo=koding&logoColor=white
1578
+ :target: https://libraries.io/pypi/tqdm
1579
+ .. |Libraries-Dependents| image:: https://img.shields.io/librariesio/dependent-repos/pypi/tqdm.svg?logo=koding&logoColor=white
1580
+ :target: https://github.com/tqdm/tqdm/network/dependents
1581
+ .. |OpenHub-Status| image:: https://www.openhub.net/p/tqdm/widgets/project_thin_badge?format=gif
1582
+ :target: https://www.openhub.net/p/tqdm?ref=Thin+badge
1583
+ .. |awesome-python| image:: https://awesome.re/mentioned-badge.svg
1584
+ :target: https://github.com/vinta/awesome-python
1585
+ .. |LICENCE| image:: https://img.shields.io/pypi/l/tqdm.svg
1586
+ :target: https://raw.githubusercontent.com/tqdm/tqdm/master/LICENCE
1587
+ .. |DOI| image:: https://img.shields.io/badge/DOI-10.5281/zenodo.595120-blue.svg
1588
+ :target: https://doi.org/10.5281/zenodo.595120
1589
+ .. |binder-demo| image:: https://mybinder.org/badge_logo.svg
1590
+ :target: https://mybinder.org/v2/gh/tqdm/tqdm/master?filepath=DEMO.ipynb
1591
+ .. |Screenshot-Jupyter1| image:: https://tqdm.github.io/img/jupyter-1.gif
1592
+ .. |Screenshot-Jupyter2| image:: https://tqdm.github.io/img/jupyter-2.gif
1593
+ .. |Screenshot-Jupyter3| image:: https://tqdm.github.io/img/jupyter-3.gif
1594
+ .. |README-Hits| image:: https://cgi.cdcl.ml/hits?q=tqdm&style=social&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif
1595
+ :target: https://cgi.cdcl.ml/hits?q=tqdm&a=plot&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif&style=social
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/RECORD ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tqdm/__init__.py,sha256=9mQNYSSqP99JasubEC1POJLMmhkkBH6cJZxPIR5G2pQ,1572
2
+ tqdm/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
3
+ tqdm/_main.py,sha256=9ySvgmi_2Sw4CAo5UDW0Q2dxfTryboEWGHohfCJz0sA,283
4
+ tqdm/_monitor.py,sha256=Uku-DPWgzJ7dO5CK08xKJK-E_F6qQ-JB3ksuXczSYR0,3699
5
+ tqdm/_tqdm.py,sha256=LfLCuJ6bpsVo9xilmtBXyEm1vGnUCFrliW85j3J-nD4,283
6
+ tqdm/_tqdm_gui.py,sha256=03Hc8KayxJveieI5-0-2NGiDpLvw9jZekofJUV7CCwk,287
7
+ tqdm/_tqdm_notebook.py,sha256=BuHiLuxu6uEfZFaPJW3RPpPaxaVctEQA3kdSJSDL1hw,307
8
+ tqdm/_tqdm_pandas.py,sha256=c9jptUgigN6axRDhRd4Rif98Tmxeopc1nFNFhIpbFUE,888
9
+ tqdm/_utils.py,sha256=_4E73bfDj4f1s3sM42NLHNrZDOkijZoWq-n6xWLkdZ8,553
10
+ tqdm/asyncio.py,sha256=Kp2rSkNRf9KRqa3d9YpgeZQ7L7EZf2Ki4bSc7UPIyoo,2757
11
+ tqdm/auto.py,sha256=nDZflj6p2zKkjBCNBourrhS81zYfZy1_dQvbckrdW8o,871
12
+ tqdm/autonotebook.py,sha256=Yb9F5uaiBPhfbDDFpbtoG8I2YUw3uQJ89rUDLbfR6ws,956
13
+ tqdm/cli.py,sha256=orEaahqDEBGZR1uCcTW8BkhSPEhBlSO0BKYbJ1Qgc6k,10994
14
+ tqdm/completion.sh,sha256=j79KbSmpIj_E11jfTfBXrGnUTzKXVpQ1vGVQvsyDRl4,946
15
+ tqdm/dask.py,sha256=9Ei58eVqTossRLhAfWyUFCduXYKjmLmwkaXIy-CHYfs,1319
16
+ tqdm/gui.py,sha256=STIB3K8iDzDgkNUqWIpvcI_u0OGtbGNy5NwpALXhfWs,5479
17
+ tqdm/keras.py,sha256=op9sBkb6q6c6dw2wJ0SD2ZwpPK7yM1Vbg4l1Qiy3MIo,4373
18
+ tqdm/notebook.py,sha256=scgzRQmDYzIFag_1gRh98LhtZdu3ig2yrmZdqvlgops,10802
19
+ tqdm/rich.py,sha256=YyMPkEHVyYUVUR3adJKbVX26iTmNKpNMf3DEqmm-m60,5021
20
+ tqdm/std.py,sha256=Sk24SwOd59hpNbb0UL8Y3_8ueRmL3_5O72Vy2XKasjE,57510
21
+ tqdm/tk.py,sha256=Gu0uwXwLCGPRGHORdi3WvBLGiseUp_xxX_h_gp9VpK0,6701
22
+ tqdm/tqdm.1,sha256=cDyo6hSykXedJ3Pcx5tkogR1ai3QXRnrJ0MbR2Gd9-s,7581
23
+ tqdm/utils.py,sha256=dpGZUeqoLPinM-kEsULTSe2E3jzp8wUunL6eKzkYOgk,11810
24
+ tqdm/version.py,sha256=oBM1eCOTDZDGZHffNqlehXTeQdKdracckNAEaMRmPjM,337
25
+ tqdm/contrib/__init__.py,sha256=1GMYYE866WCvlHg5MdmzOvPsQj4ZuMlXzz8xcRcJD60,2479
26
+ tqdm/contrib/bells.py,sha256=Yx1HqGCmHrESCAO700j5wE__JCleNODJxedh1ijPLD0,837
27
+ tqdm/contrib/concurrent.py,sha256=K1yjloKS5WRNFyjLRth0DmU5PAnDbF0A-GD27N-J4a8,3986
28
+ tqdm/contrib/discord.py,sha256=MtVIL1s_dxH21G4sL8FBgQ4Wei23ho9Ek5T-AommvNc,5243
29
+ tqdm/contrib/itertools.py,sha256=WdKKQU5eSzsqHu29SN_oH12huYZo0Jihqoi9-nVhwz4,774
30
+ tqdm/contrib/logging.py,sha256=NsYtnKttj2mMrGm58mEdo5a9DP_2vv8pZyrimSuWulA,3760
31
+ tqdm/contrib/slack.py,sha256=eP_Mr5sQonYniHxxQNGue3jk2JkIPmPWFZqIYxnOui0,4007
32
+ tqdm/contrib/telegram.py,sha256=vn_9SATMbbwn2PAbzSDyOX6av3eBB01QBug11P4H-Og,5008
33
+ tqdm/contrib/utils_worker.py,sha256=vaxyJyagYwOCQXLUMd86bCbI4sPqZysuMGbDSGmvEWo,1199
34
+ tqdm-4.67.3.dist-info/licenses/LICENCE,sha256=_P-Hw6R86AKKhRKqGC1PzwrRyQVE7nXPmzQ2hMrBlN4,1985
35
+ tqdm-4.67.3.dist-info/METADATA,sha256=fA6aZiwZCV8zmkt2EgHrBs_5xh-5WBU1svlvROcY7Sk,57679
36
+ tqdm-4.67.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
37
+ tqdm-4.67.3.dist-info/entry_points.txt,sha256=ReJCH7Ui3Zyh6M16E4OhsZ1oU7WtMXCfbtoyBhGO29Y,39
38
+ tqdm-4.67.3.dist-info/top_level.txt,sha256=NLiUJNfmc9At15s7JURiwvqMEjUi9G5PMGRrmMYzNSM,5
39
+ tqdm-4.67.3.dist-info/RECORD,,
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [console_scripts]
2
+ tqdm = tqdm.cli:main
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/licenses/LICENCE ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ `tqdm` is a product of collaborative work.
2
+ Unless otherwise stated, all authors (see commit logs) retain copyright
3
+ for their respective work, and release the work under the MIT licence
4
+ (text below).
5
+
6
+ Exceptions or notable authors are listed below
7
+ in reverse chronological order:
8
+
9
+ * files: *
10
+ MPL-2.0 2015-2026 (c) Casper da Costa-Luis
11
+ [casperdcl](https://github.com/casperdcl).
12
+ * files: tqdm/_tqdm.py
13
+ MIT 2016 (c) [PR #96] on behalf of Google Inc.
14
+ * files: tqdm/_tqdm.py README.rst .gitignore
15
+ MIT 2013 (c) Noam Yorav-Raphael, original author.
16
+
17
+ [PR #96]: https://github.com/tqdm/tqdm/pull/96
18
+
19
+
20
+ Mozilla Public Licence (MPL) v. 2.0 - Exhibit A
21
+ -----------------------------------------------
22
+
23
+ This Source Code Form is subject to the terms of the
24
+ Mozilla Public License, v. 2.0.
25
+ If a copy of the MPL was not distributed with this project,
26
+ You can obtain one at https://mozilla.org/MPL/2.0/.
27
+
28
+
29
+ MIT License (MIT)
30
+ -----------------
31
+
32
+ Copyright (c) 2013 noamraph
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
35
+ this software and associated documentation files (the "Software"), to deal in
36
+ the Software without restriction, including without limitation the rights to
37
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
38
+ the Software, and to permit persons to whom the Software is furnished to do so,
39
+ subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in all
42
+ copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
46
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
47
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
48
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
49
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm-4.67.3.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tqdm
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/__init__.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ._monitor import TMonitor, TqdmSynchronisationWarning
2
+ from ._tqdm_pandas import tqdm_pandas
3
+ from .cli import main # TODO: remove in v5.0.0
4
+ from .gui import tqdm as tqdm_gui # TODO: remove in v5.0.0
5
+ from .gui import trange as tgrange # TODO: remove in v5.0.0
6
+ from .std import (
7
+ TqdmDeprecationWarning, TqdmExperimentalWarning, TqdmKeyError, TqdmMonitorWarning,
8
+ TqdmTypeError, TqdmWarning, tqdm, trange)
9
+ from .version import __version__
10
+
11
+ __all__ = ['tqdm', 'tqdm_gui', 'trange', 'tgrange', 'tqdm_pandas',
12
+ 'tqdm_notebook', 'tnrange', 'main', 'TMonitor',
13
+ 'TqdmTypeError', 'TqdmKeyError',
14
+ 'TqdmWarning', 'TqdmDeprecationWarning',
15
+ 'TqdmExperimentalWarning',
16
+ 'TqdmMonitorWarning', 'TqdmSynchronisationWarning',
17
+ '__version__']
18
+
19
+
20
+ def tqdm_notebook(*args, **kwargs): # pragma: no cover
21
+ """See tqdm.notebook.tqdm for full documentation"""
22
+ from warnings import warn
23
+
24
+ from .notebook import tqdm as _tqdm_notebook
25
+ warn("This function will be removed in tqdm==5.0.0\n"
26
+ "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`",
27
+ TqdmDeprecationWarning, stacklevel=2)
28
+ return _tqdm_notebook(*args, **kwargs)
29
+
30
+
31
+ def tnrange(*args, **kwargs): # pragma: no cover
32
+ """Shortcut for `tqdm.notebook.tqdm(range(*args), **kwargs)`."""
33
+ from warnings import warn
34
+
35
+ from .notebook import trange as _tnrange
36
+ warn("Please use `tqdm.notebook.trange` instead of `tqdm.tnrange`",
37
+ TqdmDeprecationWarning, stacklevel=2)
38
+ return _tnrange(*args, **kwargs)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/__main__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .cli import main
2
+
3
+ main()
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_main.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from warnings import warn
2
+
3
+ from .cli import * # NOQA
4
+ from .cli import __all__ # NOQA
5
+ from .std import TqdmDeprecationWarning
6
+
7
+ warn("This function will be removed in tqdm==5.0.0\n"
8
+ "Please use `tqdm.cli.*` instead of `tqdm._main.*`",
9
+ TqdmDeprecationWarning, stacklevel=2)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_monitor.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import atexit
2
+ from threading import Event, Thread, current_thread
3
+ from time import time
4
+ from warnings import warn
5
+
6
+ __all__ = ["TMonitor", "TqdmSynchronisationWarning"]
7
+
8
+
9
+ class TqdmSynchronisationWarning(RuntimeWarning):
10
+ """tqdm multi-thread/-process errors which may cause incorrect nesting
11
+ but otherwise no adverse effects"""
12
+ pass
13
+
14
+
15
+ class TMonitor(Thread):
16
+ """
17
+ Monitoring thread for tqdm bars.
18
+ Monitors if tqdm bars are taking too much time to display
19
+ and readjusts miniters automatically if necessary.
20
+
21
+ Parameters
22
+ ----------
23
+ tqdm_cls : class
24
+ tqdm class to use (can be core tqdm or a submodule).
25
+ sleep_interval : float
26
+ Time to sleep between monitoring checks.
27
+ """
28
+ _test = {} # internal vars for unit testing
29
+
30
+ def __init__(self, tqdm_cls, sleep_interval):
31
+ Thread.__init__(self)
32
+ self.daemon = True # kill thread when main killed (KeyboardInterrupt)
33
+ self.woken = 0 # last time woken up, to sync with monitor
34
+ self.tqdm_cls = tqdm_cls
35
+ self.sleep_interval = sleep_interval
36
+ self._time = self._test.get("time", time)
37
+ self.was_killed = self._test.get("Event", Event)()
38
+ atexit.register(self.exit)
39
+ self.start()
40
+
41
+ def exit(self):
42
+ self.was_killed.set()
43
+ if self is not current_thread():
44
+ self.join()
45
+ return self.report()
46
+
47
+ def get_instances(self):
48
+ # returns a copy of started `tqdm_cls` instances
49
+ return [i for i in self.tqdm_cls._instances.copy()
50
+ # Avoid race by checking that the instance started
51
+ if hasattr(i, 'start_t')]
52
+
53
+ def run(self):
54
+ cur_t = self._time()
55
+ while True:
56
+ # After processing and before sleeping, notify that we woke
57
+ # Need to be done just before sleeping
58
+ self.woken = cur_t
59
+ # Sleep some time...
60
+ self.was_killed.wait(self.sleep_interval)
61
+ # Quit if killed
62
+ if self.was_killed.is_set():
63
+ return
64
+ # Then monitor!
65
+ # Acquire lock (to access _instances)
66
+ with self.tqdm_cls.get_lock():
67
+ cur_t = self._time()
68
+ # Check tqdm instances are waiting too long to print
69
+ instances = self.get_instances()
70
+ for instance in instances:
71
+ # Check event in loop to reduce blocking time on exit
72
+ if self.was_killed.is_set():
73
+ return
74
+ # Only if mininterval > 1 (else iterations are just slow)
75
+ # and last refresh exceeded maxinterval
76
+ if (
77
+ instance.miniters > 1
78
+ and (cur_t - instance.last_print_t) >= instance.maxinterval
79
+ ):
80
+ # force bypassing miniters on next iteration
81
+ # (dynamic_miniters adjusts mininterval automatically)
82
+ instance.miniters = 1
83
+ # Refresh now! (works only for manual tqdm)
84
+ instance.refresh(nolock=True)
85
+ # Remove accidental long-lived strong reference
86
+ del instance
87
+ if instances != self.get_instances(): # pragma: nocover
88
+ warn("Set changed size during iteration" +
89
+ " (see https://github.com/tqdm/tqdm/issues/481)",
90
+ TqdmSynchronisationWarning, stacklevel=2)
91
+ # Remove accidental long-lived strong references
92
+ del instances
93
+
94
+ def report(self):
95
+ return not self.was_killed.is_set()
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from warnings import warn
2
+
3
+ from .std import * # NOQA
4
+ from .std import __all__ # NOQA
5
+ from .std import TqdmDeprecationWarning
6
+
7
+ warn("This function will be removed in tqdm==5.0.0\n"
8
+ "Please use `tqdm.std.*` instead of `tqdm._tqdm.*`",
9
+ TqdmDeprecationWarning, stacklevel=2)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm_gui.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from warnings import warn
2
+
3
+ from .gui import * # NOQA
4
+ from .gui import __all__ # NOQA
5
+ from .std import TqdmDeprecationWarning
6
+
7
+ warn("This function will be removed in tqdm==5.0.0\n"
8
+ "Please use `tqdm.gui.*` instead of `tqdm._tqdm_gui.*`",
9
+ TqdmDeprecationWarning, stacklevel=2)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm_notebook.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from warnings import warn
2
+
3
+ from .notebook import * # NOQA
4
+ from .notebook import __all__ # NOQA
5
+ from .std import TqdmDeprecationWarning
6
+
7
+ warn("This function will be removed in tqdm==5.0.0\n"
8
+ "Please use `tqdm.notebook.*` instead of `tqdm._tqdm_notebook.*`",
9
+ TqdmDeprecationWarning, stacklevel=2)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_tqdm_pandas.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ __author__ = "github.com/casperdcl"
4
+ __all__ = ['tqdm_pandas']
5
+
6
+
7
+ def tqdm_pandas(tclass, **tqdm_kwargs):
8
+ """
9
+ Registers the given `tqdm` instance with
10
+ `pandas.core.groupby.DataFrameGroupBy.progress_apply`.
11
+ """
12
+ from tqdm import TqdmDeprecationWarning
13
+
14
+ if isinstance(tclass, type) or (getattr(tclass, '__name__', '').startswith(
15
+ 'tqdm_')): # delayed adapter case
16
+ TqdmDeprecationWarning(
17
+ "Please use `tqdm.pandas(...)` instead of `tqdm_pandas(tqdm, ...)`.",
18
+ fp_write=getattr(tqdm_kwargs.get('file', None), 'write', sys.stderr.write))
19
+ tclass.pandas(**tqdm_kwargs)
20
+ else:
21
+ TqdmDeprecationWarning(
22
+ "Please use `tqdm.pandas(...)` instead of `tqdm_pandas(tqdm(...))`.",
23
+ fp_write=getattr(tclass.fp, 'write', sys.stderr.write))
24
+ type(tclass).pandas(deprecated_t=tclass)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/_utils.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from warnings import warn
2
+
3
+ from .std import TqdmDeprecationWarning
4
+ from .utils import ( # NOQA, pylint: disable=unused-import
5
+ CUR_OS, IS_NIX, IS_WIN, RE_ANSI, Comparable, FormatReplace, SimpleTextIOWrapper,
6
+ _environ_cols_wrapper, _is_ascii, _is_utf, _screen_shape_linux, _screen_shape_tput,
7
+ _screen_shape_windows, _screen_shape_wrapper, _supports_unicode, _term_move_up, colorama)
8
+
9
+ warn("This function will be removed in tqdm==5.0.0\n"
10
+ "Please use `tqdm.utils.*` instead of `tqdm._utils.*`",
11
+ TqdmDeprecationWarning, stacklevel=2)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/asyncio.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Asynchronous progressbar decorator for iterators.
3
+ Includes a default `range` iterator printing to `stderr`.
4
+
5
+ Usage:
6
+ >>> from tqdm.asyncio import trange, tqdm
7
+ >>> async for i in trange(10):
8
+ ... ...
9
+ """
10
+ import asyncio
11
+ from sys import version_info
12
+
13
+ from .std import tqdm as std_tqdm
14
+
15
+ __author__ = {"github.com/": ["casperdcl"]}
16
+ __all__ = ['tqdm_asyncio', 'tarange', 'tqdm', 'trange']
17
+
18
+
19
+ class tqdm_asyncio(std_tqdm):
20
+ """
21
+ Asynchronous-friendly version of tqdm.
22
+ """
23
+ def __init__(self, iterable=None, *args, **kwargs):
24
+ super().__init__(iterable, *args, **kwargs)
25
+ self.iterable_awaitable = False
26
+ if iterable is not None:
27
+ if hasattr(iterable, "__anext__"):
28
+ self.iterable_next = iterable.__anext__
29
+ self.iterable_awaitable = True
30
+ elif hasattr(iterable, "__next__"):
31
+ self.iterable_next = iterable.__next__
32
+ else:
33
+ self.iterable_iterator = iter(iterable)
34
+ self.iterable_next = self.iterable_iterator.__next__
35
+
36
+ def __aiter__(self):
37
+ return self
38
+
39
+ async def __anext__(self):
40
+ try:
41
+ if self.iterable_awaitable:
42
+ res = await self.iterable_next()
43
+ else:
44
+ res = self.iterable_next()
45
+ self.update()
46
+ return res
47
+ except StopIteration:
48
+ self.close()
49
+ raise StopAsyncIteration
50
+ except BaseException:
51
+ self.close()
52
+ raise
53
+
54
+ def send(self, *args, **kwargs):
55
+ return self.iterable.send(*args, **kwargs)
56
+
57
+ @classmethod
58
+ def as_completed(cls, fs, *, loop=None, timeout=None, total=None, **tqdm_kwargs):
59
+ """
60
+ Wrapper for `asyncio.as_completed`.
61
+ """
62
+ if total is None:
63
+ total = len(fs)
64
+ kwargs = {}
65
+ if version_info[:2] < (3, 10):
66
+ kwargs['loop'] = loop
67
+ yield from cls(asyncio.as_completed(fs, timeout=timeout, **kwargs),
68
+ total=total, **tqdm_kwargs)
69
+
70
+ @classmethod
71
+ async def gather(cls, *fs, loop=None, timeout=None, total=None, **tqdm_kwargs):
72
+ """
73
+ Wrapper for `asyncio.gather`.
74
+ """
75
+ async def wrap_awaitable(i, f):
76
+ return i, await f
77
+
78
+ ifs = [wrap_awaitable(i, f) for i, f in enumerate(fs)]
79
+ res = [await f for f in cls.as_completed(ifs, loop=loop, timeout=timeout,
80
+ total=total, **tqdm_kwargs)]
81
+ return [i for _, i in sorted(res)]
82
+
83
+
84
+ def tarange(*args, **kwargs):
85
+ """
86
+ A shortcut for `tqdm.asyncio.tqdm(range(*args), **kwargs)`.
87
+ """
88
+ return tqdm_asyncio(range(*args), **kwargs)
89
+
90
+
91
+ # Aliases
92
+ tqdm = tqdm_asyncio
93
+ trange = tarange
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/auto.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Enables multiple commonly used features.
3
+
4
+ Method resolution order:
5
+
6
+ - `tqdm.autonotebook` without import warnings
7
+ - `tqdm.asyncio`
8
+ - `tqdm.std` base class
9
+
10
+ Usage:
11
+ >>> from tqdm.auto import trange, tqdm
12
+ >>> for i in trange(10):
13
+ ... ...
14
+ """
15
+ import warnings
16
+
17
+ from .std import TqdmExperimentalWarning
18
+
19
+ with warnings.catch_warnings():
20
+ warnings.simplefilter("ignore", category=TqdmExperimentalWarning)
21
+ from .autonotebook import tqdm as notebook_tqdm
22
+
23
+ from .asyncio import tqdm as asyncio_tqdm
24
+ from .std import tqdm as std_tqdm
25
+
26
+ if notebook_tqdm != std_tqdm:
27
+ class tqdm(notebook_tqdm, asyncio_tqdm): # pylint: disable=inconsistent-mro
28
+ pass
29
+ else:
30
+ tqdm = asyncio_tqdm
31
+
32
+
33
+ def trange(*args, **kwargs):
34
+ """
35
+ A shortcut for `tqdm.auto.tqdm(range(*args), **kwargs)`.
36
+ """
37
+ return tqdm(range(*args), **kwargs)
38
+
39
+
40
+ __all__ = ["tqdm", "trange"]
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/autonotebook.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Automatically choose between `tqdm.notebook` and `tqdm.std`.
3
+
4
+ Usage:
5
+ >>> from tqdm.autonotebook import trange, tqdm
6
+ >>> for i in trange(10):
7
+ ... ...
8
+ """
9
+ import sys
10
+ from warnings import warn
11
+
12
+ try:
13
+ get_ipython = sys.modules['IPython'].get_ipython
14
+ if 'IPKernelApp' not in get_ipython().config: # pragma: no cover
15
+ raise ImportError("console")
16
+ from .notebook import WARN_NOIPYW, IProgress
17
+ if IProgress is None:
18
+ from .std import TqdmWarning
19
+ warn(WARN_NOIPYW, TqdmWarning, stacklevel=2)
20
+ raise ImportError('ipywidgets')
21
+ except Exception:
22
+ from .std import tqdm, trange
23
+ else: # pragma: no cover
24
+ from .notebook import tqdm, trange
25
+ from .std import TqdmExperimentalWarning
26
+ warn("Using `tqdm.autonotebook.tqdm` in notebook mode."
27
+ " Use `tqdm.tqdm` instead to force console mode"
28
+ " (e.g. in jupyter console)", TqdmExperimentalWarning, stacklevel=2)
29
+ __all__ = ["tqdm", "trange"]
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/cli.py ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Module version for monitoring CLI pipes (`... | python -m tqdm | ...`).
3
+ """
4
+ import logging
5
+ import re
6
+ import sys
7
+ from ast import literal_eval as numeric
8
+ from textwrap import indent
9
+
10
+ from .std import TqdmKeyError, TqdmTypeError, tqdm
11
+ from .version import __version__
12
+
13
+ __all__ = ["main"]
14
+ log = logging.getLogger(__name__)
15
+
16
+
17
+ def cast(val, typ):
18
+ log.debug((val, typ))
19
+ if " or " in typ:
20
+ for t in typ.split(" or "):
21
+ try:
22
+ return cast(val, t)
23
+ except TqdmTypeError:
24
+ pass
25
+ raise TqdmTypeError(f"{val} : {typ}")
26
+
27
+ # sys.stderr.write('\ndebug | `val:type`: `' + val + ':' + typ + '`.\n')
28
+ if typ == 'bool':
29
+ if (val == 'True') or (val == ''):
30
+ return True
31
+ if val == 'False':
32
+ return False
33
+ raise TqdmTypeError(val + ' : ' + typ)
34
+ if typ == 'chr':
35
+ if len(val) == 1:
36
+ return val.encode()
37
+ if re.match(r"^\\\w+$", val):
38
+ return eval(f'"{val}"').encode()
39
+ raise TqdmTypeError(f"{val} : {typ}")
40
+ if typ == 'str':
41
+ return val
42
+ if typ == 'int':
43
+ try:
44
+ return int(val)
45
+ except ValueError as exc:
46
+ raise TqdmTypeError(f"{val} : {typ}") from exc
47
+ if typ == 'float':
48
+ try:
49
+ return float(val)
50
+ except ValueError as exc:
51
+ raise TqdmTypeError(f"{val} : {typ}") from exc
52
+ raise TqdmTypeError(f"{val} : {typ}")
53
+
54
+
55
+ def posix_pipe(fin, fout, delim=b'\\n', buf_size=256,
56
+ callback=lambda float: None, callback_len=True):
57
+ """
58
+ Params
59
+ ------
60
+ fin : binary file with `read(buf_size : int)` method
61
+ fout : binary file with `write` (and optionally `flush`) methods.
62
+ callback : function(float), e.g.: `tqdm.update`
63
+ callback_len : If (default: True) do `callback(len(buffer))`.
64
+ Otherwise, do `callback(data) for data in buffer.split(delim)`.
65
+ """
66
+ fp_write = fout.write
67
+
68
+ if not delim:
69
+ while True:
70
+ tmp = fin.read(buf_size)
71
+
72
+ # flush at EOF
73
+ if not tmp:
74
+ getattr(fout, 'flush', lambda: None)()
75
+ return
76
+
77
+ fp_write(tmp)
78
+ callback(len(tmp))
79
+ # return
80
+
81
+ buf = b''
82
+ len_delim = len(delim)
83
+ # n = 0
84
+ while True:
85
+ tmp = fin.read(buf_size)
86
+
87
+ # flush at EOF
88
+ if not tmp:
89
+ if buf:
90
+ fp_write(buf)
91
+ if callback_len:
92
+ # n += 1 + buf.count(delim)
93
+ callback(1 + buf.count(delim))
94
+ else:
95
+ for i in buf.split(delim):
96
+ callback(i)
97
+ getattr(fout, 'flush', lambda: None)()
98
+ return # n
99
+
100
+ while True:
101
+ i = tmp.find(delim)
102
+ if i < 0:
103
+ buf += tmp
104
+ break
105
+ fp_write(buf + tmp[:i + len(delim)])
106
+ # n += 1
107
+ callback(1 if callback_len else (buf + tmp[:i]))
108
+ buf = b''
109
+ tmp = tmp[i + len_delim:]
110
+
111
+
112
+ # ((opt, type), ... )
113
+ RE_OPTS = re.compile(r'\n {4}(\S+)\s{2,}:\s*([^,]+)')
114
+ # better split method assuming no positional args
115
+ RE_SHLEX = re.compile(r'\s*(?<!\S)--?([^\s=]+)(\s+|=|$)')
116
+
117
+ # TODO: add custom support for some of the following?
118
+ UNSUPPORTED_OPTS = ('iterable', 'gui', 'out', 'file')
119
+
120
+ # The 8 leading spaces are required for consistency
121
+ CLI_EXTRA_DOC = r"""
122
+ Extra CLI Options
123
+ -----------------
124
+ name : type, optional
125
+ TODO: find out why this is needed.
126
+ delim : chr, optional
127
+ Delimiting character [default: '\n']. Use '\0' for null.
128
+ N.B.: on Windows systems, Python converts '\n' to '\r\n'.
129
+ buf_size : int, optional
130
+ String buffer size in bytes [default: 256]
131
+ used when `delim` is specified.
132
+ bytes : bool, optional
133
+ If true, will count bytes, ignore `delim`, and default
134
+ `unit_scale` to True, `unit_divisor` to 1024, and `unit` to 'B'.
135
+ tee : bool, optional
136
+ If true, passes `stdin` to both `stderr` and `stdout`.
137
+ update : bool, optional
138
+ If true, will treat input as newly elapsed iterations,
139
+ i.e. numbers to pass to `update()`. Note that this is slow
140
+ (~2e5 it/s) since every input must be decoded as a number.
141
+ update_to : bool, optional
142
+ If true, will treat input as total elapsed iterations,
143
+ i.e. numbers to assign to `self.n`. Note that this is slow
144
+ (~2e5 it/s) since every input must be decoded as a number.
145
+ null : bool, optional
146
+ If true, will discard input (no stdout).
147
+ manpath : str, optional
148
+ Directory in which to install tqdm man pages.
149
+ comppath : str, optional
150
+ Directory in which to place tqdm completion.
151
+ log : str, optional
152
+ CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET.
153
+ """
154
+
155
+
156
+ def main(fp=sys.stderr, argv=None):
157
+ """
158
+ Parameters (internal use only)
159
+ ---------
160
+ fp : file-like object for tqdm
161
+ argv : list (default: sys.argv[1:])
162
+ """
163
+ if argv is None:
164
+ argv = sys.argv[1:]
165
+ try:
166
+ log_idx = argv.index('--log')
167
+ except ValueError:
168
+ for i in argv:
169
+ if i.startswith('--log='):
170
+ logLevel = i[len('--log='):]
171
+ break
172
+ else:
173
+ logLevel = 'INFO'
174
+ else:
175
+ # argv.pop(log_idx)
176
+ # logLevel = argv.pop(log_idx)
177
+ logLevel = argv[log_idx + 1]
178
+ logging.basicConfig(level=getattr(logging, logLevel),
179
+ format="%(levelname)s:%(module)s:%(lineno)d:%(message)s")
180
+
181
+ # py<3.13 doesn't dedent docstrings
182
+ d = (tqdm.__doc__ if sys.version_info < (3, 13)
183
+ else indent(tqdm.__doc__, " ")) + CLI_EXTRA_DOC
184
+
185
+ opt_types = dict(RE_OPTS.findall(d))
186
+ # opt_types['delim'] = 'chr'
187
+
188
+ for o in UNSUPPORTED_OPTS:
189
+ opt_types.pop(o)
190
+
191
+ log.debug(sorted(opt_types.items()))
192
+
193
+ # d = RE_OPTS.sub(r' --\1=<\1> : \2', d)
194
+ split = RE_OPTS.split(d)
195
+ opt_types_desc = zip(split[1::3], split[2::3], split[3::3])
196
+ d = ''.join(('\n --{0} : {2}{3}' if otd[1] == 'bool' else
197
+ '\n --{0}=<{1}> : {2}{3}').format(
198
+ otd[0].replace('_', '-'), otd[0], *otd[1:])
199
+ for otd in opt_types_desc if otd[0] not in UNSUPPORTED_OPTS)
200
+
201
+ help_short = "Usage:\n tqdm [--help | options]\n"
202
+ d = help_short + """
203
+ Options:
204
+ -h, --help Print this help and exit.
205
+ -v, --version Print version and exit.
206
+ """ + d.strip('\n') + '\n'
207
+
208
+ # opts = docopt(d, version=__version__)
209
+ if any(v in argv for v in ('-v', '--version')):
210
+ sys.stdout.write(__version__ + '\n')
211
+ sys.exit(0)
212
+ elif any(v in argv for v in ('-h', '--help')):
213
+ sys.stdout.write(d + '\n')
214
+ sys.exit(0)
215
+ elif argv and argv[0][:2] != '--':
216
+ sys.stderr.write(f"Error:Unknown argument:{argv[0]}\n{help_short}")
217
+
218
+ argv = RE_SHLEX.split(' '.join(["tqdm"] + argv))
219
+ opts = dict(zip(argv[1::3], argv[3::3]))
220
+
221
+ log.debug(opts)
222
+ opts.pop('log', True)
223
+
224
+ tqdm_args = {'file': fp}
225
+ try:
226
+ for (o, v) in opts.items():
227
+ o = o.replace('-', '_')
228
+ try:
229
+ tqdm_args[o] = cast(v, opt_types[o])
230
+ except KeyError as e:
231
+ raise TqdmKeyError(str(e))
232
+ log.debug('args:' + str(tqdm_args))
233
+
234
+ delim_per_char = tqdm_args.pop('bytes', False)
235
+ update = tqdm_args.pop('update', False)
236
+ update_to = tqdm_args.pop('update_to', False)
237
+ if sum((delim_per_char, update, update_to)) > 1:
238
+ raise TqdmKeyError("Can only have one of --bytes --update --update_to")
239
+ except Exception:
240
+ fp.write("\nError:\n" + help_short)
241
+ stdin, stdout_write = sys.stdin, sys.stdout.write
242
+ for i in stdin:
243
+ stdout_write(i)
244
+ raise
245
+ else:
246
+ buf_size = tqdm_args.pop('buf_size', 256)
247
+ delim = tqdm_args.pop('delim', b'\\n')
248
+ tee = tqdm_args.pop('tee', False)
249
+ manpath = tqdm_args.pop('manpath', None)
250
+ comppath = tqdm_args.pop('comppath', None)
251
+ if tqdm_args.pop('null', False):
252
+ class stdout:
253
+ @staticmethod
254
+ def write(_):
255
+ pass
256
+ else:
257
+ stdout = sys.stdout
258
+ stdout = getattr(stdout, 'buffer', stdout)
259
+ stdin = getattr(sys.stdin, 'buffer', sys.stdin)
260
+ if manpath or comppath:
261
+ try: # py<3.9
262
+ import importlib_resources as resources
263
+ except ImportError:
264
+ from importlib import resources
265
+ from pathlib import Path
266
+
267
+ def cp(name, dst):
268
+ """copy resource `name` to `dst`"""
269
+ fi = resources.files('tqdm') / name
270
+ dst.write_bytes(fi.read_bytes())
271
+ log.info("written:%s", dst)
272
+ if manpath is not None:
273
+ cp('tqdm.1', Path(manpath) / 'tqdm.1')
274
+ if comppath is not None:
275
+ cp('completion.sh', Path(comppath) / 'tqdm_completion.sh')
276
+ sys.exit(0)
277
+ if tee:
278
+ stdout_write = stdout.write
279
+ fp_write = getattr(fp, 'buffer', fp).write
280
+
281
+ class stdout: # pylint: disable=function-redefined
282
+ @staticmethod
283
+ def write(x):
284
+ with tqdm.external_write_mode(file=fp):
285
+ fp_write(x)
286
+ stdout_write(x)
287
+ if delim_per_char:
288
+ tqdm_args.setdefault('unit', 'B')
289
+ tqdm_args.setdefault('unit_scale', True)
290
+ tqdm_args.setdefault('unit_divisor', 1024)
291
+ log.debug(tqdm_args)
292
+ with tqdm(**tqdm_args) as t:
293
+ posix_pipe(stdin, stdout, '', buf_size, t.update)
294
+ elif delim == b'\\n':
295
+ log.debug(tqdm_args)
296
+ write = stdout.write
297
+ if update or update_to:
298
+ with tqdm(**tqdm_args) as t:
299
+ if update:
300
+ def callback(i):
301
+ t.update(numeric(i.decode()))
302
+ else: # update_to
303
+ def callback(i):
304
+ t.update(numeric(i.decode()) - t.n)
305
+ for i in stdin:
306
+ write(i)
307
+ callback(i)
308
+ else:
309
+ for i in tqdm(stdin, **tqdm_args):
310
+ write(i)
311
+ else:
312
+ log.debug(tqdm_args)
313
+ with tqdm(**tqdm_args) as t:
314
+ callback_len = False
315
+ if update:
316
+ def callback(i):
317
+ t.update(numeric(i.decode()))
318
+ elif update_to:
319
+ def callback(i):
320
+ t.update(numeric(i.decode()) - t.n)
321
+ else:
322
+ callback = t.update
323
+ callback_len = True
324
+ posix_pipe(stdin, stdout, delim, buf_size, callback, callback_len)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/completion.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ _tqdm(){
3
+ local cur prv
4
+ cur="${COMP_WORDS[COMP_CWORD]}"
5
+ prv="${COMP_WORDS[COMP_CWORD - 1]}"
6
+
7
+ case ${prv} in
8
+ --bar_format|--buf_size|--colour|--comppath|--delay|--delim|--desc|--initial|--lock_args|--manpath|--maxinterval|--mininterval|--miniters|--ncols|--nrows|--position|--postfix|--smoothing|--total|--unit|--unit_divisor)
9
+ # await user input
10
+ ;;
11
+ "--log")
12
+ COMPREPLY=($(compgen -W 'CRITICAL FATAL ERROR WARN WARNING INFO DEBUG NOTSET' -- ${cur}))
13
+ ;;
14
+ *)
15
+ COMPREPLY=($(compgen -W '--ascii --bar_format --buf_size --bytes --colour --comppath --delay --delim --desc --disable --dynamic_ncols --help --initial --leave --lock_args --log --manpath --maxinterval --mininterval --miniters --ncols --nrows --null --position --postfix --smoothing --tee --total --unit --unit_divisor --unit_scale --update --update_to --version --write_bytes -h -v' -- ${cur}))
16
+ ;;
17
+ esac
18
+ }
19
+ complete -F _tqdm tqdm
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/__init__.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Thin wrappers around common functions.
3
+
4
+ Subpackages contain potentially unstable extensions.
5
+ """
6
+ from warnings import warn
7
+
8
+ from ..auto import tqdm as tqdm_auto
9
+ from ..std import TqdmDeprecationWarning, tqdm
10
+ from ..utils import ObjectWrapper
11
+
12
+ __author__ = {"github.com/": ["casperdcl"]}
13
+ __all__ = ['tenumerate', 'tzip', 'tmap']
14
+
15
+
16
+ class DummyTqdmFile(ObjectWrapper):
17
+ """Dummy file-like that will write to tqdm"""
18
+
19
+ def __init__(self, wrapped):
20
+ super().__init__(wrapped)
21
+ self._buf = []
22
+
23
+ def write(self, x, nolock=False):
24
+ nl = b"\n" if isinstance(x, bytes) else "\n"
25
+ pre, sep, post = x.rpartition(nl)
26
+ if sep:
27
+ blank = type(nl)()
28
+ tqdm.write(blank.join(self._buf + [pre, sep]),
29
+ end=blank, file=self._wrapped, nolock=nolock)
30
+ self._buf = [post]
31
+ else:
32
+ self._buf.append(x)
33
+
34
+ def __del__(self):
35
+ if self._buf:
36
+ blank = type(self._buf[0])()
37
+ try:
38
+ tqdm.write(blank.join(self._buf), end=blank, file=self._wrapped)
39
+ except (OSError, ValueError):
40
+ pass
41
+
42
+
43
+ def builtin_iterable(func):
44
+ """Returns `func`"""
45
+ warn("This function has no effect, and will be removed in tqdm==5.0.0",
46
+ TqdmDeprecationWarning, stacklevel=2)
47
+ return func
48
+
49
+
50
+ def tenumerate(iterable, start=0, total=None, tqdm_class=tqdm_auto, **tqdm_kwargs):
51
+ """
52
+ Equivalent of `numpy.ndenumerate` or builtin `enumerate`.
53
+
54
+ Parameters
55
+ ----------
56
+ tqdm_class : [default: tqdm.auto.tqdm].
57
+ """
58
+ try:
59
+ import numpy as np
60
+ except ImportError:
61
+ pass
62
+ else:
63
+ if isinstance(iterable, np.ndarray):
64
+ return tqdm_class(np.ndenumerate(iterable), total=total or iterable.size,
65
+ **tqdm_kwargs)
66
+ return enumerate(tqdm_class(iterable, total=total, **tqdm_kwargs), start)
67
+
68
+
69
+ def tzip(iter1, *iter2plus, **tqdm_kwargs):
70
+ """
71
+ Equivalent of builtin `zip`.
72
+
73
+ Parameters
74
+ ----------
75
+ tqdm_class : [default: tqdm.auto.tqdm].
76
+ """
77
+ kwargs = tqdm_kwargs.copy()
78
+ tqdm_class = kwargs.pop("tqdm_class", tqdm_auto)
79
+ yield from zip(tqdm_class(iter1, **kwargs), *iter2plus)
80
+
81
+
82
+ def tmap(function, *sequences, **tqdm_kwargs):
83
+ """
84
+ Equivalent of builtin `map`.
85
+
86
+ Parameters
87
+ ----------
88
+ tqdm_class : [default: tqdm.auto.tqdm].
89
+ """
90
+ for i in tzip(*sequences, **tqdm_kwargs):
91
+ yield function(*i)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/bells.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Even more features than `tqdm.auto` (all the bells & whistles):
3
+
4
+ - `tqdm.auto`
5
+ - `tqdm.tqdm.pandas`
6
+ - `tqdm.contrib.telegram`
7
+ + uses `${TQDM_TELEGRAM_TOKEN}` and `${TQDM_TELEGRAM_CHAT_ID}`
8
+ - `tqdm.contrib.discord`
9
+ + uses `${TQDM_DISCORD_TOKEN}` and `${TQDM_DISCORD_CHANNEL_ID}`
10
+ """
11
+ __all__ = ['tqdm', 'trange']
12
+ import warnings
13
+ from os import getenv
14
+
15
+ if getenv("TQDM_SLACK_TOKEN") and getenv("TQDM_SLACK_CHANNEL"):
16
+ from .slack import tqdm, trange
17
+ elif getenv("TQDM_TELEGRAM_TOKEN") and getenv("TQDM_TELEGRAM_CHAT_ID"):
18
+ from .telegram import tqdm, trange
19
+ elif getenv("TQDM_DISCORD_TOKEN") and getenv("TQDM_DISCORD_CHANNEL_ID"):
20
+ from .discord import tqdm, trange
21
+ else:
22
+ from ..auto import tqdm, trange
23
+
24
+ with warnings.catch_warnings():
25
+ warnings.simplefilter("ignore", category=FutureWarning)
26
+ tqdm.pandas()
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/concurrent.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Thin wrappers around `concurrent.futures`.
3
+ """
4
+ from contextlib import contextmanager
5
+ from operator import length_hint
6
+ from os import cpu_count
7
+
8
+ from ..auto import tqdm as tqdm_auto
9
+ from ..std import TqdmWarning
10
+
11
+ __author__ = {"github.com/": ["casperdcl"]}
12
+ __all__ = ['thread_map', 'process_map']
13
+
14
+
15
+ @contextmanager
16
+ def ensure_lock(tqdm_class, lock_name=""):
17
+ """get (create if necessary) and then restore `tqdm_class`'s lock"""
18
+ old_lock = getattr(tqdm_class, '_lock', None) # don't create a new lock
19
+ lock = old_lock or tqdm_class.get_lock() # maybe create a new lock
20
+ lock = getattr(lock, lock_name, lock) # maybe subtype
21
+ tqdm_class.set_lock(lock)
22
+ yield lock
23
+ if old_lock is None:
24
+ del tqdm_class._lock
25
+ else:
26
+ tqdm_class.set_lock(old_lock)
27
+
28
+
29
+ def _executor_map(PoolExecutor, fn, *iterables, **tqdm_kwargs):
30
+ """
31
+ Implementation of `thread_map` and `process_map`.
32
+
33
+ Parameters
34
+ ----------
35
+ tqdm_class : [default: tqdm.auto.tqdm].
36
+ max_workers : [default: min(32, cpu_count() + 4)].
37
+ chunksize : [default: 1].
38
+ lock_name : [default: "":str].
39
+ """
40
+ kwargs = tqdm_kwargs.copy()
41
+ if "total" not in kwargs:
42
+ kwargs["total"] = length_hint(iterables[0])
43
+ tqdm_class = kwargs.pop("tqdm_class", tqdm_auto)
44
+ max_workers = kwargs.pop("max_workers", min(32, cpu_count() + 4))
45
+ chunksize = kwargs.pop("chunksize", 1)
46
+ lock_name = kwargs.pop("lock_name", "")
47
+ with ensure_lock(tqdm_class, lock_name=lock_name) as lk:
48
+ # share lock in case workers are already using `tqdm`
49
+ with PoolExecutor(max_workers=max_workers, initializer=tqdm_class.set_lock,
50
+ initargs=(lk,)) as ex:
51
+ return list(tqdm_class(ex.map(fn, *iterables, chunksize=chunksize), **kwargs))
52
+
53
+
54
+ def thread_map(fn, *iterables, **tqdm_kwargs):
55
+ """
56
+ Equivalent of `list(map(fn, *iterables))`
57
+ driven by `concurrent.futures.ThreadPoolExecutor`.
58
+
59
+ Parameters
60
+ ----------
61
+ tqdm_class : optional
62
+ `tqdm` class to use for bars [default: tqdm.auto.tqdm].
63
+ max_workers : int, optional
64
+ Maximum number of workers to spawn; passed to
65
+ `concurrent.futures.ThreadPoolExecutor.__init__`.
66
+ [default: max(32, cpu_count() + 4)].
67
+ """
68
+ from concurrent.futures import ThreadPoolExecutor
69
+ return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)
70
+
71
+
72
+ def process_map(fn, *iterables, **tqdm_kwargs):
73
+ """
74
+ Equivalent of `list(map(fn, *iterables))`
75
+ driven by `concurrent.futures.ProcessPoolExecutor`.
76
+
77
+ Parameters
78
+ ----------
79
+ tqdm_class : optional
80
+ `tqdm` class to use for bars [default: tqdm.auto.tqdm].
81
+ max_workers : int, optional
82
+ Maximum number of workers to spawn; passed to
83
+ `concurrent.futures.ProcessPoolExecutor.__init__`.
84
+ [default: min(32, cpu_count() + 4)].
85
+ chunksize : int, optional
86
+ Size of chunks sent to worker processes; passed to
87
+ `concurrent.futures.ProcessPoolExecutor.map`. [default: 1].
88
+ lock_name : str, optional
89
+ Member of `tqdm_class.get_lock()` to use [default: mp_lock].
90
+ """
91
+ from concurrent.futures import ProcessPoolExecutor
92
+ if iterables and "chunksize" not in tqdm_kwargs:
93
+ # default `chunksize=1` has poor performance for large iterables
94
+ # (most time spent dispatching items to workers).
95
+ longest_iterable_len = max(map(length_hint, iterables))
96
+ if longest_iterable_len > 1000:
97
+ from warnings import warn
98
+ warn("Iterable length %d > 1000 but `chunksize` is not set."
99
+ " This may seriously degrade multiprocess performance."
100
+ " Set `chunksize=1` or more." % longest_iterable_len,
101
+ TqdmWarning, stacklevel=2)
102
+ if "lock_name" not in tqdm_kwargs:
103
+ tqdm_kwargs = tqdm_kwargs.copy()
104
+ tqdm_kwargs["lock_name"] = "mp_lock"
105
+ return _executor_map(ProcessPoolExecutor, fn, *iterables, **tqdm_kwargs)
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/discord.py ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Sends updates to a Discord bot.
3
+
4
+ Usage:
5
+ >>> from tqdm.contrib.discord import tqdm, trange
6
+ >>> for i in trange(10, token='{token}', channel_id='{channel_id}'):
7
+ ... ...
8
+
9
+ ![screenshot](https://tqdm.github.io/img/screenshot-discord.png)
10
+ """
11
+ from os import getenv
12
+ from warnings import warn
13
+
14
+ from requests import Session
15
+ from requests.utils import default_user_agent
16
+
17
+ from ..auto import tqdm as tqdm_auto
18
+ from ..std import TqdmWarning
19
+ from ..version import __version__
20
+ from .utils_worker import MonoWorker
21
+
22
+ __author__ = {"github.com/": ["casperdcl", "guigoruiz1"]}
23
+ __all__ = ['DiscordIO', 'tqdm_discord', 'tdrange', 'tqdm', 'trange']
24
+
25
+
26
+ class DiscordIO(MonoWorker):
27
+ """Non-blocking file-like IO using a Discord Bot."""
28
+ API = "https://discord.com/api/v10"
29
+ UA = f"tqdm (https://tqdm.github.io, {__version__}) {default_user_agent()}"
30
+
31
+ def __init__(self, token, channel_id):
32
+ """Creates a new message in the given `channel_id`."""
33
+ super().__init__()
34
+ self.token = token
35
+ self.channel_id = channel_id
36
+ self.session = Session()
37
+ self.text = self.__class__.__name__
38
+ self.message_id
39
+
40
+ @property
41
+ def message_id(self):
42
+ if hasattr(self, '_message_id'):
43
+ return self._message_id
44
+ try:
45
+ res = self.session.post(
46
+ f'{self.API}/channels/{self.channel_id}/messages',
47
+ headers={'Authorization': f'Bot {self.token}', 'User-Agent': self.UA},
48
+ json={'content': f"`{self.text}`"}).json()
49
+ except Exception as e:
50
+ tqdm_auto.write(str(e))
51
+ else:
52
+ if res.get('error_code') == 429:
53
+ warn("Creation rate limit: try increasing `mininterval`.",
54
+ TqdmWarning, stacklevel=2)
55
+ else:
56
+ self._message_id = res['id']
57
+ return self._message_id
58
+
59
+ def write(self, s):
60
+ """Replaces internal `message_id`'s text with `s`."""
61
+ if not s:
62
+ s = "..."
63
+ s = s.replace('\r', '').strip()
64
+ if s == self.text:
65
+ return # avoid duplicate message Bot error
66
+ message_id = self.message_id
67
+ if message_id is None:
68
+ return
69
+ self.text = s
70
+ try:
71
+ future = self.submit(
72
+ self.session.patch,
73
+ f'{self.API}/channels/{self.channel_id}/messages/{message_id}',
74
+ headers={'Authorization': f'Bot {self.token}', 'User-Agent': self.UA},
75
+ json={'content': f"`{self.text}`"})
76
+ except Exception as e:
77
+ tqdm_auto.write(str(e))
78
+ else:
79
+ return future
80
+
81
+ def delete(self):
82
+ """Deletes internal `message_id`."""
83
+ try:
84
+ future = self.submit(
85
+ self.session.delete,
86
+ f'{self.API}/channels/{self.channel_id}/messages/{self.message_id}',
87
+ headers={'Authorization': f'Bot {self.token}', 'User-Agent': self.UA})
88
+ except Exception as e:
89
+ tqdm_auto.write(str(e))
90
+ else:
91
+ return future
92
+
93
+
94
+ class tqdm_discord(tqdm_auto):
95
+ """
96
+ Standard `tqdm.auto.tqdm` but also sends updates to a Discord Bot.
97
+ May take a few seconds to create (`__init__`).
98
+
99
+ - create a discord bot (not public, no requirement of OAuth2 code
100
+ grant, only send message permissions) & invite it to a channel:
101
+ <https://discordpy.readthedocs.io/en/latest/discord.html>
102
+ - copy the bot `{token}` & `{channel_id}` and paste below
103
+
104
+ >>> from tqdm.contrib.discord import tqdm, trange
105
+ >>> for i in tqdm(iterable, token='{token}', channel_id='{channel_id}'):
106
+ ... ...
107
+ """
108
+ def __init__(self, *args, **kwargs):
109
+ """
110
+ Parameters
111
+ ----------
112
+ token : str, required. Discord bot token
113
+ [default: ${TQDM_DISCORD_TOKEN}].
114
+ channel_id : int, required. Discord channel ID
115
+ [default: ${TQDM_DISCORD_CHANNEL_ID}].
116
+
117
+ See `tqdm.auto.tqdm.__init__` for other parameters.
118
+ """
119
+ if not kwargs.get('disable'):
120
+ kwargs = kwargs.copy()
121
+ self.dio = DiscordIO(
122
+ kwargs.pop('token', getenv('TQDM_DISCORD_TOKEN')),
123
+ kwargs.pop('channel_id', getenv('TQDM_DISCORD_CHANNEL_ID')))
124
+ super().__init__(*args, **kwargs)
125
+
126
+ def display(self, **kwargs):
127
+ super().display(**kwargs)
128
+ fmt = self.format_dict
129
+ if fmt.get('bar_format', None):
130
+ fmt['bar_format'] = fmt['bar_format'].replace(
131
+ '<bar/>', '{bar:10u}').replace('{bar}', '{bar:10u}')
132
+ else:
133
+ fmt['bar_format'] = '{l_bar}{bar:10u}{r_bar}'
134
+ self.dio.write(self.format_meter(**fmt))
135
+
136
+ def clear(self, *args, **kwargs):
137
+ super().clear(*args, **kwargs)
138
+ if not self.disable:
139
+ self.dio.write("")
140
+
141
+ def close(self):
142
+ if self.disable:
143
+ return
144
+ super().close()
145
+ if not (self.leave or (self.leave is None and self.pos == 0)):
146
+ self.dio.delete()
147
+
148
+
149
+ def tdrange(*args, **kwargs):
150
+ """Shortcut for `tqdm.contrib.discord.tqdm(range(*args), **kwargs)`."""
151
+ return tqdm_discord(range(*args), **kwargs)
152
+
153
+
154
+ # Aliases
155
+ tqdm = tqdm_discord
156
+ trange = tdrange
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/itertools.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Thin wrappers around `itertools`.
3
+ """
4
+ import itertools
5
+
6
+ from ..auto import tqdm as tqdm_auto
7
+
8
+ __author__ = {"github.com/": ["casperdcl"]}
9
+ __all__ = ['product']
10
+
11
+
12
+ def product(*iterables, **tqdm_kwargs):
13
+ """
14
+ Equivalent of `itertools.product`.
15
+
16
+ Parameters
17
+ ----------
18
+ tqdm_class : [default: tqdm.auto.tqdm].
19
+ """
20
+ kwargs = tqdm_kwargs.copy()
21
+ tqdm_class = kwargs.pop("tqdm_class", tqdm_auto)
22
+ try:
23
+ lens = list(map(len, iterables))
24
+ except TypeError:
25
+ total = None
26
+ else:
27
+ total = 1
28
+ for i in lens:
29
+ total *= i
30
+ kwargs.setdefault("total", total)
31
+ with tqdm_class(**kwargs) as t:
32
+ it = itertools.product(*iterables)
33
+ for i in it:
34
+ yield i
35
+ t.update()
.cache/uv/archive-v0/5itABfUpr52efEvNSNHEE/tqdm/contrib/logging.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Helper functionality for interoperability with stdlib `logging`.
3
+ """
4
+ import logging
5
+ import sys
6
+ from contextlib import contextmanager
7
+
8
+ try:
9
+ from typing import Iterator, List, Optional, Type # noqa: F401
10
+ except ImportError:
11
+ pass
12
+
13
+ from ..std import tqdm as std_tqdm
14
+
15
+
16
+ class _TqdmLoggingHandler(logging.StreamHandler):
17
+ def __init__(
18
+ self,
19
+ tqdm_class=std_tqdm # type: Type[std_tqdm]
20
+ ):
21
+ super().__init__()
22
+ self.tqdm_class = tqdm_class
23
+
24
+ def emit(self, record):
25
+ try:
26
+ msg = self.format(record)
27
+ self.tqdm_class.write(msg, file=self.stream)
28
+ self.flush()
29
+ except (KeyboardInterrupt, SystemExit):
30
+ raise
31
+ except: # noqa pylint: disable=bare-except
32
+ self.handleError(record)
33
+
34
+
35
+ def _is_console_logging_handler(handler):
36
+ return (isinstance(handler, logging.StreamHandler)
37
+ and handler.stream in {sys.stdout, sys.stderr})
38
+
39
+
40
+ def _get_first_found_console_logging_handler(handlers):
41
+ for handler in handlers:
42
+ if _is_console_logging_handler(handler):
43
+ return handler
44
+
45
+
46
+ @contextmanager
47
+ def logging_redirect_tqdm(
48
+ loggers=None, # type: Optional[List[logging.Logger]],
49
+ tqdm_class=std_tqdm # type: Type[std_tqdm]
50
+ ):
51
+ # type: (...) -> Iterator[None]
52
+ """
53
+ Context manager redirecting console logging to `tqdm.write()`, leaving
54
+ other logging handlers (e.g. log files) unaffected.
55
+
56
+ Parameters
57
+ ----------
58
+ loggers : list, optional
59
+ Which handlers to redirect (default: [logging.root]).
60
+ tqdm_class : optional
61
+
62
+ Example
63
+ -------
64
+ ```python
65
+ import logging
66
+ from tqdm import trange
67
+ from tqdm.contrib.logging import logging_redirect_tqdm
68
+
69
+ LOG = logging.getLogger(__name__)
70
+
71
+ if __name__ == '__main__':
72
+ logging.basicConfig(level=logging.INFO)
73
+ with logging_redirect_tqdm():
74
+ for i in trange(9):
75
+ if i == 4:
76
+ LOG.info("console logging redirected to `tqdm.write()`")
77
+ # logging restored
78
+ ```
79
+ """
80
+ if loggers is None:
81
+ loggers = [logging.root]
82
+ original_handlers_list = [logger.handlers for logger in loggers]
83
+ try:
84
+ for logger in loggers:
85
+ tqdm_handler = _TqdmLoggingHandler(tqdm_class)
86
+ orig_handler = _get_first_found_console_logging_handler(logger.handlers)
87
+ if orig_handler is not None:
88
+ tqdm_handler.setFormatter(orig_handler.formatter)
89
+ tqdm_handler.stream = orig_handler.stream
90
+ logger.handlers = [
91
+ handler for handler in logger.handlers
92
+ if not _is_console_logging_handler(handler)] + [tqdm_handler]
93
+ yield
94
+ finally:
95
+ for logger, original_handlers in zip(loggers, original_handlers_list):
96
+ logger.handlers = original_handlers
97
+
98
+
99
+ @contextmanager
100
+ def tqdm_logging_redirect(
101
+ *args,
102
+ # loggers=None, # type: Optional[List[logging.Logger]]
103
+ # tqdm=None, # type: Optional[Type[tqdm.tqdm]]
104
+ **kwargs
105
+ ):
106
+ # type: (...) -> Iterator[None]
107
+ """
108
+ Convenience shortcut for:
109
+ ```python
110
+ with tqdm_class(*args, **tqdm_kwargs) as pbar:
111
+ with logging_redirect_tqdm(loggers=loggers, tqdm_class=tqdm_class):
112
+ yield pbar
113
+ ```
114
+
115
+ Parameters
116
+ ----------
117
+ tqdm_class : optional, (default: tqdm.std.tqdm).
118
+ loggers : optional, list.
119
+ **tqdm_kwargs : passed to `tqdm_class`.
120
+ """
121
+ tqdm_kwargs = kwargs.copy()
122
+ loggers = tqdm_kwargs.pop('loggers', None)
123
+ tqdm_class = tqdm_kwargs.pop('tqdm_class', std_tqdm)
124
+ with tqdm_class(*args, **tqdm_kwargs) as pbar:
125
+ with logging_redirect_tqdm(loggers=loggers, tqdm_class=tqdm_class):
126
+ yield pbar