Skip to content

fix: Support skipping operations in device profile#3142

Merged
albinsuresh merged 1 commit intothin-edge:mainfrom
albinsuresh:device-profile-skip-operation
Sep 30, 2024
Merged

fix: Support skipping operations in device profile#3142
albinsuresh merged 1 commit intothin-edge:mainfrom
albinsuresh:device-profile-skip-operation

Conversation

@albinsuresh
Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh commented Sep 27, 2024

Proposed changes

Support skipping operations in device profile

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#3137

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 99.02913% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/core/tedge_api/src/workflow/mod.rs 99.02% 0 Missing and 1 partial ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
506 0 2 506 100 1h33m23.323194999s

@reubenmiller
Copy link
Copy Markdown
Contributor

@albinsuresh I don't think it makes sense to use @skip over skip. We previously used the @ prefix to denote special thin-edge.io property (e.g. in the registration syntax), however in the same payload we still use operation and payload...so the @skip does not look consistent (imho).

I'd be happy to hear other opinions on this. @didier-wenzek @jarhodes314

@albinsuresh
Copy link
Copy Markdown
Contributor Author

@albinsuresh I don't think it makes sense to use @skip over skip. We previously used the @ prefix to denote special thin-edge.io property (e.g. in the registration syntax), however in the same payload we still use operation and payload...so the @skip does not look consistent (imho).

I'd be happy to hear other opinions on this. @didier-wenzek @jarhodes314

In my view, the @skip field is different from the operation and payload fields because the iterator doesn't really care that the operation and payload fields are named as such. They could have been named anything like my_operation and my_payload as well. The user explicitly refers to those fields in the on_next target of the iterator as follows:

[next_operation]
iterate = "${.payload.operations}"
on_next = "apply_operation"
on_success = "twin_update"
on_error = "rollback"

[apply_operation]
operation = "${.payload.@next.item.my_operation}"
input = "${.payload.@next.item.my_payload}"
on_exec = "awaiting_operation"

But, the @skip field gets a special treatment by the iterator action during the iteration, just like the @next field is. And @next having that special @ prefix is what that prompted me to add that same prefix to @skip as well, so that all our internal fields have that consistency.

@didier-wenzek
Copy link
Copy Markdown
Contributor

And @next having that special @ prefix is what that prompted me to add that same prefix to @skip as well, so that all our internal fields have that consistency.

Being consistent is appealing. We also need to avoid name clashes. Since, these two keywords can be injected by the iterator action in any operation workflow, I will go with @albinsuresh proposal.

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

Approved.

@reubenmiller
Copy link
Copy Markdown
Contributor

@albinsuresh I don't think it makes sense to use @skip over skip. We previously used the @ prefix to denote special thin-edge.io property (e.g. in the registration syntax), however in the same payload we still use operation and payload...so the @skip does not look consistent (imho).
I'd be happy to hear other opinions on this. @didier-wenzek @jarhodes314

In my view, the @skip field is different from the operation and payload fields because the iterator doesn't really care that the operation and payload fields are named as such. They could have been named anything like my_operation and my_payload as well. The user explicitly refers to those fields in the on_next target of the iterator as follows:

[next_operation]
iterate = "${.payload.operations}"
on_next = "apply_operation"
on_success = "twin_update"
on_error = "rollback"

[apply_operation]
operation = "${.payload.@next.item.my_operation}"
input = "${.payload.@next.item.my_payload}"
on_exec = "awaiting_operation"

But, the @skip field gets a special treatment by the iterator action during the iteration, just like the @next field is. And @next having that special @ prefix is what that prompted me to add that same prefix to @skip as well, so that all our internal fields have that consistency.

With this explanation, then the @skip would be consistent then. Thanks for the thorough explanation.

@reubenmiller reubenmiller added the theme:profile Device Profile label Sep 30, 2024
@reubenmiller reubenmiller changed the title Support skipping operations in device profile feat: Support skipping operations in device profile Sep 30, 2024
@albinsuresh albinsuresh added this pull request to the merge queue Sep 30, 2024
@reubenmiller reubenmiller changed the title feat: Support skipping operations in device profile fix: Support skipping operations in device profile Sep 30, 2024
Merged via the queue into thin-edge:main with commit 65356c4 Sep 30, 2024
@albinsuresh albinsuresh deleted the device-profile-skip-operation branch October 22, 2024 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:profile Device Profile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants