Skip to content

Commit

Permalink
add software platform's support
Browse files Browse the repository at this point in the history
  • Loading branch information
Snyssfx committed Nov 11, 2024
1 parent e395844 commit ccee935
Show file tree
Hide file tree
Showing 10 changed files with 1,851 additions and 1,586 deletions.
4 changes: 3 additions & 1 deletion model/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export const model = BlockModel.create<BlockArgs>()

.initialArgs({})

.output('message', (ctx) => ctx.outputs?.resolve('message')?.getDataAsJson())
.output('tengoMessage', (ctx) => ctx.outputs?.resolve('tengoMessage')?.getDataAsJson())

.output('pythonMessage', (ctx) => ctx.outputs?.resolve('pythonMessage')?.getDataAsJson())

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

Expand Down
3,329 changes: 1,766 additions & 1,563 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ packages:
- model
- ui
- test
- software
- .

catalog:
"@platforma-sdk/model": ^1.5.40
"@platforma-sdk/ui-vue": ^1.5.38
"@platforma-sdk/workflow-tengo": ^1.3.0
"@platforma-sdk/block-tools": ^2.3.12
"@platforma-sdk/test": ^1.5.43
"@platforma-sdk/tengo-builder": ^1.14.13
"@platforma-sdk/model": ^1.7.20
"@platforma-sdk/ui-vue": ^1.7.46
"@platforma-sdk/workflow-tengo": ^1.7.3
"@platforma-sdk/block-tools": ^2.3.21
"@platforma-sdk/test": ^1.7.43
"@platforma-sdk/tengo-builder": ^1.16.1
"@platforma-sdk/package-builder": ^2.10.7
"@milaboratories/graph-maker": ^1.0.19


"vue": ^3.4.34
"vue-tsc": ^2.0.29
"vue": ^3.5.12
"vue-tsc": ^2.1.10

"typescript": ^5.5.4
"tsup": ~8.1.2
"typescript": ^5.6.3
"tsup": ~8.3.5

"vite": ^5.3.5
"vitest": ^2.0.4
"@vitejs/plugin-vue": ^5.1.0
"vite": ^5.4.10
"vitest": ^2.1.4
"@vitejs/plugin-vue": ^5.1.4

"@changesets/cli": ^2.27.7
"@changesets/cli": ^2.27.9
40 changes: 40 additions & 0 deletions software/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@platforma-open/my-org.block-boilerplate.software",
"version": "1.0.0",
"type": "module",
"description": "Block Software",
"scripts": {
"build": "pl-pkg build",
"build:dev": "pl-pkg build --dev=local",
"test": "true",

"prepublishOnly": ""
},
"block-software": {
"artifacts": {
"hello-python-artifact": {
"type": "python",
"registry": "platforma-open",
"version": "1.0.0",
"environment": "@platforma-open/milaboratories.runenv-python-3:3.12.6",
"dependencies": {
"toolset": "pip",
"requirements": "requirements.txt"
},
"root": "./src_python"
}
},
"entrypoints": {
"hello-world-python": {
"binary": {
"artifact": "hello-python-artifact",
"cmd": [ "python", "{pkg}/hello.py" ]
}
}
}
},
"devDependencies": {
"@platforma-open/milaboratories.runenv-python-3": "^1.0.0",
"@platforma-sdk/package-builder": "catalog:"
}
}
4 changes: 4 additions & 0 deletions software/src_python/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import sys
import click

print("Hello, " + sys.argv[1] + "!")
1 change: 1 addition & 0 deletions software/src_python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
click==8.1.7
6 changes: 2 additions & 4 deletions ui/src/pages/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ const app = useApp();

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

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

{{ app.model.outputs.message }}

</PlAlert>
<PlAlert type="success" v-if="app.model.outputs.pythonMessage"> {{ app.model.outputs.pythonMessage }} </PlAlert>

</PlBlockPage>
</template>
1 change: 1 addition & 0 deletions workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"format": "/usr/bin/env emacs --script ./format.el"
},
"devDependencies": {
"@platforma-open/my-org.block-boilerplate.software": "workspace:",
"@platforma-sdk/tengo-builder": "catalog:",
"@platforma-sdk/workflow-tengo": "catalog:",
"@platforma-sdk/test": "catalog:",
Expand Down
14 changes: 13 additions & 1 deletion workflow/src/main.tpl.tengo
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
wf := import("@platforma-sdk/workflow-tengo:workflow")

wf.body(func(args) {
python := exec.builder().
software(assets.importSoftware("@platforma-open/my-org.block-boilerplate.software:main")).
arg(args.name).
inMediumQueue().
saveStdoutContent().
run()
pythonMessage := run.getStdoutFileContent()

tengoMessage := "Hello, " + args.name + "!"

return {
outputs: {
message: "Hello, " + args.name + "!"
pythonMessage: pythonMessage,
tengoMessage: tengoMessage
},

exports: {}
}
})

7 changes: 5 additions & 2 deletions workflow/src/wf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ tplTest(
name: 'World'
});

const message = results.output("message", (a) => a?.getDataAsJson<string>());
expect(await message.awaitStableValue()).eq('Hello, World!');
const pythonMessage = results.output("pythonMessage", (a) => a?.getDataAsJson<string>());
expect(await pythonMessage.awaitStableValue()).eq('Hello, World!');

const tengoMessage = results.output("tengoMessage", (a) => a?.getDataAsJson<string>());
expect(await tengoMessage.awaitStableValue()).eq('Hello, World!');
}
);

0 comments on commit ccee935

Please sign in to comment.