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

Modules and tasks #21

Open
michaelsharpe opened this issue Jul 25, 2021 · 10 comments
Open

Modules and tasks #21

michaelsharpe opened this issue Jul 25, 2021 · 10 comments

Comments

@michaelsharpe
Copy link

I have a system which is reliant upon the task plugin to create branching run logic. I would also however like to use the module plugin.

Is there a way to do this presently, or a strategy you recommend, or should I fork the module plugin to modify for my uses?

Thanks!

@lancety
Copy link

lancety commented Jul 26, 2021

+1 module input/output ACTION socket for task plugin~ thanks ~ @Ni55aN

@lancety
Copy link

lancety commented Jul 26, 2021

I just tried some usecases @michaelsharpe , seems we dont need to do extra change to use module. when you have a node need value from a module, the node 's action can connect to a task node to trigger it, and then it will reverse look for value from module, so the module will be triggered.

like the screenshot bellow, no matter you get value from the left task node which trigger the logic, or from a normal input node. module always works.
about the task plugin's workflow - there is another discussion Ni55aN responded might be helful for your understanding retejs/task-plugin#1 here
image
image

@lancety
Copy link

lancety commented Jul 26, 2021

@michaelsharpe learn typescript

@michaelsharpe
Copy link
Author

@lancety Thanks so much for the input! My main use case is wanting the submodules themselves to be able to use tasks as well, as I use tasks to control logic flow through my application. We have nodes that, when they run, are expensive, and so we only want them to run when the logic flow dictates they should. We have a lot of node gates, like booleans and switches, etc.

So I want to be able to expose 'option/action' sockets on the module, and have it pass the run flow into the submodule along triggered paths.

I am working on local copy of the plugin with heavy modifications. I have added support for action inputs and outputs, which are working in terms of rendering.

I am currently getting tripped up on trying to get the internally cloned engine inside the module plugin to run tasks, and then to figure out how I can programmatically trigger a task run on the specific node which was fired on the parents action input, if that makes sense.

I have been updating the code all day now to get to this point. Just a few more hurdles to have task flows working inside modules with trigger sockets that are exposed.

Here are a couple of screenshots of it so far. Currently working on the logic to get the internal tasks running.

Screenshot 2021-07-28 at 21 26 55

Screenshot 2021-07-28 at 21 27 03

@lancety
Copy link

lancety commented Jul 29, 2021

I guess this module plugin doesn't support input output trigger partly because module normally is not the last logic node, if it export anything as output, that output can connect to any following node which has a trigger like above screenshot I posted.
So any node has been trggered will run module task which connected as the node's input.

the "backward" task trigger behavior works well in my module usecase. and it does not need me to do any module plugin modification.
again here is the link shows how backward task trigger works #21

If above did not work to you it means I did not get right understanding of your issue, haha

@michaelsharpe
Copy link
Author

@lancety The example I gave of a module for us is a trivial one, however I am building under the need of much larger and complex chains inside a module. If these chains didn't require more expensive branching logic, I would be fine with the standard functionality, or if the running of individual branches and closing others was built into core rete.

@michaelsharpe
Copy link
Author

Just as an update, I did manage to get it working, but it isn't super elegant. Each run cycle of the task plugin now passes down the option socket that the signal came from, and uses this information to get the targeted option socket on the current node and attaches it to a fourth "context" object I have defined and pass out to the worker. The worker then uses this info to find that targeted node in the node tree after the engine processes the graph, and calls a "run" function on that component with that node which I have defined. The run function matches that nodes ID to a map the component now stores internally of all registered tasks, and runs the associated tasks run function to trigger off the run flow from that internal module.

I also had to define two separate components that are registered with the module manager independently for trigger inputs and trigger outputs which are used to trigger flows inside the module, and to pass output triggers back up to the parent chain.

It was a lot of custom work, but it seems to be functioning currently, which I am happy about. Currently last thing I have to do is refactor the removeIO and addIO on startup because this pattern causes the module to drop all its connections in reloading.

@dzm-brimit
Copy link

@michaelsharpe @lancety
Hey! can you share an example of your code (codesandbox, codepen)?
I can't understand how the Task plugin works with the Module.

@michaelsharpe
Copy link
Author

Hey @dzm-brimit, they dont work together out of the box. I had to do heavy modification on both plugins to make them work together. My modifications add new node types (trigger ins and triggers outs for the task options) which when triggered from the module will start the chain running inside the child from that node.

My project I used it in, Thoth, is open sourced and can be found here:

https://github.com/AtlasFoundation/Thoth/tree/main/packages/core/src/plugins

If you have any questions feel free to hit me up, or open an issue on that repo to chat.

@dzm-brimit
Copy link

@michaelsharpe, thanks for the answer. He added some clarity to my work. I'll explore your repository with pleasure.

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

No branches or pull requests

3 participants