Git Product home page Git Product logo

Comments (3)

daveaglick avatar daveaglick commented on August 30, 2024

The idea is to allow a sequence of modules to execute without impacting the "main" module sequence. In other words, Branch executes it's child modules as if there were no Branch module in the sequence, but then when it's child modules are done, the main sequence of modules is executed as if there were no Branch. I'm not sure either of those explanations made a ton of sense, so it's probably best explained with an example. Assume you have a module, AddOne, that just adds 1 to whatever numeric value is in the content of the input document(s). The input and output content of the following configuration should demonstrate what Branch does:

                            // Input Content      // Output Content
Pipelines.Add(
    AddOne(),       // [Empty]                // 0
    AddOne(),       // 0                          // 1
    AddOne(),       // 1                          // 2
    Branch(
        AddOne(),   // 2                          // 3
        AddOne()    // 3                          // 4
    ),
    AddOne(),       // 2                          // 3
    AddOne()        // 3                          // 4
);

You can see that the input content to the AddOne modules after the Branch is the same as the input content to the AddOne modules inside the branch. The result of the modules in the Branch had no impact on those modules that run after the Branch. This is true for both content and metadata. If any modules inside the Branch created or changed metadata, it would be forgotten once the Branch was done.

Now, why would you need this? There are a couple of use cases I can think of. One might be if you need to process your input documents multiple different ways. Branch would let you keep the input content to each transformation the same. Another case might be if you want to write the documents to disk multiple times but don't want to preserve the metadata that WriteFiles adds from one write to the next.

from wyam.web.

dodyg avatar dodyg commented on August 30, 2024

Thank you for the explanation. This explanation I think should go to the documentation because it clearly describes the purpose of http://wyam.io/modules/branch.

from wyam.web.

daveaglick avatar daveaglick commented on August 30, 2024

Good point - done.

from wyam.web.

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.