Code Monkey home page Code Monkey logo

Comments (8)

ditansu avatar ditansu commented on August 23, 2024

Is it possible to config a parallel()? For example to choose behavior: failure if any fail and vice versa, wait first finished only, wait all etc

from stories.

proofit404 avatar proofit404 commented on August 23, 2024

I think it could be split into several context managers.

  • parallel will execute every step specified
  • wait_first will wait for the first step which returns Success. A step could return Skip marker to specify if we should ignore its status. #141 could be considered as well to give the marker a proper name.

In my opinion, this feature should not change the semantic of the Result and Failure markers. We also should not ignore uncaught exceptions in any steps.

Would it work for you?

from stories.

ditansu avatar ditansu commented on August 23, 2024

I think it could be split into several context managers.

  • parallel will execute every step specified
  • wait_first will wait for the first step which returns Success. A step could return Skip marker to specify if we should ignore its status. #141 could be considered as well to give the marker a proper name.

In my opinion, this feature should not change the semantic of the Result and Failure markers. We also should not ignore uncaught exceptions in any steps.

Would it work for you?

Yes wait_first sounds as good solution. Also I agree we have to keep current semantic. More over I think Skip is right naming in this context, because it closely to Ignore semantic then Break in #141. I guess we need something like a parallel_ignore_failure for case when we want run few tasks and want success any one. For example send a notification by mail, slack and push.

from stories.

proofit404 avatar proofit404 commented on August 23, 2024
For example send a notification by mail, slack, and push.

Is it really a parallel task? Or we want it to be a sequence that will exit after the first successful execution?

from stories.

thedrow avatar thedrow commented on August 23, 2024

Syntax:

from stories import story, parallel

class Order:
    @story
    def purchase(I):
        I.one
        with parallel:
            I.two
            I.three
        I.four

Requirements:

  1. This feature should work both for sync and async stories. The semantic of execution and decision making should be the same. Or at least as close as possible.
  2. parallel should have at least two steps in it.
  3. Context changes made by two should not be visible to the three and wise versa. Context changes made by two and three should be visible by four.
  4. two, three or both of them could be a substory. Context restrictions continue to be the same independent from this detail.
  5. If some of the step returns Result this will be a result of the whole story. If other parallel steps are still running, their result should be ignored when they return. The story returns only after all the steps complete. If other running steps returns Failure or Result a warning of this clash should be reported.
  6. If some of the step returns Failure this will be a failure of the whole story. If other parallel steps are still running, their result should be ignored when they return. The story fails only after all the steps complete. If other running steps returns Failure or Result a warning of this clash should be reported.
  7. <parallel> should be present in the representation of the story.
  8. History representation should contain the execution of all steps in order of the actual execution even if it is mixed between parallel substories.
  9. The warning mentioned by items 5 and 6 of this list should be present in history representation as well.

Why don't we group the failures' reasons in a tuple and return that as a Failure instead of warning about other failures.
If there's a result and a failure, I think I'd rather the story to fail since it didn't complete successfully.

from stories.

proofit404 avatar proofit404 commented on August 23, 2024

Maybe we should not allow returning Result or Failure markers from the steps and substories within a parallel section?

from stories.

thedrow avatar thedrow commented on August 23, 2024

That's going to be a problem. Stories and steps can fail.
They can also return results.

from stories.

proofit404 avatar proofit404 commented on August 23, 2024

Superseded by #39

from stories.

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.