Skip to content

Commit

Permalink
Merge pull request #42 from rob-tay/rt-tweaks
Browse files Browse the repository at this point in the history
Changes to __main__ entry point
  • Loading branch information
benkrikler authored May 23, 2019
2 parents e2f5a88 + 523971b commit 0a2a1dd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions fast_carpenter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def collect(self, *args, **kwargs):
pass


def process_args(args=None):
def create_parser():
from argparse import ArgumentParser, Action

class StagesHelp(Action):
Expand Down Expand Up @@ -56,18 +56,25 @@ def __call__(self, parser, namespace, values, option_string=None):
help="Print help specific to the available stages")
parser.add_argument("--help-stages-full", action=StagesHelp, metavar="stage",
help="Print the full help specific to the available stages")
return parser.parse_args()

return parser


def main(args=None):
args = process_args(args)
args = create_parser().parse_args(args)

sequence = fast_flow.read_sequence_yaml(args.sequence_cfg, output_dir=args.outdir)

datasets = fast_curator.read.from_yaml(args.dataset_cfg)

mkdir_p(args.outdir)

_, ret_val = run_carpenter(sequence, datasets, args)
print(ret_val)
return 0


def run_carpenter(sequence, datasets, args):
process = atup.AtUproot(args.outdir,
quiet=args.quiet,
parallel_mode=args.mode,
Expand All @@ -81,8 +88,7 @@ def main(args=None):

sequence = [(s, s.collector() if hasattr(s, "collector") else DummyCollector()) for s in sequence]
ret_val = process.run(datasets, sequence)
print(ret_val)
return 0
return sequence, ret_val


if __name__ == "__main__":
Expand Down

0 comments on commit 0a2a1dd

Please sign in to comment.