Skip to content

Commit

Permalink
Separate insert and process args in process.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshiebert committed Apr 25, 2024
1 parent 41f4b46 commit b3f8197
Showing 1 changed file with 42 additions and 31 deletions.
73 changes: 42 additions & 31 deletions crmprtd/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
log = logging.getLogger(__name__)


def add_process_args(parser): # pragma: no cover
def add_insert_args(parser): # pragma: no cover
parser.add_argument(
"-c", "--connection_string", help="PostgreSQL connection string"
)
Expand All @@ -42,35 +42,6 @@ def add_process_args(parser): # pragma: no cover
"when searching for duplicates "
"to determine which insertion strategy to use",
)
parser.add_argument(
"-N",
"--network",
choices=NETWORKS,
help="The network from which the data is coming from. "
"The name will be used for a dynamic import of "
"the module's normalization function.",
)
parser.add_argument(
"-S",
"--start_date",
help="Optional start time to use for processing "
"(interpreted with dateutil.parser.parse).",
)
parser.add_argument(
"-E",
"--end_date",
help="Optional end time to use for processing "
"(interpreted with dateutil.parser.parse).",
)
parser.add_argument(
"-I",
"--infer",
default=False,
action="store_true",
help="Run the 'infer' stage of the pipeline, which "
"determines what metadata insertions could be made based"
"on the observed data available",
)
parser.add_argument(
"-R",
"--insert_strategy",
Expand Down Expand Up @@ -107,6 +78,39 @@ def add_process_args(parser): # pragma: no cover
return parser


def add_process_args(parser): # pragma: no cover
parser.add_argument(
"-N",
"--network",
choices=NETWORKS,
help="The network from which the data is coming from. "
"The name will be used for a dynamic import of "
"the module's normalization function.",
)
parser.add_argument(
"-S",
"--start_date",
help="Optional start time to use for processing "
"(interpreted with dateutil.parser.parse).",
)
parser.add_argument(
"-E",
"--end_date",
help="Optional end time to use for processing "
"(interpreted with dateutil.parser.parse).",
)
parser.add_argument(
"-I",
"--infer",
default=False,
action="store_true",
help="Run the 'infer' stage of the pipeline, which "
"determines what metadata insertions could be made based"
"on the observed data available",
)
return parser


def get_normalization_module(network):
return import_module(f"crmprtd.networks.{network}.normalize")

Expand Down Expand Up @@ -217,8 +221,14 @@ def gulpy_plus_plus():

parser = ArgumentParser()
add_version_arg(parser)
add_process_args(parser) # FIXME: remove start_date/end_date args
add_insert_args(parser)
add_logging_args(parser)
parser.add_argument(
"-N",
"--network",
help="The network from which the data is coming from. "
"Since gulpy input already identifies the network by way of the provided history_ids, the name will only be used for logging.",
)
parser.add_argument('filenames', metavar='filename', nargs='+',
help='CSV files to process')
args = parser.parse_args()
Expand Down Expand Up @@ -308,6 +318,7 @@ def main(args=None):
parser = ArgumentParser()
add_version_arg(parser)
add_process_args(parser)
add_insert_args(parser)
add_logging_args(parser)
args = parser.parse_args(args)

Expand Down

0 comments on commit b3f8197

Please sign in to comment.