-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from scramjetorg/feat/hello-world-py
Add hello-world samples
- Loading branch information
Showing
9 changed files
with
182 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Hello world js | ||
|
||
Simple sequence that outputs "Hello world" written in javascript. | ||
|
||
## Running | ||
|
||
> ❗ Remember to [setup transform-hub locally](https://docs.scramjet.org/platform/self-hosted-installation) or use the [platform's environment](https://docs.scramjet.org/platform/quick-start) for the sequence deployment. | ||
Open two terminals and run the following commands: | ||
|
||
**The first terminal:** | ||
|
||
```bash | ||
# go to 'hello-world-js' directory | ||
cd javascript/hello-world-js | ||
|
||
# install node_modules | ||
npm install | ||
|
||
# go back to javascript/ directory | ||
cd ../ | ||
|
||
# deploy 'hello-world-js' Sequence | ||
si seq deploy hello-world-js | ||
``` | ||
|
||
**The second terminal** | ||
|
||
Read the Instance output: | ||
|
||
```bash | ||
si inst output - | ||
``` | ||
|
||
You should see "Hello World!" printed out in the terminal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { PassThrough } = require("stream"); | ||
|
||
module.exports = async function(_input) { | ||
// create a clean output stream | ||
const out = new PassThrough({ encoding: "utf-8" }); | ||
|
||
// write some data to the output stream | ||
out.write("Hello World!"); | ||
|
||
// return the output stream so it can be consumed (e.g. by CLI client) | ||
return out; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@scramjet/hello-world-js", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"author": "a-tylenda", | ||
"license": "GPL-3.0", | ||
"description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", | ||
"keywords": [ | ||
"sample", | ||
"easy", | ||
"streaming", | ||
"Data Producer" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/scramjetorg/platform-samples/tree/main/javascript/hello-world-js" | ||
}, | ||
"scripts": { | ||
"build": "mkdir -p dist/ && cp -r index.js package.json dist/ && (cd dist && npm i --omit=dev)", | ||
"pack": "si seq pack ./dist/", | ||
"clean": "rm -rf ./dist ./*.tar.gz" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Hello world py | ||
|
||
Simple Sequence that outputs "Hello world" written in python | ||
|
||
## Running | ||
|
||
> ❗ Remember to [setup transform-hub locally](https://docs.scramjet.org/platform/self-hosted-installation) or use the [platform's environment](https://docs.scramjet.org/platform/quick-start) for the sequence deployment. | ||
Open two terminals and run the following commands: | ||
|
||
**The first terminal:** | ||
|
||
Open the terminal and run the following commands: | ||
|
||
```bash | ||
# go to 'hello-world-py' directory | ||
cd python/hello-world-py | ||
|
||
# build | ||
npm run build | ||
|
||
# make a compressed package with Sequence | ||
si seq pack dist | ||
|
||
# send Sequence to transform hub, this will output Sequence ID | ||
si seq send dist.tar.gz | ||
|
||
# start a Sequence | ||
si seq start - | ||
``` | ||
|
||
**The second terminal** | ||
|
||
Read the Instance output: | ||
|
||
```bash | ||
si inst output - | ||
``` | ||
|
||
You should see "Hello World!" printed out in the terminal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from scramjet.streams import Stream | ||
|
||
|
||
async def run(context, input): | ||
# create a clean output stream | ||
stream = Stream() | ||
|
||
# write some data to the output stream | ||
stream.write("Hello World!") | ||
|
||
# return the output stream so it can be consumed (e.g. by CLI client) | ||
return stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@scramjet/hello-world-py", | ||
"version": "1.0.0", | ||
"main": "./hello_world.py", | ||
"author": "S4adam", | ||
"license": "GPL-3.0", | ||
"description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", | ||
"keywords": [ | ||
"sample", | ||
"easy", | ||
"streaming", | ||
"Data Producer" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/scramjetorg/platform-samples/tree/main/python/hello-world-py" | ||
}, | ||
"scripts": { | ||
"build": "mkdir -p dist/__pypackages__/ && cp *.py package.json dist/ && pip3 install -t dist/__pypackages__/ -r requirements.txt", | ||
"clean": "rm -rf ./dist ./*.tar.gz", | ||
"pack": "si seq pack ./dist/" | ||
}, | ||
"engines": { | ||
"python3": "3.8.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scramjet-framework-py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters