





"""simple docstring"""




import collections
import inspect
import unittest

from transformers import DonutSwinConfig
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import is_torch_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch
						from torch import nn

						from transformers import DonutSwinModel
						from transformers.models.donut.modeling_donut_swin import DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST




class 					_a		:






				def __init__(					self						:       Dict,					lowerCAmelCase__						:       Optional[int],					lowerCAmelCase__						:       str=1_3,					lowerCAmelCase__						:       str=3_2,					lowerCAmelCase__						:       List[str]=2,					lowerCAmelCase__						:       Dict=3,					lowerCAmelCase__						:       Dict=1_6,					lowerCAmelCase__						:       Tuple=[1, 2, 1],					lowerCAmelCase__						:       Optional[int]=[2, 2, 4],					lowerCAmelCase__						:       Any=2,					lowerCAmelCase__						:       Optional[Any]=2.0,					lowerCAmelCase__						:       List[str]=True,					lowerCAmelCase__						:       int=0.0,					lowerCAmelCase__						:       Any=0.0,					lowerCAmelCase__						:       Optional[Any]=0.1,					lowerCAmelCase__						:       Any="gelu",					lowerCAmelCase__						:       str=False,					lowerCAmelCase__						:       Optional[int]=True,					lowerCAmelCase__						:       Optional[int]=0.02,					lowerCAmelCase__						:       Dict=1e-5,					lowerCAmelCase__						:       Any=True,					lowerCAmelCase__						:       Union[str, Any]=None,					lowerCAmelCase__						:       List[Any]=True,					lowerCAmelCase__						:       Optional[Any]=1_0,					lowerCAmelCase__						:       Any=8,					)      -> List[Any]:




										'''simple docstring'''



										_UpperCamelCase     :   str      =       parent
										_UpperCamelCase     :   List[Any]      =       batch_size
										_UpperCamelCase     :   Optional[int]      =       image_size
										_UpperCamelCase     :   Tuple      =       patch_size
										_UpperCamelCase     :   Union[str, Any]      =       num_channels
										_UpperCamelCase     :   List[str]      =       embed_dim
										_UpperCamelCase     :   List[Any]      =       depths
										_UpperCamelCase     :   Tuple      =       num_heads
										_UpperCamelCase     :   Union[str, Any]      =       window_size
										_UpperCamelCase     :   Union[str, Any]      =       mlp_ratio
										_UpperCamelCase     :   List[Any]      =       qkv_bias
										_UpperCamelCase     :   Dict      =       hidden_dropout_prob
										_UpperCamelCase     :   List[str]      =       attention_probs_dropout_prob
										_UpperCamelCase     :   Dict      =       drop_path_rate
										_UpperCamelCase     :   Any      =       hidden_act
										_UpperCamelCase     :   Union[str, Any]      =       use_absolute_embeddings
										_UpperCamelCase     :   Dict      =       patch_norm
										_UpperCamelCase     :   int      =       layer_norm_eps
										_UpperCamelCase     :   List[Any]      =       initializer_range
										_UpperCamelCase     :   str      =       is_training
										_UpperCamelCase     :   Tuple      =       scope
										_UpperCamelCase     :   Optional[int]      =       use_labels
										_UpperCamelCase     :   Union[str, Any]      =       type_sequence_label_size
										_UpperCamelCase     :   List[str]      =       encoder_stride






				def 							snake_case      (					self						:       int				)      -> Union[str, Any]:




										'''simple docstring'''



										_UpperCamelCase     :   List[str]      =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

										_UpperCamelCase     :   int      =       None
										if self.use_labels:
																_UpperCamelCase     :   Optional[int]      =       ids_tensor([self.batch_size],					self.type_sequence_label_size				)

										_UpperCamelCase     :   str      =       self.get_config()

										return config, pixel_values, labels






				def 							snake_case      (					self						:       List[str]				)      -> List[Any]:




										'''simple docstring'''



										return DonutSwinConfig(
										    image_size=self.image_size,					patch_size=self.patch_size,					num_channels=self.num_channels,					embed_dim=self.embed_dim,					depths=self.depths,					num_heads=self.num_heads,					window_size=self.window_size,					mlp_ratio=self.mlp_ratio,					qkv_bias=self.qkv_bias,					hidden_dropout_prob=self.hidden_dropout_prob,					attention_probs_dropout_prob=self.attention_probs_dropout_prob,					drop_path_rate=self.drop_path_rate,					hidden_act=self.hidden_act,					use_absolute_embeddings=self.use_absolute_embeddings,					path_norm=self.patch_norm,					layer_norm_eps=self.layer_norm_eps,					initializer_range=self.initializer_range,					encoder_stride=self.encoder_stride,					)






				def 							snake_case      (					self						:       List[str],					lowerCAmelCase__						:       Dict,					lowerCAmelCase__						:       List[str],					lowerCAmelCase__						:       Optional[Any]				)      -> Union[str, Any]:




										'''simple docstring'''



										_UpperCamelCase     :   Tuple      =       DonutSwinModel(config=lowerCAmelCase__				)
										model.to(lowerCAmelCase__				)
										model.eval()
										_UpperCamelCase     :   Optional[int]      =       model(lowerCAmelCase__				)

										_UpperCamelCase     :   List[Any]      =       ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths				) - 1))
										_UpperCamelCase     :   Union[str, Any]      =       int(config.embed_dim * 2 ** (len(config.depths				) - 1)				)

										self.parent.assertEqual(result.last_hidden_state.shape,					(self.batch_size, expected_seq_len, expected_dim)				)






				def 							snake_case      (					self						:       Union[str, Any]				)      -> Dict:




										'''simple docstring'''



										_UpperCamelCase     :   str      =       self.prepare_config_and_inputs()
										(
										    (
										    _UpperCamelCase
										)  ,				(
										    _UpperCamelCase
										)  ,				(
										    _UpperCamelCase
										)  ,				
										)     :   List[str]      =       config_and_inputs
										_UpperCamelCase     :   Tuple      =       {'''pixel_values''': pixel_values}
										return config, inputs_dict




@require_torch
class 					_a		( _lowerCAmelCase      ,							_lowerCAmelCase      ,							unittest.TestCase							):
				UpperCamelCase								=       (DonutSwinModel,) if is_torch_available() else ()
				UpperCamelCase								=       {'''feature-extraction''': DonutSwinModel} if is_torch_available() else {}
				UpperCamelCase								=       True

				UpperCamelCase								=       False
				UpperCamelCase								=       False
				UpperCamelCase								=       False






				def 							snake_case      (					self						:       List[str]				)      -> Dict:




										'''simple docstring'''



										_UpperCamelCase     :   Union[str, Any]      =       DonutSwinModelTester(self				)
										_UpperCamelCase     :   Union[str, Any]      =       ConfigTester(self,					config_class=lowerCAmelCase__,					embed_dim=3_7				)






				def 							snake_case      (					self						:       int				)      -> List[Any]:




										'''simple docstring'''



										self.create_and_test_config_common_properties()
										self.config_tester.create_and_test_config_to_json_string()
										self.config_tester.create_and_test_config_to_json_file()
										self.config_tester.create_and_test_config_from_and_save_pretrained()
										self.config_tester.create_and_test_config_with_num_labels()
										self.config_tester.check_config_can_be_init_without_params()
										self.config_tester.check_config_arguments_init()






				def 							snake_case      (					self						:       Any				)      -> int:




										'''simple docstring'''



										return






				def 							snake_case      (					self						:       Tuple				)      -> Any:




										'''simple docstring'''



										_UpperCamelCase     :   int      =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowerCAmelCase__				)






				def 							snake_case      (					self						:       List[Any]				)      -> Dict:




										'''simple docstring'''



										pass






				def 							snake_case      (					self						:       Dict				)      -> Union[str, Any]:




										'''simple docstring'''



										_UpperCamelCase  ,				_UpperCamelCase     :   Optional[Any]      =       self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
																_UpperCamelCase     :   Any      =       model_class(lowerCAmelCase__				)
																self.assertIsInstance(model.get_input_embeddings(),					(nn.Module)				)
																_UpperCamelCase     :   Union[str, Any]      =       model.get_output_embeddings()
																self.assertTrue(x is None or isinstance(lowerCAmelCase__,					nn.Linear				)				)






				def 							snake_case      (					self						:       List[str]				)      -> Dict:




										'''simple docstring'''



										_UpperCamelCase  ,				_UpperCamelCase     :   Union[str, Any]      =       self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
																_UpperCamelCase     :   Any      =       model_class(lowerCAmelCase__				)
																_UpperCamelCase     :   List[Any]      =       inspect.signature(model.forward				)
																# signature.parameters is an OrderedDict => so arg_names order is deterministic
																_UpperCamelCase     :   str      =       [*signature.parameters.keys()]

																_UpperCamelCase     :   str      =       ['''pixel_values''']
																self.assertListEqual(arg_names[:1],					lowerCAmelCase__				)






				def 							snake_case      (					self						:       List[str]				)      -> int:




										'''simple docstring'''



										_UpperCamelCase  ,				_UpperCamelCase     :   Union[str, Any]      =       self.model_tester.prepare_config_and_inputs_for_common()
										_UpperCamelCase     :   Optional[Any]      =       True

										for model_class in self.all_model_classes:
																_UpperCamelCase     :   str      =       True
																_UpperCamelCase     :   int      =       False
																_UpperCamelCase     :   int      =       True
																_UpperCamelCase     :   Dict      =       model_class(lowerCAmelCase__				)
																model.to(lowerCAmelCase__				)
																model.eval()
																with torch.no_grad():
																						_UpperCamelCase     :   Dict      =       model(**self._prepare_for_class(lowerCAmelCase__,					lowerCAmelCase__				)				)
																_UpperCamelCase     :   Union[str, Any]      =       outputs.attentions
																_UpperCamelCase     :   Any      =       len(self.model_tester.depths				)
																self.assertEqual(len(lowerCAmelCase__				),					lowerCAmelCase__				)

																# check that output_attentions also work using config
																del inputs_dict["output_attentions"]
																_UpperCamelCase     :   Optional[Any]      =       True
																_UpperCamelCase     :   str      =       config.window_size**2
																_UpperCamelCase     :   Dict      =       model_class(lowerCAmelCase__				)
																model.to(lowerCAmelCase__				)
																model.eval()
																with torch.no_grad():
																						_UpperCamelCase     :   Optional[Any]      =       model(**self._prepare_for_class(lowerCAmelCase__,					lowerCAmelCase__				)				)
																_UpperCamelCase     :   str      =       outputs.attentions
																self.assertEqual(len(lowerCAmelCase__				),					lowerCAmelCase__				)

																self.assertListEqual(
																    list(attentions[0].shape[-3:]				),					[self.model_tester.num_heads[0], window_size_squared, window_size_squared],					)
																_UpperCamelCase     :   List[Any]      =       len(lowerCAmelCase__				)

																# Check attention is always last and order is fine
																_UpperCamelCase     :   List[str]      =       True
																_UpperCamelCase     :   Dict      =       True
																_UpperCamelCase     :   Any      =       model_class(lowerCAmelCase__				)
																model.to(lowerCAmelCase__				)
																model.eval()
																with torch.no_grad():
																						_UpperCamelCase     :   int      =       model(**self._prepare_for_class(lowerCAmelCase__,					lowerCAmelCase__				)				)

																if hasattr(self.model_tester,					'''num_hidden_states_types'''				):
																						_UpperCamelCase     :   int      =       self.model_tester.num_hidden_states_types
																else:
																						# also another +1 for reshaped_hidden_states
																						_UpperCamelCase     :   Any      =       2
																self.assertEqual(out_len + added_hidden_states,					len(lowerCAmelCase__				)				)

																_UpperCamelCase     :   List[str]      =       outputs.attentions

																self.assertEqual(len(lowerCAmelCase__				),					lowerCAmelCase__				)

																self.assertListEqual(
																    list(self_attentions[0].shape[-3:]				),					[self.model_tester.num_heads[0], window_size_squared, window_size_squared],					)






				def 							snake_case      (					self						:       List[str],					lowerCAmelCase__						:       Optional[Any],					lowerCAmelCase__						:       List[Any],					lowerCAmelCase__						:       Optional[int],					lowerCAmelCase__						:       Optional[Any]				)      -> Tuple:




										'''simple docstring'''



										_UpperCamelCase     :   Union[str, Any]      =       model_class(lowerCAmelCase__				)
										model.to(lowerCAmelCase__				)
										model.eval()

										with torch.no_grad():
																_UpperCamelCase     :   Optional[int]      =       model(**self._prepare_for_class(lowerCAmelCase__,					lowerCAmelCase__				)				)

										_UpperCamelCase     :   Any      =       outputs.hidden_states

										_UpperCamelCase     :   Tuple      =       getattr(
										    self.model_tester,					'''expected_num_hidden_layers''',					len(self.model_tester.depths				) + 1				)
										self.assertEqual(len(lowerCAmelCase__				),					lowerCAmelCase__				)

										# DonutSwin has a different seq_length
										_UpperCamelCase     :   List[Any]      =       (
										    config.patch_size
										    if isinstance(config.patch_size,					collections.abc.Iterable				)
										    else (config.patch_size, config.patch_size)
										)

										_UpperCamelCase     :   List[Any]      =       (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

										self.assertListEqual(
										    list(hidden_states[0].shape[-2:]				),					[num_patches, self.model_tester.embed_dim],					)

										_UpperCamelCase     :   Union[str, Any]      =       outputs.reshaped_hidden_states
										self.assertEqual(len(lowerCAmelCase__				),					lowerCAmelCase__				)

										_UpperCamelCase  ,				_UpperCamelCase  ,				_UpperCamelCase  ,				_UpperCamelCase     :   Union[str, Any]      =       reshaped_hidden_states[0].shape
										_UpperCamelCase     :   Optional[Any]      =       (
										    reshaped_hidden_states[0].view(lowerCAmelCase__,					lowerCAmelCase__,					height * width				).permute(0,					2,					1				)
										)
										self.assertListEqual(
										    list(reshaped_hidden_states.shape[-2:]				),					[num_patches, self.model_tester.embed_dim],					)






				def 							snake_case      (					self						:       List[Any]				)      -> List[Any]:




										'''simple docstring'''



										_UpperCamelCase  ,				_UpperCamelCase     :   Optional[Any]      =       self.model_tester.prepare_config_and_inputs_for_common()

										_UpperCamelCase     :   int      =       (
										    self.model_tester.image_size
										    if isinstance(self.model_tester.image_size,					collections.abc.Iterable				)
										    else (self.model_tester.image_size, self.model_tester.image_size)
										)

										for model_class in self.all_model_classes:
																_UpperCamelCase     :   int      =       True
																self.check_hidden_states_output(lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__				)

																# check that output_hidden_states also work using config
																del inputs_dict["output_hidden_states"]
																_UpperCamelCase     :   Any      =       True

																self.check_hidden_states_output(lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__				)






				def 							snake_case      (					self						:       Dict				)      -> Tuple:




										'''simple docstring'''



										_UpperCamelCase  ,				_UpperCamelCase     :   int      =       self.model_tester.prepare_config_and_inputs_for_common()
										_UpperCamelCase     :   Any      =       3

										_UpperCamelCase     :   Tuple      =       (
										    self.model_tester.image_size
										    if isinstance(self.model_tester.image_size,					collections.abc.Iterable				)
										    else (self.model_tester.image_size, self.model_tester.image_size)
										)
										_UpperCamelCase     :   Any      =       (
										    config.patch_size
										    if isinstance(config.patch_size,					collections.abc.Iterable				)
										    else (config.patch_size, config.patch_size)
										)

										_UpperCamelCase     :   Optional[int]      =       image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
										_UpperCamelCase     :   int      =       image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

										for model_class in self.all_model_classes:
																_UpperCamelCase     :   Union[str, Any]      =       True
																self.check_hidden_states_output(lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__,					(padded_height, padded_width)				)

																# check that output_hidden_states also work using config
																del inputs_dict["output_hidden_states"]
																_UpperCamelCase     :   Dict      =       True
																self.check_hidden_states_output(lowerCAmelCase__,					lowerCAmelCase__,					lowerCAmelCase__,					(padded_height, padded_width)				)






				@slow
				def 							snake_case      (					self						:       Any				)      -> Tuple:




										'''simple docstring'''



										for model_name in DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																_UpperCamelCase     :   Union[str, Any]      =       DonutSwinModel.from_pretrained(lowerCAmelCase__				)
																self.assertIsNotNone(lowerCAmelCase__				)






				def 							snake_case      (					self						:       str				)      -> Optional[int]:




										'''simple docstring'''



										_UpperCamelCase  ,				_UpperCamelCase     :   Tuple      =       self.model_tester.prepare_config_and_inputs_for_common()

										_UpperCamelCase     :   str      =       _config_zero_init(lowerCAmelCase__				)
										for model_class in self.all_model_classes:
																_UpperCamelCase     :   Optional[Any]      =       model_class(config=lowerCAmelCase__				)
																for name, param in model.named_parameters():
																						if "embeddings" not in name and param.requires_grad:
																												self.assertIn(
																												    ((param.data.mean() * 1e9).round() / 1e9).item(),					[0.0, 1.0],					msg=f"""Parameter {name} of model {model_class} seems not properly initialized""",					)










import json
import os
import subprocess
import sys
import warnings
from argparse import ArgumentParser
from contextlib import AbstractContextManager
from typing import Dict, List, Optional

import requests

from ..utils import logging
from . import BaseTransformersCLICommand


__lowerCAmelCase			:Tuple	 =     logging.get_logger(__name__)  # pylint: disable=invalid-name


__lowerCAmelCase			:Union[str, Any]	 =     'lfs-multipart-upload'






class 							_a(     __A     ):







		@staticmethod
		def 							lowercase							(     __snake_case					)   ->   Tuple:


							'''simple docstring'''

							_snake_case							:       Tuple												= parser.add_parser(
							    "lfs-enable-largefiles"			,    help=(
							        "Deprecated: use `huggingface-cli` instead. Configure your repository to enable upload of files > 5GB."
							    )			,    )
							enable_parser.add_argument("path"			,    type=__snake_case			,    help="Local path to repository you want to configure."					)
							enable_parser.set_defaults(func=lambda __snake_case					: LfsEnableCommand(__snake_case					)					)

							_snake_case							:       Union[str, Any]												= parser.add_parser(
							    __snake_case			,    help=(
							        "Deprecated: use `huggingface-cli` instead. "
							        "Command will get called by git-lfs, do not call it directly."
							    )			,    )
							upload_parser.set_defaults(func=lambda __snake_case					: LfsUploadCommand(__snake_case					)					)






class 							_a:







		def __init__(     self			,    __snake_case					)   ->   Any:


							'''simple docstring'''

							_snake_case							:       List[Any]												= args







		def 							lowercase							(     self					)   ->   Dict:


							'''simple docstring'''

							warnings.warn(
							    "Managing repositories through transformers-cli is deprecated. Please use `huggingface-cli` instead."					)
							_snake_case							:       Dict												= os.path.abspath(self.args.path					)
							if not os.path.isdir(__snake_case					):
												print("This does not look like a valid git repo."					)
												exit(1					)
							subprocess.run(
							    "git config lfs.customtransfer.multipart.path transformers-cli".split()			,    check=__snake_case			,    cwd=__snake_case					)
							subprocess.run(
							    f"""git config lfs.customtransfer.multipart.args {LFS_MULTIPART_UPLOAD_COMMAND}""".split()			,    check=__snake_case			,    cwd=__snake_case			,    )
							print("Local repo set up for largefiles"					)







def  A					(				UpperCAmelCase					):
					_snake_case							:       str												= json.dumps(UpperCAmelCase					) + "\n"
					sys.stdout.write(UpperCAmelCase					)
					sys.stdout.flush()







def  A					(				):
					_snake_case							:       str												= json.loads(sys.stdin.readline().strip()					)

					if "terminate" in (msg.get("type"					), msg.get("event"					)):
										# terminate message received
										return None

					if msg.get("event"					) not in ("download", "upload"):
										logger.critical("Received unexpected message"					)
										sys.exit(1					)

					return msg






class 							_a(     __A     ):







		def __init__(     self			,    __snake_case			,    __snake_case			,    __snake_case					)   ->   Optional[int]:


							'''simple docstring'''

							_snake_case							:       int												= filepath
							_snake_case							:       Tuple												= seek_from
							_snake_case							:       int												= read_limit
							_snake_case							:       int												= 0







		def __enter__(     self					)   ->   Any:


							'''simple docstring'''

							_snake_case							:       Optional[Any]												= open(self.filepath			,    "rb"					)
							self.f.seek(self.seek_from					)
							return self







		def __len__(     self					)   ->   Dict:


							'''simple docstring'''

							_snake_case							:       Dict												= os.fstat(self.f.fileno()					).st_size
							return min(self.read_limit			,    total_length - self.seek_from					)







		def 							lowercase							(     self			,    __snake_case=-1					)   ->   Union[str, Any]:


							'''simple docstring'''

							if self.n_seen >= self.read_limit:
												return b""
							_snake_case							:       Dict												= self.read_limit - self.n_seen
							_snake_case							:       Tuple												= self.f.read(remaining_amount if n < 0 else min(__snake_case			,    __snake_case					)					)
							self.n_seen += len(__snake_case					)
							return data







		def __iter__(     self					)   ->   int:


							'''simple docstring'''

							yield self.read(n=4 * 1_0_2_4 * 1_0_2_4					)







		def __exit__(     self			,    *__snake_case					)   ->   List[str]:


							'''simple docstring'''

							self.f.close()






class 							_a:







		def __init__(     self			,    __snake_case					)   ->   List[str]:


							'''simple docstring'''

							_snake_case							:       Any												= args







		def 							lowercase							(     self					)   ->   str:


							'''simple docstring'''

							_snake_case							:       Optional[Any]												= json.loads(sys.stdin.readline().strip()					)
							if not (init_msg.get("event"					) == "init" and init_msg.get("operation"					) == "upload"):
												write_msg({"error": {"code": 3_2, "message": "Wrong lfs init operation"}}					)
												sys.exit(1					)

							# The transfer process should use the information it needs from the
							# initiation structure, and also perform any one-off setup tasks it
							# needs to do. It should then respond on stdout with a simple empty
							# confirmation structure, as follows:
							write_msg({}					)

							# After the initiation exchange, git-lfs will send any number of
							# transfer requests to the stdin of the transfer process, in a serial sequence.
							while True:
												_snake_case							:       Optional[Any]												= read_msg()
												if msg is None:
																	# When all transfers have been processed, git-lfs will send
																	# a terminate event to the stdin of the transfer process.
																	# On receiving this message the transfer process should
																	# clean up and terminate. No response is expected.
																	sys.exit(0					)

												_snake_case							:       Dict												= msg["oid"]
												_snake_case							:       int												= msg["path"]
												_snake_case							:       Any												= msg["action"]["href"]
												_snake_case							:       Union[str, Any]												= msg["action"]["header"]
												_snake_case							:       Any												= int(header.pop("chunk_size"					)					)
												_snake_case							:       List[str]												= list(header.values()					)

												_snake_case							:       Any												= []
												for i, presigned_url in enumerate(__snake_case					):
																	with FileSlice(__snake_case			,    seek_from=i * chunk_size			,    read_limit=__snake_case					) as data:
																						_snake_case							:       List[str]												= requests.put(__snake_case			,    data=__snake_case					)
																						r.raise_for_status()
																						parts.append(
																						    {
																						        "etag": r.headers.get("etag"					),
																						        "partNumber": i + 1,
																						    }					)
																						# In order to support progress reporting while data is uploading / downloading,
																						# the transfer process should post messages to stdout
																						write_msg(
																						    {
																						        "event": "progress",
																						        "oid": oid,
																						        "bytesSoFar": (i + 1) * chunk_size,
																						        "bytesSinceLast": chunk_size,
																						    }					)
																						# Not precise but that's ok.

												_snake_case							:       Optional[Any]												= requests.post(
												    __snake_case			,    json={
												        "oid": oid,
												        "parts": parts,
												    }			,    )
												r.raise_for_status()

												write_msg({"event": "complete", "oid": oid}					)