Git Product home page Git Product logo

Comments (4)

mnadeem avatar mnadeem commented on July 29, 2024

You can add that logic in task itself to skip : https://github.com/dexecutor/dexecutor-core/wiki/How-Do-I-%3F#how-do-i-execute-tasks-conditionally-based-on-the-result-of-parent-tasks

from dexecutor-core.

xiaomao23zhi avatar xiaomao23zhi commented on July 29, 2024

I couldn't think of a way to do this using parentResutls. I think It's two different use case. ParentResults is for task execute conditions, it's "bottom-up". But taskIdToStartWith is DAG graph iterate method, it's "top-down"。

Since the executor is based on a DAG graph, I think it should be delt within DAG graph.
For example:

public Set<Node<T, R>> getInitialNodes(T startWith) {
	Set<Node<T, R>> initialNodes = new LinkedHashSet<Node<T, R>>();
	for (Entry<T, Node<T, R>> entry : this.nodes.entrySet()) {
		Node<T, R> node = entry.getValue();

		if (startWith == null) {
			if (node.getInComingNodes().isEmpty()) {				
				initialNodes.add(node);
		} else {
			if (node.getValue().equals(startWith)) {
				initialNodes.add(node);
			}
		}
	}
	return initialNodes;		
}

from dexecutor-core.

mnadeem avatar mnadeem commented on July 29, 2024

That would be error prone, as there could be multiple starts, here is an example, in this case 1, 11 and 12 are starts

image

Here is how you can do it

private static class SleepyTaskProvider implements TaskProvider<String, String> {

public Task<String, String> provideTask(final String id) {

   if   ( (scenario == 1 ||  scenario == 5) && "A".equals(id)) {
      return new EmptyTask();
   } else {

    return new Task<String, String>() {

        @Override
        public String execute() {
            try {
                //Perform some task
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String result = id + "processed";
            return result;
        }

        @Override
        public boolean shouldExecute(ExecutionResults<String, String> parentResults) {
            ExecutionResult<String, String> firstParentResult = parentResults.getFirst();
            //Do some logic with parent result
            if ("B".equals(id) && firstParentResult.isSkipped() && firstParentResult.getResult() == "No") {
                return false;
            }
            return true;
        }
    };          
}

}

from dexecutor-core.

mnadeem avatar mnadeem commented on July 29, 2024

Closing this ticket for now

from dexecutor-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.