


'''simple docstring'''







import os

from apache_beam.io.filesystems import FileSystems
from apache_beam.pipeline import Pipeline

from .logging import get_logger


A   :  int       		=				2 << 20  # 2mb
A   :  Any       		=				get_logger(__name__)


class 				__lowerCamelCase				( a_ ):
    """simple docstring"""


    def      A					(						self    :							List[str]):
           _A  :			str											=      self._options.get_all_options().get('runner')
           return runner in [None, "DirectRunner", "PortableRunner"]






def    lowerCAmelCase__ (       lowerCamelCase  :    Optional[int]						,lowerCamelCase  :    str						,lowerCamelCase  :    int=False     ):
       _A  :			str											=      FileSystems
       if fs.exists(lowerCamelCase     ):
              if force_upload:
                     logger.info(F'Remote path already exist: {remote_file_path}. Overwriting it as force_upload=True.'     )
              else:
                     logger.info(F'Remote path already exist: {remote_file_path}. Skipping it as force_upload=False.'     )
                     return
       with fs.create(lowerCamelCase     ) as remote_file:
              with open(lowerCamelCase						,'rb'     ) as local_file:
                     _A  :			Optional[Any]											=      local_file.read(lowerCamelCase     )
                     while chunk:
                            remote_file.write(lowerCamelCase     )
                            _A  :			Union[str, Any]											=      local_file.read(lowerCamelCase     )






def    lowerCAmelCase__ (       lowerCamelCase  :    Union[str, Any]						,lowerCamelCase  :    List[str]						,lowerCamelCase  :    Any=False     ):
       _A  :			Tuple											=      FileSystems
       if os.path.exists(lowerCamelCase     ):
              if force_download:
                     logger.info(F'Local path already exist: {remote_file_path}. Overwriting it as force_upload=True.'     )
              else:
                     logger.info(F'Local path already exist: {remote_file_path}. Skipping it as force_upload=False.'     )
                     return
       with fs.open(lowerCamelCase     ) as remote_file:
              with open(lowerCamelCase						,'wb'     ) as local_file:
                     _A  :			Any											=      remote_file.read(lowerCamelCase     )
                     while chunk:
                            local_file.write(lowerCamelCase     )
                            _A  :			Optional[int]											=      remote_file.read(lowerCamelCase     )










'''simple docstring'''







from unittest.mock import patch

import datasets
from datasets import Dataset






def    lowerCAmelCase__ (       ):
       _A  :			Optional[int]											=      Dataset.from_dict({'col_1': [3, 2, 0, 1]}     )

       with patch('tqdm.auto.tqdm'     ) as mock_tqdm:
              datasets.disable_progress_bar()
              dset.map(lambda lowerCamelCase     : {"col_2": x["col_1"] + 1}     )
              mock_tqdm.assert_not_called()

              mock_tqdm.reset_mock()

              datasets.enable_progress_bar()
              dset.map(lambda lowerCamelCase     : {"col_2": x["col_1"] + 1}     )
              mock_tqdm.assert_called()






