Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts #268

Merged
merged 4 commits into from
Mar 9, 2022
Merged

Shortcuts #268

merged 4 commits into from
Mar 9, 2022

Conversation

yaythomas
Copy link
Member

  • Shortcuts.
    • save shortcut for pipeline run commands to context, to allow operator to run longer pipeline sequences with the short and sweet alias
    • to make this work more easily, create classmethod factory on pypyr.pipeline.Pipeline that returns a new Pipeline from config.shortcuts if matching shortcut found.
    • closing shortcuts #267
  • Somewhere in the last year or two, Python's argparse module looks like it got a new bug in that default isn't honored on nargs.
  • Result is that pypyr's args_in nargs initialize to [] rather than None as specified and as it should.
  • It so happens that this wouldn't have caused drama for pypyr, because at worst API users who specified arg_parse=False would just have redundantly run the context_parser, if it exists. But all the built-in context_parsers do a truthy None check on the args input anyway, so this wouldn't have failed.
  • Therefore, change logic of Pipeline._get_parse_input to check truthy on args_in rather than is None.
  • remove tox caching from gh actions.
    • not convinced this cache actually helps the build run faster - tox has to re-check its deps anyway, and the pip install cache is supported by gh action nowadays so the tox configure step should be fast anyway. This might be the case, might not be, let's see.

Add new classmethod factory ctor to Pipeline to instantiate from config.shortcuts,
if any matching requested pipeline_name exist.

Initialize new pipeline from shortcut on pypyr.steps.pype, if matching found.

Refactor pipelinerunner.run() also to use new factory ctor.

Add pytest fixtures to intercept cls arg on Pipeline instantiation, allowing
patching/mocking of Pipeline when invoked from the pipelinerunner/pype pipeline
launch points.

Rename shortcut pipe_arg to parser_args.

Ref #267
Python's argparse looks like it has a (new) bug where `default` isn't honored on nargs.
Result is that args_in nargs initialize to [] rather than None as specified.
Therefore, change logic of Pipeline._get_parse_input to check truthy on args_in rather than `is None`.
Amend shortcut logic to bypass run() parse_args bool switch, to allow shortcut to calculate whether to
skip_parse or not.

Ref #267.
@yaythomas yaythomas merged commit 266ed35 into main Mar 9, 2022
@yaythomas yaythomas deleted the shortcuts branch March 9, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant