88
99import pandas as pd
1010
11- from dgraphpandas import __version__
11+ from dgraphpandas import __version__ , __description__
1212from dgraphpandas .strategies .horizontal import horizontal_transform
1313from dgraphpandas .strategies .vertical import vertical_transform
1414from dgraphpandas .writers .upserts import generate_upserts
1515
16- logger = logging .getLogger (__name__ )
17-
18- try :
19- import coloredlogs
20- coloredlogs .install (level = 'DEBUG' )
21- except ImportError as e :
22- logger .warning (e )
23-
2416pd .set_option ('mode.chained_assignment' , None )
2517
2618
2719def main ():
28- parser = argparse .ArgumentParser ()
20+ parser = argparse .ArgumentParser (description = __description__ )
2921 parser .add_argument ('-f' , '--file' , required = True , help = 'The Data File (CSV) to convert into RDF.' )
3022 parser .add_argument ('-c' , '--config' , required = True , help = 'The DgraphPandas Configuration. See Documentation for options/examples.' )
3123 parser .add_argument ('-ck' , '--config_file_key' , required = True , help = 'The Entry in the Configuration to use for this passed file.' )
3224 parser .add_argument ('-o' , '--output_dir' , default = '.' , help = 'The output directory to write files.' )
3325 parser .add_argument ('--console' , action = 'store_true' , default = False , help = 'Write the Preprocessed DataFrames to console (for debugging)' )
3426 parser .add_argument ('--pre_csv' , action = 'store_true' , default = False , help = 'Write the Preprocessed DataFrame to CSV (for debugging)' )
3527 parser .add_argument ('--skip_upsert_generation' , action = 'store_true' , default = False , help = "Don't generate RDF files" )
36- parser .add_argument ('--encoding' , default = os .environ .get ('DGRAPH_PANDAS_ENCODING ' , 'utf-8' ), help = 'The Encoding to write files.' )
28+ parser .add_argument ('--encoding' , default = os .environ .get ('DGRAPHPANDAS_ENCODING ' , 'utf-8' ), help = 'The Encoding to write files.' )
3729 parser .add_argument ('--chunk_size' , default = 10_000_000 , type = int , help = 'Process and output in chunks rather all at once' )
3830 parser .add_argument ('--gz_compression_level' , default = 9 , type = int , help = 'Compression level to set output gzip files to' )
3931 parser .add_argument ('--key_separator' )
@@ -43,9 +35,21 @@ def main():
4335 parser .add_argument ('--illegal_characters' , default = ['%' , '\\ .' , '\\ s' , '\" ' , '\\ n' , '\\ r\\ n' ])
4436 parser .add_argument ('--illegal_characters_intrinsic_object' , default = ['\" ' , '\\ n' , '\\ r\\ n' ])
4537 parser .add_argument ('--version' , action = 'version' , version = __version__ )
38+ parser .add_argument ('-v' , '--verbosity' ,
39+ choices = ['DEBUG' , 'INFO' , 'WARNING' , 'ERROR' , 'NOTSET' ],
40+ default = os .environ .get ('DGRAPHPANDAS_LOG' , 'INFO' ))
4641
4742 args = parser .parse_args ()
4843
44+ logging .basicConfig (level = args .verbosity )
45+ logger = logging .getLogger (__name__ )
46+
47+ try :
48+ import coloredlogs
49+ coloredlogs .install (level = args .verbosity )
50+ except ImportError as e :
51+ logger .debug (e )
52+
4953 with open (args .config , 'r' ) as f :
5054 global_config : Dict [str , Any ] = json .load (f )
5155 logger .debug ('Global Config \n %s' , pformat (global_config ))
0 commit comments