From b6eb9b748f4ec7091d78a494be00447b7af9cc93 Mon Sep 17 00:00:00 2001 From: Naman Jain Date: Sun, 25 Aug 2024 22:33:54 +0200 Subject: [PATCH] bugfix: args parsing in main function --- README.md | 2 ++ netcdf_to_parquet/__main__.py | 11 +++++++---- pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c11acb4..e6a0371 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ There is some scope of improvements to further enhance the performance - __Tests and Coverage Report__: Add some more end to end tests (including for one when this is being used as a library) and add coverage report. + - __Logic of main() function__: The implementation of the `main()` function in `__main__.py` seems unnecessarily complex and convulated. This can be refactored and simplified. + ### Fix: There are some minor issues that need to be fixed: diff --git a/netcdf_to_parquet/__main__.py b/netcdf_to_parquet/__main__.py index 434b018..2616990 100644 --- a/netcdf_to_parquet/__main__.py +++ b/netcdf_to_parquet/__main__.py @@ -80,12 +80,15 @@ def main( out_dir (str): Output directory for Parquet files. Defaults to "parquet_files". args (argparse.Namespace, optional): Command-line arguments. Defaults to None. """ - if args is None: + if args is None and ( + start_date is None or end_date is None or out_dir is None + ): args = parse_arguments() - start_date = args.start_date or start_date - end_date = args.end_date or end_date - out_dir = args.out_dir or out_dir + if start_date is None: + start_date = args.start_date + if end_date is None: + end_date = args.end_date if start_date is None or end_date is None: raise ValueError("start_date and end_date must be provided.") diff --git a/pyproject.toml b/pyproject.toml index 35af78c..775b698 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "netcdf-to-parquet" -version = "0.1.5" +version = "0.1.7" description = "Transforms total precipitation NetCDF files into Parquet format." authors = ["Naman Jain"] license = "MIT"