@zea.cl/create-cerebelum 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-cerebelum.js +70 -0
- package/package.json +16 -0
- package/template/workflow.py +33 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* create-cerebelum ā Scaffold a new Cerebelum workflow project.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* npx @zea.cl/create-cerebelum my-project
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs')
|
|
10
|
+
const path = require('path')
|
|
11
|
+
const { execSync } = require('child_process')
|
|
12
|
+
|
|
13
|
+
const args = process.argv.slice(2)
|
|
14
|
+
const projectName = args[0]
|
|
15
|
+
|
|
16
|
+
if (!projectName) {
|
|
17
|
+
console.log('\nš§ create-cerebelum ā Scaffold a new Cerebelum project\n')
|
|
18
|
+
console.log(' Usage: npx @zea.cl/create-cerebelum <project-name>\n')
|
|
19
|
+
console.log(' Example:')
|
|
20
|
+
console.log(' npx @zea.cl/create-cerebelum my-workflow')
|
|
21
|
+
console.log(' cd my-workflow')
|
|
22
|
+
console.log(' python workflow.py')
|
|
23
|
+
console.log('')
|
|
24
|
+
process.exit(0)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const projectDir = path.resolve(projectName)
|
|
28
|
+
const templateDir = path.resolve(__dirname, '..', 'template')
|
|
29
|
+
|
|
30
|
+
// āā Create project directory āā
|
|
31
|
+
if (fs.existsSync(projectDir)) {
|
|
32
|
+
console.error(`ā Directory "${projectName}" already exists.`)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fs.mkdirSync(projectDir, { recursive: true })
|
|
37
|
+
console.log(`\nš§ Creating Cerebelum project: ${projectName}\n`)
|
|
38
|
+
|
|
39
|
+
// āā Copy template files āā
|
|
40
|
+
const files = fs.readdirSync(templateDir)
|
|
41
|
+
for (const file of files) {
|
|
42
|
+
const src = path.join(templateDir, file)
|
|
43
|
+
const dest = path.join(projectDir, file)
|
|
44
|
+
fs.copyFileSync(src, dest)
|
|
45
|
+
console.log(` ā
${file}`)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// āā Python venv āā
|
|
49
|
+
console.log(`\n š¦ Installing Python dependencies...`)
|
|
50
|
+
try {
|
|
51
|
+
execSync('pip install cerebelum-sdk', {
|
|
52
|
+
cwd: projectDir,
|
|
53
|
+
stdio: 'pipe',
|
|
54
|
+
})
|
|
55
|
+
console.log(` ā
cerebelum-sdk installed`)
|
|
56
|
+
} catch {
|
|
57
|
+
console.log(` ā ļø Could not install cerebelum-sdk via pip.`)
|
|
58
|
+
console.log(` Run: pip install cerebelum-sdk`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// āā Auth hint āā
|
|
62
|
+
console.log(`\n š To use cloud mode, authenticate:`)
|
|
63
|
+
console.log(` npx @zea.cl/cerebelum-cli login`)
|
|
64
|
+
console.log(`\n š Quickstart:`)
|
|
65
|
+
console.log(` cd ${projectName}`)
|
|
66
|
+
console.log(` python workflow.py`)
|
|
67
|
+
console.log(`\n āļø Cloud mode:`)
|
|
68
|
+
console.log(` npx @zea.cl/cerebelum-cli deploy workflow.py`)
|
|
69
|
+
console.log(` npx @zea.cl/cerebelum-cli run my_workflow --inputs '{"name":"ZEA"}'`)
|
|
70
|
+
console.log('')
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zea.cl/create-cerebelum",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold a new Cerebelum workflow project",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-cerebelum": "./bin/create-cerebelum.js"
|
|
7
|
+
},
|
|
8
|
+
"files": ["bin", "template"],
|
|
9
|
+
"keywords": ["cerebelum", "workflow", "scaffold", "create"],
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/ZeaCl/cerebelum.git",
|
|
14
|
+
"directory": "create-cerebelum"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""My Cerebelum Workflow ā modify this file to build your workflow."""
|
|
2
|
+
|
|
3
|
+
from cerebelum import step, workflow
|
|
4
|
+
|
|
5
|
+
# āā Define your steps āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
6
|
+
|
|
7
|
+
@step
|
|
8
|
+
async def hello(context):
|
|
9
|
+
"""First step: greets the world."""
|
|
10
|
+
return {"message": "Hello, Cerebelum! š§ "}
|
|
11
|
+
|
|
12
|
+
# Add more steps here...
|
|
13
|
+
# @step
|
|
14
|
+
# async def my_step(context, previous_result=None):
|
|
15
|
+
# return {"data": "my result"}
|
|
16
|
+
|
|
17
|
+
# āā Define your workflow āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
18
|
+
|
|
19
|
+
@workflow
|
|
20
|
+
def my_workflow(wf):
|
|
21
|
+
wf.timeline(hello)
|
|
22
|
+
# wf.timeline(hello >> my_step) # Chain steps
|
|
23
|
+
|
|
24
|
+
# āā Execute āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
25
|
+
|
|
26
|
+
import asyncio
|
|
27
|
+
|
|
28
|
+
async def main():
|
|
29
|
+
result = await my_workflow.execute({})
|
|
30
|
+
print(f"Status: {result.status}")
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
asyncio.run(main())
|