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

A series of suggestions for improvements of the dynamic workflow example #78

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions typescript/dynamic-workflow-executor/.dockerignore

This file was deleted.

21 changes: 0 additions & 21 deletions typescript/dynamic-workflow-executor/Dockerfile

This file was deleted.

13 changes: 7 additions & 6 deletions typescript/dynamic-workflow-executor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Here is an overview of the services:
![](dynamic_workflow_executor.png)


**Note:** This app stores images locally in the `generated-images` folder. These images would of course get lost when the app is restarted. This is just a demo app, so it's not a problem. But in a real app, you would store the images in some persistent storage.
**Note:** This app stores images locally in the shared locally accessible folder `generated-images`.
In a real deployment, this would need to be a shared storage, like S3.

## Running the example

Expand All @@ -41,27 +42,27 @@ npm install

Run puppeteer service:
```shell
npm run puppeteer-dev
npm run puppeteer-service
```

Run transformers service:
```shell
npm run transformers-dev
npm run transformers-service
```

Run stable diffusion service:
```shell
npm run stable-diffusion-dev
npm run stable-diffusion-service
```

Run external stable diffusion service:
```shell
npm run external-stable-diffusion-dev
npm run external-stable-diffusion-service
```

Run workflow service:
```shell
npm run workflow-dev
npm run workflow-service
```

Register the services at the Restate Server, using the CLI:
Expand Down
19 changes: 8 additions & 11 deletions typescript/dynamic-workflow-executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
"name": "dynamic-workflow-executor",
"version": "0.0.1",
"description": "An application that executes a workflow based on a workflow definition",
"main": "app.js",
"author": "Restate Developers",
"license": "MIT",
"email": "[email protected]",
"type": "commonjs",
"scripts": {
"build": "tsc --noEmitOnError",
"prebundle": "rm -rf dist",
"bundle": "esbuild src/app.ts --bundle --minify --sourcemap --platform=node --target=es2020 --outfile=dist/index.js",
"postbundle": "cd dist && zip -r index.zip index.js*",
"app": "node ./dist/app.js",
"app-dev": "ts-node-dev --watch ./src --respawn --transpile-only ./src/app.ts",
"puppeteer-dev": "ts-node-dev --watch ./src --respawn --transpile-only src/puppeteer/puppeteer.ts",
"stable-diffusion-dev": "ts-node-dev --watch ./src --respawn --transpile-only src/stable-diffusion/stable_diffusion.ts",
"external-stable-diffusion-dev": "ts-node-dev --watch ./src --respawn --transpile-only src/external/stable_diffusion.ts",
"transformers-dev": "ts-node-dev --watch ./src --respawn --transpile-only src/transformers/transformers.ts",
"workflow-dev": "ts-node-dev --watch ./src --respawn --transpile-only src/workflow/workflow.ts"
"puppeteer-service": "ts-node-dev --watch ./src --respawn --transpile-only src/puppeteer/puppeteer.ts",
"stable-diffusion-service": "ts-node-dev --watch ./src --respawn --transpile-only src/stable-diffusion/stable_diffusion.ts",
"external-stable-diffusion-service": "ts-node-dev --watch ./src --respawn --transpile-only src/external/stable_diffusion.ts",
"transformers-service": "ts-node-dev --watch ./src --respawn --transpile-only src/transformers/transformers.ts",
"workflow-service": "ts-node-dev --watch ./src --respawn --transpile-only src/workflow/workflow.ts"
},
"dependencies": {
"@restatedev/restate-sdk": "^0.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export const router = restate.router({
const blurParams = wfStep.parameters as { blur: number };
console.info("Blurring image with parameters: " + JSON.stringify(blurParams))

// we don't want to retry this too often, because failures here are most likely
// terminal (path issues, etc.), so limit the reties to 5
const retrySettings = {
initialDelayMs: 100,
maxRetries: 5,
name: "image blurring"
};

await ctx.sideEffect(async () => {
let image;
try {
Expand All @@ -18,7 +26,7 @@ export const router = restate.router({
}
const blurredImg = image.blur(blurParams.blur);
await blurredImg.writeAsync(wfStep.imgOutputPath!)
})
}, retrySettings);

return {
msg: "[Blurred image with parameters: " + JSON.stringify(blurParams) + "]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ export const router = restate.router({
const rotateParams = wfStep.parameters as { angle: number };
console.info("Rotating image with parameters: " + JSON.stringify(rotateParams))

// we don't want to retry this too often, because failures here are most likely
// terminal (path issues, etc.), so limit the reties to 5
const retrySettings = {
initialDelayMs: 100,
maxRetries: 5,
name: "image blurring"
};

await ctx.sideEffect(async () => {
let image;
try {
Expand All @@ -17,7 +25,7 @@ export const router = restate.router({
}
const rotatedImg = image.rotate(rotateParams.angle);
await rotatedImg.writeAsync(wfStep.imgOutputPath!)
})
}, retrySettings);

return {
msg: "[Rotated image with parameters: " + JSON.stringify(rotateParams) + "]"
Expand Down
Loading