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

Add example of how to use publish and publish-on-error attributes #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdavidp
Copy link

@jdavidp jdavidp commented May 5, 2020

Add example workflow that shows how to use both the publish and publish-on-error attributes of a task.

@jdavidp jdavidp requested a review from nik-bladey May 5, 2020 18:06
Copy link
Contributor

@nik-bladey nik-bladey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for helping build out this resource!

Comment on lines +14 to +15
# It's used here to keep the code D.R.Y. That is, instead of declaring the same variables
# again in the publish-on-error block, we dereference the variables using an asterisk (*).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what this is saying, but I worry that people unfamiliar with clean code practices might not

Suggested change
# It's used here to keep the code D.R.Y. That is, instead of declaring the same variables
# again in the publish-on-error block, we dereference the variables using an asterisk (*).
# It's used here to keep the code "D.R.Y." (Don't Repeat Yourself) That is, instead of declaring the same variables
# again in the publish-on-error block, we dereference the variables using an asterisk (*).

Comment on lines +31 to +36
job_name: task_1
job_id: <% task(task_1).result.job_id %>
run_id: <% task(task_1).result.run_id %>
started_at: <% task(task_1).result.started_at %>
finished_at: <% task(task_1).result.finished_at %>
status: <% task(task_1).result.state %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always wondered what sort of task information is available to be publish'ed like this -- is it just these fields? Could you add a link to the docs?

Comment on lines +54 to +59
job_name: task_2
job_id: <% task(task_2).result.job_id %>
run_id: <% task(task_2).result.run_id %>
started_at: <% task(task_2).result.started_at %>
finished_at: <% task(task_2).result.finished_at %>
status: <% task(task_2).result.state %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify whether this will overwrite the previous values of these variables?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it will. I'm not sure that's a paradigm we want to recommend? One thing that might be useful for overwriting is if there's a workflow input field that you want a task to overwrite. I believe then you can use the input if you want to run a partial workflow.

Comment on lines +54 to +59
job_name: task_2
job_id: <% task(task_2).result.job_id %>
run_id: <% task(task_2).result.run_id %>
started_at: <% task(task_2).result.started_at %>
finished_at: <% task(task_2).result.finished_at %>
status: <% task(task_2).result.state %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it will. I'm not sure that's a paradigm we want to recommend? One thing that might be useful for overwriting is if there's a workflow input field that you want a task to overwrite. I believe then you can use the input if you want to run a partial workflow.

input:
source: |
print(
'Job Name: <% $.job_name %>\n'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing this in another example, but I think we should set the example of setting up script inputs, passing these in as parameters, and accessing them through python's os.environ. But if this is less confusing that works.


time.sleep(5)
print('Task 1')
time.sleep(5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be helpful to folk to have this script create a JSON output and publish that, or is that too confusing? Maybe it does make sense to focus on publish here, and we have another example of a JSON output that they can combine.

@mattyb mattyb removed their assignment May 13, 2020
@mattyb
Copy link
Member

mattyb commented Aug 27, 2020

We've changed the default branch to main for this repo. Could you repoint this PR to there? Thanks!

@mattyb mattyb changed the base branch from master to main September 1, 2020 21:45
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.

3 participants