Replies: 2 comments 2 replies
-
HI @blaisep, very interesting topic! Short answer: no, pypyr doesn't have an out-of-box magic recorder in the same vein as ara. (That said, ara is not an out-of-box bit of magic either, it need some setup/configuration.) Longer answer: yes, there are various ways you can go about logging/recording pipeline runs.
# mypackage/recorder.py
import my_db_api
def run_step(context):
# okay this is obviously laughably simple, just to illustrate the point:
# getting some values from context and passing them to whatever
# logging/recording/db api or rest service you want
# notice the get_formatted will make pypyr substitution expressions "just work"
record = context.get_formatted('record')
my_db_api.write(record) Details on custom step creation here. And then you can have pipelines like this, where the pipeline author explicitly uses the the # ./my-pipeline.yaml
steps:
- name: pypyr.steps.cmd
in:
cmd: ./mycmd --does important --things
- name: mypackage.recorder
in:
record: "The mycmd sequence has run for the day"
- name: pypyr.steps.cmd
in:
cmd:
run: ./another-cmd --blah
save: True
- name: mypackage.recorder
comment: only runs if returncode == 0 for previous cmd
skip: '{cmdOut.returncode}'
in:
# notice we're using a {substitution expression} here to format the recorder/log input
record: "The another cmd process ran successfully with output: {cmdOut.stdout}" |
Beta Was this translation helpful? Give feedback.
-
ah, you remind me! Similarly, the So if you had: steps:
- name: pypyr.steps.cmd
description: -> 1. something descriptive here
in:
cmd: myprogram --blah
- name: pypyr.steps.cmd
description: -> 2. useful output here
in:
cmd: another-program --arg1 --arg2 You can then run it like this: $ pypyr my-pipeline
-> 1. something descriptive here
<<myprogram output here, if any>>
-> 2. useful output here
<<another-program output here, if any>> So if you took the idea from 1) and 2) above - i.e 1) using pypyr with i.e anything in (Note that for - name: pypyr.steps.cmd
description: this description will show up in output, but my-executable's output is suppressed
in:
cmd:
run: ./my-executable --arg1 value
stdout: /dev/null ) Real world example: Note the When this pipeline runs as part of the GitHub action, you can see the output here: https://github.com/pypyr/pypyr/runs/6609819662?check_suite_focus=true (look under "Run build pipeline for linting, testing & package validation". The build output starts on line 62. The So hopefully between this, and the 3) custom step "recorder"/"logger" - the tracing/auditing story is sensible! :-) |
Beta Was this translation helpful? Give feedback.
-
I just started using ara to record the results of playbook runs and I wonder if I could do something similar with pypyr?
https://blog.vkhitrin.com/analyzing-ansible-playbooks-using-ara/
https://ara.readthedocs.io/en/latest/
Beta Was this translation helpful? Give feedback.
All reactions