Skip to content

Commit cf344b9

Browse files
committed
add software platform's support
1 parent e395844 commit cf344b9

File tree

11 files changed

+6150
-2042
lines changed

11 files changed

+6150
-2042
lines changed

model/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const model = BlockModel.create<BlockArgs>()
88

99
.initialArgs({})
1010

11-
.output('message', (ctx) => ctx.outputs?.resolve('message')?.getDataAsJson())
11+
.output('tengoMessage', (ctx) => ctx.outputs?.resolve('tengoMessage')?.getDataAsJson())
12+
13+
.output('pythonMessage', (ctx) => ctx.outputs?.resolve('pythonMessage')?.getDataAsJson())
1214

1315
.sections([{ type: 'link', href: '/', label: 'Main' }])
1416

pnpm-lock.yaml

Lines changed: 6062 additions & 2019 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@ packages:
33
- model
44
- ui
55
- test
6+
- software
67
- .
78

89
catalog:
9-
"@platforma-sdk/model": ^1.5.40
10-
"@platforma-sdk/ui-vue": ^1.5.38
11-
"@platforma-sdk/workflow-tengo": ^1.3.0
12-
"@platforma-sdk/block-tools": ^2.3.12
13-
"@platforma-sdk/test": ^1.5.43
14-
"@platforma-sdk/tengo-builder": ^1.14.13
10+
"@platforma-sdk/model": ^1.7.20
11+
"@platforma-sdk/ui-vue": ^1.7.46
12+
"@platforma-sdk/workflow-tengo": ^1.8.1
13+
"@platforma-sdk/block-tools": ^2.3.21
14+
"@platforma-sdk/test": ^1.8.5
15+
"@platforma-sdk/tengo-builder": ^1.16.1
16+
"@platforma-sdk/package-builder": ^2.11.1
1517
"@milaboratories/graph-maker": ^1.0.19
1618

19+
"@platforma-open/milaboratories.runenv-python-3": ^3.12.6
1720

18-
"vue": ^3.4.34
19-
"vue-tsc": ^2.0.29
21+
"vue": ^3.5.12
22+
"vue-tsc": ^2.1.6
2023

21-
"typescript": ^5.5.4
22-
"tsup": ~8.1.2
24+
"typescript": ^5.6.3
25+
"tsup": ~8.3.5
2326

24-
"vite": ^5.3.5
25-
"vitest": ^2.0.4
26-
"@vitejs/plugin-vue": ^5.1.0
27+
"vite": ^5.4.10
28+
"vitest": ^2.1.4
29+
"@vitejs/plugin-vue": ^5.1.4
2730

28-
"@changesets/cli": ^2.27.7
31+
"@changesets/cli": ^2.27.9

software/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@platforma-open/my-org.block-boilerplate.software",
3+
"version": "1.0.0",
4+
"type": "module",
5+
"description": "Block Software",
6+
"scripts": {
7+
"build": "pl-pkg build",
8+
"build:dev": "pl-pkg build --dev=local",
9+
"test": "true",
10+
11+
"prepublishOnly": ""
12+
},
13+
"block-software": {
14+
"artifacts": {
15+
"hello-python-artifact": {
16+
"type": "python",
17+
"registry": "platforma-open",
18+
"version": "1.0.0",
19+
"environment": "@platforma-open/milaboratories.runenv-python-3:3.12.6",
20+
"dependencies": {
21+
"toolset": "pip",
22+
"requirements": "requirements.txt"
23+
},
24+
"root": "./src_python"
25+
}
26+
},
27+
"entrypoints": {
28+
"hello-world-python": {
29+
"binary": {
30+
"artifact": "hello-python-artifact",
31+
"cmd": [ "python", "{pkg}/hello.py" ]
32+
}
33+
}
34+
}
35+
},
36+
"devDependencies": {
37+
"@platforma-open/milaboratories.runenv-python-3": "^1.0.0",
38+
"@platforma-sdk/package-builder": "catalog:"
39+
}
40+
}

software/src_python/hello.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
import click
3+
4+
print("Hello from Python, " + sys.argv[1] + "!")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
click==8.1.7

ui/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MainPage from "./pages/MainPage.vue";
55
export const sdkPlugin = defineApp(model, () => {
66
return {
77
routes: {
8-
"/": MainPage,
8+
"/": () => MainPage,
99
},
1010
};
1111
});

ui/src/pages/MainPage.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ const app = useApp();
1111

1212
<PlTextField v-model="app.model.args.name" label="Enter your name" clearable />
1313

14-
<PlAlert type="success" v-if="app.model.outputs.message">
14+
<PlAlert type="success" v-if="app.model.outputs.tengoMessage"> {{ app.model.outputs.tengoMessage }} </PlAlert>
1515

16-
{{ app.model.outputs.message }}
17-
18-
</PlAlert>
16+
<PlAlert type="success" v-if="app.model.outputs.pythonMessage"> {{ app.model.outputs.pythonMessage }} </PlAlert>
1917

2018
</PlBlockPage>
2119
</template>

workflow/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"test": "vitest",
99
"format": "/usr/bin/env emacs --script ./format.el"
1010
},
11+
"dependencies": {
12+
"@platforma-open/my-org.block-boilerplate.software": "workspace:*"
13+
},
1114
"devDependencies": {
1215
"@platforma-sdk/tengo-builder": "catalog:",
1316
"@platforma-sdk/workflow-tengo": "catalog:",

workflow/src/main.tpl.tengo

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@
22
wf := import("@platforma-sdk/workflow-tengo:workflow")
33

44
wf.body(func(args) {
5+
python := exec.builder().
6+
software(assets.importSoftware("@platforma-open/my-org.block-boilerplate.software:hello-world-python")).
7+
arg(args.name).
8+
saveStdoutContent().
9+
run()
10+
pythonMessage := python.getStdoutFileContent()
11+
12+
tengoMessage := "Hello from Tengo, " + args.name + "!"
13+
514
return {
615
outputs: {
7-
message: "Hello, " + args.name + "!"
16+
pythonMessage: pythonMessage,
17+
tengoMessage: tengoMessage
818
},
919

1020
exports: {}
1121
}
1222
})
23+

0 commit comments

Comments
 (0)