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

Shell commands and function callbacks #1193

Merged
merged 6 commits into from
Nov 1, 2023

Conversation

cyrush
Copy link
Member

@cyrush cyrush commented Aug 22, 2023

Work from @siramok.

  • Initial callback and shell command implementations

  • Initial work to combine commands and callbacks

  • Move callback registration and execution into Command

  • Catch the case where neither action is defined

  • Allow defining multiline shell commands and callbacks

  • Minor formatting tweaks

  • Initial implementation of triggers with callbacks

  • Improved organization, more error catching

  • Make sure that triggers either have a condition or callback

  • Make void callbacks take conduit node parameters

  • Initial attempt at exposing callbacks through ascent-jupyter-bridge

  • Let void callbacks return arbitrary data via conduit nodes

  • Disallow anonymous callbacks, add some tests

  • Add tests for shell commands and callbacks

  • Refactor callback API into the main API, adjusts tests to reflect the change

  • Minor cleanups that I missed

  • Fix minor bug with the trigger + callback test

siramok and others added 3 commits August 22, 2023 16:04
Work from @siramok.

* Initial callback and shell command implementations

* Initial work to combine commands and callbacks

* Move callback registration and execution into Command

* Catch the case where neither action is defined

* Allow defining multiline shell commands and callbacks

* Minor formatting tweaks

* Initial implementation of triggers with callbacks

* Improved organization, more error catching

* Make sure that triggers either have a condition or callback

* Make void callbacks take conduit node parameters

* Initial attempt at exposing callbacks through ascent-jupyter-bridge

* Let void callbacks return arbitrary data via conduit nodes

* Disallow anonymous callbacks, add some tests

* Add tests for shell commands and callbacks

* Refactor callback API into the main API, adjusts tests to reflect the change

* Minor cleanups that I missed

* Fix minor bug with the trigger + callback test
@cyrush
Copy link
Member Author

cyrush commented Aug 23, 2023

@siramok I fixed the third party lib build issue (we needed a new zlib download url)

I'll get to work on other tweaks soon.

@siramok
Copy link
Collaborator

siramok commented Aug 23, 2023

Awesome. I saw your feedback on the previous PR and thought that the suggestions were great.

Let me know if you'd like me to take on any of those tasks.

@siramok
Copy link
Collaborator

siramok commented Sep 6, 2023

Just noticed that the command tests are failing on MSVC: my guess is that it's due to touch <file_path> not creating a file (due to touch not being a thing), and subsequently failing to assert that the file was created. I believe we already have a conditional compilation directive for when the arch is Windows? A possible fix would be to use the Windows equivalent for touch <file_path> ifdef Windows, else use the existing command.

@siramok
Copy link
Collaborator

siramok commented Oct 25, 2023

Upon investigating, I realized that the tests were failing due to several things:

  • A side effect of callbacks being stored in static maps was that subsequent tests would still have callbacks registered from previous tests. To fix this, I added a way to reset the callback maps and then had each test reset the callbacks before executing.
  • Functions that we expect to fail are now wrapped with EXPECT_ANY_THROW so that the "failure" tests ultimately pass.
  • I had directly copied one of the trigger tests to test using callbacks as trigger conditions, but wasn't careful to check whether the assertions were still applicable. It turns out that evaluated expressions have their results available via an info extract, but the same is not true for callbacks.
  • I made the touch change for Windows that I mentioned above. I don't have Windows setup for building ascent, so I'll rely on the CI to tell me if it was sufficient or not.

@cyrush
Copy link
Member Author

cyrush commented Oct 26, 2023

@siramok thanks for the updates, I should have time next week to review further and get these features in!

Copy link
Member Author

@cyrush cyrush left a comment

Choose a reason for hiding this comment

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

Looks great, made a few minor suggestions (which I can take care of if you like)

One Q:
I don't think we have the logic to trigger based on a shell command result yet?
If so no worries, we can tackle in a follow on PR -- just want to make sure I am reading the current code correctly.

Thanks for your effort on this, these are going to be great features!

src/libs/ascent/ascent.hpp Outdated Show resolved Hide resolved
src/tests/ascent/t_ascent_commands.cpp Outdated Show resolved Hide resolved
src/tests/ascent/t_ascent_commands.cpp Show resolved Hide resolved
@siramok
Copy link
Collaborator

siramok commented Oct 31, 2023

@cyrush Correct, it's not possible to use shell commands as trigger conditions right now.

Since your suggestions were pretty easy, I just went ahead and implemented them.

@cyrush
Copy link
Member Author

cyrush commented Oct 31, 2023

Awesome, thanks for the quick turn around!

@cyrush
Copy link
Member Author

cyrush commented Nov 1, 2023

CI Failure was a github fetch fluke, unrelated to changes.

@cyrush cyrush merged commit bb7733b into develop Nov 1, 2023
17 of 19 checks passed
@cyrush cyrush deleted the task/2023_08_siramok_command_integration branch November 1, 2023 15:20
@cyrush
Copy link
Member Author

cyrush commented Nov 1, 2023

Thanks again for this!

@siramok
Copy link
Collaborator

siramok commented Nov 1, 2023

Thanks!

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.

2 participants