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

simplify pypyr.steps.py syntax #204

Closed
yaythomas opened this issue Nov 24, 2020 · 1 comment · Fixed by #210
Closed

simplify pypyr.steps.py syntax #204

yaythomas opened this issue Nov 24, 2020 · 1 comment · Fixed by #210
Assignees
Labels
enhancement new features type: step steps up next features that are more or less on the TODO list

Comments

@yaythomas
Copy link
Member

working with context in a pypyr.steps.py step means working with the dict object rather than its contents:

    - name: pypyr.steps.py
      description: runs arb python
      in:
        # multi-line statement starts with |, per yaml spec
        pycode: |
                  print(f"py step: {0+1}")
                  context['arbvalue'] = 6
                  print(context['arbvalue'])

Add py mode of execution where pipeline authors don't need to trip over the context['arbkey'] syntax and can just use arbkey:

    - name: pypyr.steps.contextsetf
      comment: set arb context to manipulate in the next step
      in:
        contextSetf:
          existing_key: existing value
          existing_dict:
            a: a value
            b: 123

    - name: pypyr.steps.py
      description: runs arb python
      in:
        # multi-line statement starts with |, per yaml spec
        py: |
          from math import sqrt
          print(f"py step: {1+1}")
          
          arbvalue = sqrt(1764)
          print(int(arbvalue))

          existing_key = 'updated value'
          existing_dict['a'] = 'a value set in py step'
          existing_dict['b'] = 456

Make this backwards compatible so pipeline author can use either pycode or py inputs. Additionally, there might be occasions where access to the dict object itself is useful, rather than just its contents.

@yaythomas yaythomas added enhancement new features type: step steps labels Nov 24, 2020
@yaythomas yaythomas self-assigned this Nov 24, 2020
@yaythomas yaythomas added this to To do in pypyr roadmap via automation Nov 24, 2020
@yaythomas yaythomas added the up next features that are more or less on the TODO list label Nov 24, 2020
pypyr roadmap automation moved this from To do to Done Dec 26, 2020
@yaythomas
Copy link
Member Author

Related #205. See adr 0001-namespace-on-eval-and-exec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new features type: step steps up next features that are more or less on the TODO list
Projects
pypyr roadmap
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant