



import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Value
from datasets.packaged_modules.json.json import Json




@pytest.fixture
def     UpperCAmelCase__ (							__snake_case							)   -> List[str]:
  _A           =    tmp_path / '''file.jsonl'''
  _A           =    textwrap.dedent(
      '''\
        {"col_1": -1}
        {"col_1": 1, "col_2": 2}
        {"col_1": 10, "col_2": 20}
        '''							)
  with open(__snake_case						,				'''w'''							) as f:
    f.write(__snake_case							)
  return str(__snake_case							)




@pytest.fixture
def     UpperCAmelCase__ (							__snake_case							)   -> Tuple:
  _A           =    tmp_path / '''file_utf16_encoded.jsonl'''
  _A           =    textwrap.dedent(
      '''\
        {"col_1": -1}
        {"col_1": 1, "col_2": 2}
        {"col_1": 10, "col_2": 20}
        '''							)
  with open(__snake_case						,				'''w'''						,				encoding='''utf-16'''							) as f:
    f.write(__snake_case							)
  return str(__snake_case							)




@pytest.fixture
def     UpperCAmelCase__ (							__snake_case							)   -> Union[str, Any]:
  _A           =    tmp_path / '''file_with_list_of_dicts.json'''
  _A           =    textwrap.dedent(
      '''\
        [
            {"col_1": -1},
            {"col_1": 1, "col_2": 2},
            {"col_1": 10, "col_2": 20}
        ]
        '''							)
  with open(__snake_case						,				'''w'''							) as f:
    f.write(__snake_case							)
  return str(__snake_case							)




@pytest.fixture
def     UpperCAmelCase__ (							__snake_case							)   -> Optional[int]:
  _A           =    tmp_path / '''file_with_list_of_dicts_field.json'''
  _A           =    textwrap.dedent(
      '''\
        {
            "field1": 1,
            "field2": "aabb",
            "field3": [
                {"col_1": -1},
                {"col_1": 1, "col_2": 2},
                {"col_1": 10, "col_2": 20}
            ]
        }
        '''							)
  with open(__snake_case						,				'''w'''							) as f:
    f.write(__snake_case							)
  return str(__snake_case							)




@pytest.mark.parametrize(
    '''file_fixture, config_kwargs'''						,				[
        ('''jsonl_file''', {}),
        ('''jsonl_file_utf16_encoded''', {'''encoding''': '''utf-16'''}),
        ('''json_file_with_list_of_dicts''', {}),
        ('''json_file_with_list_of_dicts_field''', {'''field''': '''field3'''}),
    ]						,				)
def     UpperCAmelCase__ (							__snake_case						,				__snake_case						,				__snake_case							)   -> Union[str, Any]:
  _A           =    Json(**__snake_case							)
  _A           =    json._generate_tables([[request.getfixturevalue(__snake_case							)]]							)
  _A           =    pa.concat_tables([table for _, table in generator]							)
  assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20]}




@pytest.mark.parametrize(
    '''file_fixture, config_kwargs'''						,				[
        (
            '''jsonl_file''',
            {'''features''': Features({'''col_1''': Value('''int64'''							), '''col_2''': Value('''int64'''							), '''missing_col''': Value('''string'''							)}							)},
        ),
        (
            '''json_file_with_list_of_dicts''',
            {'''features''': Features({'''col_1''': Value('''int64'''							), '''col_2''': Value('''int64'''							), '''missing_col''': Value('''string'''							)}							)},
        ),
        (
            '''json_file_with_list_of_dicts_field''',
            {
                '''field''': '''field3''',
                '''features''': Features(
                    {'''col_1''': Value('''int64'''							), '''col_2''': Value('''int64'''							), '''missing_col''': Value('''string'''							)}							),
            },
        ),
    ]						,				)
def     UpperCAmelCase__ (							__snake_case						,				__snake_case						,				__snake_case							)   -> Optional[Any]:
  _A           =    Json(**__snake_case							)
  _A           =    json._generate_tables([[request.getfixturevalue(__snake_case							)]]							)
  _A           =    pa.concat_tables([table for _, table in generator]							)
  assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20], "missing_col": [None, None, None]}




import platform
from argparse import ArgumentParser

import huggingface_hub
import pandas
import pyarrow

from datasets import __version__ as version
from datasets.commands import BaseDatasetsCLICommand




def     UpperCAmelCase__ (							__snake_case							)   -> Optional[Any]:
  return EnvironmentCommand()



class 		_snake_case      (			lowerCamelCase				):





 """simple docstring"""



 @staticmethod
 def lowercase_		(						a					)	->							Dict:




   """simple docstring"""







   _A           =    parser.add_parser('''env'''	,    help='''Print relevant system environment info.'''					)
   download_parser.set_defaults(func=a					)
 def lowercase_		(						self					)	->							Optional[int]:




   """simple docstring"""







   _A           =    {
       '''`datasets` version''': version,
       '''Platform''': platform.platform(),
       '''Python version''': platform.python_version(),
       '''Huggingface_hub version''': huggingface_hub.__version__,
       '''PyArrow version''': pyarrow.__version__,
       '''Pandas version''': pandas.__version__,
   }

   print('''\nCopy-and-paste the text below in your GitHub issue.\n'''					)
   print(self.format_dict(a					)					)

   return info



 @staticmethod
 def lowercase_		(						a					)	->							Optional[int]:




   """simple docstring"""







   return "\n".join([f'''- {prop}: {val}''' for prop, val in d.items()]					) + "\n"