




'''simple docstring'''







import os
import tempfile
from functools import partial
from unittest import TestCase
from unittest.mock import patch

import datasets
import datasets.config

from .utils import require_beam

class 	_snake_case(			datasets.BeamBasedBuilder      ):






 def 						_UpperCamelCase (self       :  int    )       ->   Any:






    """simple docstring"""


    return datasets.DatasetInfo(
        features=datasets.Features({'content': datasets.Value('string'    )}    )    ,		supervised_keys=a    ,		)






 def 						_UpperCamelCase (self       :  List[str]    ,		a       :  Union[str, Any]    ,		a       :  List[Any]    )       ->   Optional[Any]:






    """simple docstring"""


    return [datasets.SplitGenerator(name=datasets.Split.TRAIN    ,		gen_kwargs={'examples': get_test_dummy_examples()}    )]






 def 						_UpperCamelCase (self       :  Tuple    ,		a       :  Union[str, Any]    ,		a       :  str    )       ->   Dict:






    """simple docstring"""


    import apache_beam as beam

    return pipeline | "Load Examples" >> beam.Create(a    )




class 	_snake_case(			datasets.BeamBasedBuilder      ):






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






    """simple docstring"""


    return datasets.DatasetInfo(
        features=datasets.Features({'a': datasets.Sequence({'b': datasets.Value('string'    )}    )}    )    ,		supervised_keys=a    ,		)






 def 						_UpperCamelCase (self       :  str    ,		a       :  Any    ,		a       :  Tuple    )       ->   List[str]:






    """simple docstring"""


    return [
        datasets.SplitGenerator(name=datasets.Split.TRAIN    ,		gen_kwargs={'examples': get_test_nested_examples()}    )
    ]






 def 						_UpperCamelCase (self       :  List[Any]    ,		a       :  List[Any]    ,		a       :  str    )       ->   int:






    """simple docstring"""


    import apache_beam as beam

    return pipeline | "Load Examples" >> beam.Create(a    )







def 						_A      ( ):






   '''simple docstring'''







   return [(i, {"content": content}) for i, content in enumerate(['foo', 'bar', 'foobar']						)]







def 						_A      ( ):






   '''simple docstring'''







   return [(i, {"a": {"b": [content]}}) for i, content in enumerate(['foo', 'bar', 'foobar']						)]







class 	_snake_case(			UpperCAmelCase      ):






 @require_beam
 def 						_UpperCamelCase (self       :  Union[str, Any]    )       ->   Tuple:






    """simple docstring"""


    A__       =     len(get_test_dummy_examples()    )
    with tempfile.TemporaryDirectory() as tmp_cache_dir:
       A__       =     DummyBeamDataset(cache_dir=a    ,		beam_runner='DirectRunner'    )
       builder.download_and_prepare()
       self.assertTrue(
           os.path.exists(
               os.path.join(a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		f"""{builder.name}-train.arrow"""    )    )    )
       self.assertDictEqual(builder.info.features    ,		datasets.Features({'content': datasets.Value('string'    )}    )    )
       A__       =     builder.as_dataset()
       self.assertEqual(dset['train'].num_rows    ,		a    )
       self.assertEqual(dset['train'].info.splits['train'].num_examples    ,		a    )
       self.assertDictEqual(dset['train'][0]    ,		get_test_dummy_examples()[0][1]    )
       self.assertDictEqual(
           dset['train'][expected_num_examples - 1]    ,		get_test_dummy_examples()[expected_num_examples - 1][1]    )
       self.assertTrue(
           os.path.exists(os.path.join(a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		'dataset_info.json'    )    )    )
       del dset






 @require_beam
 def 						_UpperCamelCase (self       :  Any    )       ->   Dict:






    """simple docstring"""


    import apache_beam as beam

    A__       =     beam.io.parquetio.WriteToParquet

    A__       =     len(get_test_dummy_examples()    )
    with tempfile.TemporaryDirectory() as tmp_cache_dir:
       A__       =     DummyBeamDataset(cache_dir=a    ,		beam_runner='DirectRunner'    )
       with patch('apache_beam.io.parquetio.WriteToParquet'    ) as write_parquet_mock:
          A__       =     partial(a    ,		num_shards=2    )
          builder.download_and_prepare()
       self.assertTrue(
           os.path.exists(
               os.path.join(
                   a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		f"""{builder.name}-train-00000-of-00002.arrow"""    )    )    )
       self.assertTrue(
           os.path.exists(
               os.path.join(
                   a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		f"""{builder.name}-train-00000-of-00002.arrow"""    )    )    )
       self.assertDictEqual(builder.info.features    ,		datasets.Features({'content': datasets.Value('string'    )}    )    )
       A__       =     builder.as_dataset()
       self.assertEqual(dset['train'].num_rows    ,		a    )
       self.assertEqual(dset['train'].info.splits['train'].num_examples    ,		a    )
       # Order is not preserved when sharding, so we just check that all the elements are there
       self.assertListEqual(sorted(dset['train']['content']    )    ,		sorted(['foo', 'bar', 'foobar']    )    )
       self.assertTrue(
           os.path.exists(os.path.join(a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		'dataset_info.json'    )    )    )
       del dset






 @require_beam
 def 						_UpperCamelCase (self       :  str    )       ->   Dict:






    """simple docstring"""


    with tempfile.TemporaryDirectory() as tmp_cache_dir:
       A__       =     DummyBeamDataset(cache_dir=a    )
       self.assertRaises(datasets.builder.MissingBeamOptions    ,		builder.download_and_prepare    )






 @require_beam
 def 						_UpperCamelCase (self       :  List[str]    )       ->   Optional[int]:






    """simple docstring"""


    A__       =     len(get_test_nested_examples()    )
    with tempfile.TemporaryDirectory() as tmp_cache_dir:
       A__       =     NestedBeamDataset(cache_dir=a    ,		beam_runner='DirectRunner'    )
       builder.download_and_prepare()
       self.assertTrue(
           os.path.exists(
               os.path.join(a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		f"""{builder.name}-train.arrow"""    )    )    )
       self.assertDictEqual(
           builder.info.features    ,		datasets.Features({'a': datasets.Sequence({'b': datasets.Value('string'    )}    )}    )    )
       A__       =     builder.as_dataset()
       self.assertEqual(dset['train'].num_rows    ,		a    )
       self.assertEqual(dset['train'].info.splits['train'].num_examples    ,		a    )
       self.assertDictEqual(dset['train'][0]    ,		get_test_nested_examples()[0][1]    )
       self.assertDictEqual(
           dset['train'][expected_num_examples - 1]    ,		get_test_nested_examples()[expected_num_examples - 1][1]    )
       self.assertTrue(
           os.path.exists(os.path.join(a    ,		builder.name    ,		'default'    ,		'0.0.0'    ,		'dataset_info.json'    )    )    )
       del dset








'''simple docstring'''







def 						_A      ( UpperCAmelCase = 1      ,UpperCAmelCase = 1000						):






   '''simple docstring'''







   A__       =     1
   A__       =     0

   for divide_by_number in range(UpperCAmelCase      ,digit + 1						):
      A__       =     []
      A__       =     numerator
      for _ in range(1      ,digit + 1						):
         if now_divide in has_been_divided:
            if longest_list_length < len(UpperCAmelCase						):
               A__       =     len(UpperCAmelCase						)
               A__       =     divide_by_number
         else:
            has_been_divided.append(UpperCAmelCase						)
            A__       =     now_divide * 10 % divide_by_number

   return the_digit


# Tests
if __name__ == "__main__":
    import doctest

    doctest.testmod()


