-
Notifications
You must be signed in to change notification settings - Fork 107
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
Clarification of execution order for pre,main,post workflows #1188
Comments
I think you want something like this: {
"scripts": {
"db:update": "wireit",
"db:generate": "wireit",
"db:pull": "wireit"
},
"wireit": {
"db:update": {
"command": "..."
"dependencies": [
"db:generate"
]
},
"db:generate": {
"command": "..."
"dependencies": [
"db:pull"
]
},
"db:pull": {
"command": "..."
}
}
} You don't need to modify |
Sorry, my bad. I forgot to clarify that I don't always want db:generate to run db:pull. Is this something that can be isolated with wireit? |
Ah I see, yeah I missed that detail. I think for this use-case I would actually just use shell chaining for your macro. Something like this: {
"scripts": {
"db:update": "wireit",
"db:pull": "wireit",
"db:generate": "wireit",
"db:dump": "wireit"
},
"wireit": {
"db:update": {
"command": "npm run db:pull && npm run db:generate && npm run db:dump"
},
"db:pull": {
"command": "..."
},
"db:generate": {
"command": "..."
},
"db:dump": {
"command": "..."
}
}
} |
We could maybe add a feature like that has the same behavior as above, but more concise and without the overhead of those extra processes that each {
"scripts": {
"db:update": "wireit",
"db:pull": "wireit",
"db:generate": "wireit",
"db:dump": "wireit"
},
"wireit": {
"db:update": {
"sequence": ["db:pull", "db:generate", "db:dump"]
},
"db:pull": {
"command": "..."
},
"db:generate": {
"command": "..."
},
"db:dump": {
"command": "..."
}
}
} Doesn't seem crazy, though I'd like to think a bit more about whether there is some better way to express that. |
I was kinda thinking about that. Ideally, for something like this, I think it would be amazing to express "downstream" execution dependencies. Could a sequence flag be a more efficient solution to cut through it? As in, randomization is default unless disabled explicitly? Which would imply sequence mode. |
Though, now that I've had a chance to look at the code, that would also require having to deal with not just circumventing the shuffle functionality, but also to use a different strategy for iterating over the dependencies, to prevent race conditions from Promise.all. |
Thanks so far! |
@aomarks I think I may have a rough idea/solution. I'll look into this and if it's viable, I'm willing to commit implementing it. In short, the current workflow for dependencies stays the same, but if a dependency entry is a string array, each element is then executed sequentially. Example: {
"scripts": {
"db:update": "wireit",
"db:pull": "wireit",
"db:generate": "wireit",
"db:dump": "wireit"
},
"wireit": {
"db:update": {
"dependencies": [["db:pull", "db:generate", "db:dump"]]
},
"db:pull": {
"command": "..."
},
"db:generate": {
"command": "..."
},
"db:dump": {
"command": "..."
}
}
} Reflection: not sure how/if that could would work with the current dependency graphs, but I'm imagining that coercing every "dependencies" config entry into an string[][] object and using uniform sequential execution for the second level would alleviate most of the concerns. And I think a bonus would be that this could allow specific dependency workflows that could be executed in parallel. (Think parallel builds with specific execution order requirements.) Let me know if this sounds like it might be a viable solution and I'll look into this. (I'm not sure how wireit does dependency lookup resolution, in terms of whether these hard linked dependencies or if these are vectors that can be looked up. But I'll take a look and see.) |
As I understand from sources, comments and issues, if I wanted to replace a pre,main,post workflow through a simple placeholder script, I would need to set WIREIT_PARALLEL=1 and have each scripting dependency declare the previous step as a dependency?
Concrete example:
By themselves I could migrate them and I think the appropriate way to convert those would look something like this. But it feels a little bit counter-intuitive?
Is there a better/preferred way to build "meta" scripts like this? Or would a simple entry with just the linked tasks as dependencies work and would they be executed in the correct order based on WIREIT_PARALLEL=1?
Thanks!
EDITED optimized example workflow
The text was updated successfully, but these errors were encountered: