update fldist run_air and new_services to qqua run and dist deploy

This commit is contained in:
boneyard93501
2022-02-11 01:07:09 -06:00
parent f1a50e3484
commit 43d70de2e1
5 changed files with 150 additions and 103 deletions

View File

@ -114,34 +114,50 @@ Any one of the peers will do and we can deploy our services with the `fldist` to
```text ```text
# deploy greeting service # deploy greeting service
fldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \ aqua dist deploy \
new_service \ --addr /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
--ms artifacts/greeting.wasm:configs/greeting_cfg.json \ --data-path configs/echo_greeter_deploy_cfg.json \
--name greeting-demo --service echo-greeter
``` ```
Which gives us the service id for the greeting service: Which gives us the service id for the greeting service:
```text ```text
service id: 9436af06-86ab-4df3-ba2a-ad29e37043c2 Your peerId: 12D3KooWG65EzhW66PFpFGr79CQdMdif4THbkp6CVoQwbwaSM2aq
service created successfully "Going to upload a module..."
2022.02.09 23:47:57 [INFO] created ipfs client to /ip4/161.35.222.178/tcp/5001
2022.02.09 23:47:57 [INFO] connected to ipfs
2022.02.09 23:47:58 [INFO] file uploaded
"Now time to make a blueprint..."
"Blueprint id:"
"de3e242cb4489f2ed04b4ad8ff0e7cee701b75d86422c51b691dfeee8ab4ed92"
"And your service id is:"
"c2f5f5d3-708a-4b3e-bb97-149bb16cf048"
``` ```
and and
```text ```text
# deploy echo service # deploy echo service
fldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \ aqua dist deploy \
new_service \ --addr /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
--ms artifacts/echo_service.wasm:configs/echo_service_cfg.json \ --data-path configs/echo_greeter_deploy_cfg.json \
--name echo-demo --service echo-service
``` ```
Which gives as the id for the echo service: Which gives as the id for the echo service:
```text ```text
service id: ff3f3aa0-daeb-4555-b596-0f653df2ace9 Your peerId: 12D3KooWR58xvHD7nLKfnHVeqWL4MQ9dmnyq4sTLu4ENabHSmEwn
service created successfully "Going to upload a module..."
2022.02.10 00:13:03 [INFO] created ipfs client to /ip4/161.35.222.178/tcp/5001
2022.02.10 00:13:03 [INFO] connected to ipfs
2022.02.10 00:13:05 [INFO] file uploaded
"Now time to make a blueprint..."
"Blueprint id:"
"dfbcf30cccee5b9a05ac707617c652130d53ef94a1c600a98db396b5455514fa"
"And your service id is:"
"628109b6-f702-4b26-af36-f6f9bc008219"
``` ```
Take note of the service id for each service deployed as we need the peer and service id to execute each service. Take note of the service id for each service deployed as we need the peer and service id to execute each service.
@ -239,30 +255,21 @@ In the function body we:
7. Call the Greeting service with a name and the greet parameters in sequence 7. Call the Greeting service with a name and the greet parameters in sequence
8. Return the results array 8. Return the results array
Let's run the compiled Aqua code with the `fldist` cli tool:
**Please note that the `fldist run_air` examples below are NOT running. We are in the process of switching to `aqua run`, which should be ready shortly. Please proceed to `client-peer` example, which works as expected.**
```text ```text
fldist run_air \ aqua run\
-p aqua-compiled/echo_greeter.echo_greeting_seq.air \ -a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-d '{"names":["jim", "john", "james"], -i aqua \
"greet": true, -f 'echo_greeting_seq(names, greet, node, echo_service_id, greeting_service_id)' -d '{"names":["jim", "john", "james"],"greet": true,"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE","greeting_service_id":"5a03906b-3217-40a2-93fb-7e83be735408", "echo_service_id": "893a6fb8-43b9-4b11-8786-93300bd68bc8"}'
"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "greeting_service_id":"5a03906b-3217-40a2-93fb-7e83be735408",
"echo_service_id": "893a6fb8-43b9-4b11-8786-93300bd68bc8"
}' \
--generated
``` ```
`fldist` provides a client peer and deploys the compiled Aqua script, with the `-p` flag, and input data, with the `-d` flag, in form of a json string to the peer-to-peer network for execution and returns expected result: `aqua run` provides a client peer and deploys the compiled Aqua script and input data for execution and returns the expected result:
```text ```bash
[Your peerId: 12D3KooWSKem9nrxLBngskEPAmor9SkH6PKA4YGtTbrTM2VsyKrp
[ [
[ "Hi, jim",
"Hi, jim", "Hi, john",
"Hi, john", "Hi, james"
"Hi, james"
]
] ]
``` ```
@ -294,31 +301,25 @@ Since we want to compose services deployed on different nodes, we express this r
Again, we can execute our workflow with the `fldist` tool: Again, we can execute our workflow with the `fldist` tool:
```shell ```bash
fldist run_air \ aqua run\
-p aqua-compiled/echo_greeter.echo_greeting_seq_2.air \ -a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-d '{"names":["jim", "john", "james"], -i aqua \
"greet": true, -f 'echo_greeting_seq_2(names, greet, echo_topo, greeting_topo)' -d '{"names":["jim", "john", "james"],"greet": true,"greeting_topo":{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE","service_id":"5a03906b-3217-40a2-93fb-7e83be735408"},"echo_topo": {"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt","service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b"}}'
"greeting_topo":{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
"service_id":"5a03906b-3217-40a2-93fb-7e83be735408"},
"echo_topo": {"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b"}}' \
--generated
``` ```
Regardless of the difference in service hosts, we of course get the expected result: Regardless of the difference in service hosts, we of course get the expected result:
```json ```bash
Your peerId: 12D3KooWPvTHyy7AyDAYqKdUiMJ5gcMUMBN8vdWJrFjoVMCZAb3t
[ [
[ "Hi, jim",
"Hi, jim", "Hi, john",
"Hi, john", "Hi, james"
"Hi, james"
]
] ]
``` ```
Both workflow examples we've seen are **seq**uentially executing service calls. Let's kick it up a notch and process echo service outputs in **par**allel. Of course, we need to have the necessary greeting services deployed on different peers otherwise parallel processing defaults to sequential processing. Also, to continue to keep things compact, we introduce the `EchoServiceInput` struct. Both workflow examples we've seen are **seq**uentially executing service calls. Let's kick it up a notch and process echo service outputs in **par**allel. Of course, we need to have the necessary greeting services deployed. Also, to continue to keep things compact, we introduce the `EchoServiceInput` struct.
```aqua ```aqua
@ -346,34 +347,45 @@ func echo_greeting_par(greet: bool, echo_service: EchoServiceInput, greeting_ser
In this implementation version, we call the echo-service, just as before, and introduce parallelization when we reach the greeting service fold. That is, each greeting service arm is run in parallel and for each *result*, we execute k greeting services, as specified in greeting_services array, in parallel. Note that as a consequence of the parallelization we need to introduce a `join` on *res* as the result streaming into *res* happens on the specified node and therefore without being visible to the other streaming activities. We accomplish this with the `OpString.identity(res!5)` function where the argument needs to be a literal at this point. In this implementation version, we call the echo-service, just as before, and introduce parallelization when we reach the greeting service fold. That is, each greeting service arm is run in parallel and for each *result*, we execute k greeting services, as specified in greeting_services array, in parallel. Note that as a consequence of the parallelization we need to introduce a `join` on *res* as the result streaming into *res* happens on the specified node and therefore without being visible to the other streaming activities. We accomplish this with the `OpString.identity(res!5)` function where the argument needs to be a literal at this point.
Our updated `fldist` reads: Our updated `aqua run` reads:
```bash ```bash
fldist run_air \ aqua run\
-p aqua-compiled/echo_greeter.echo_greeting_par.air \ -a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-d '{"echo_service":{"names":["jim", "john", "james"], -i aqua \
"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", -f 'echo_greeting_par(greet, echo_service, greeting_services)' \
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b"}, -d '{"greet":true, "echo_service":{"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b",
"names":["jim", "john", "james"]
},
"greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
"service_id":"5a03906b-3217-40a2-93fb-7e83be735408"}, "service_id":"5a03906b-3217-40a2-93fb-7e83be735408"},
{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", {"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede"}], "service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede"}]
"greet": true}' \ }'
--generated
``` ```
And our result is: And our result is:
```json ```bash
Your peerId: 12D3KooWNjhhb1rgpgmthU6U1eRQMUDkKU5FayZ53hFzm2GV7Rcs
[ waiting for an argument with idx '5' on stream with size '0'
"Hi, jim", waiting for an argument with idx '5' on stream with size '3'
"Hi, jim", waiting for an argument with idx '5' on stream with size '3'
"Hi, john", waiting for an argument with idx '5' on stream with size '3'
"Hi, john", waiting for an argument with idx '5' on stream with size '3'
"Hi, james", waiting for an argument with idx '5' on stream with size '3'
"Hi, james" waiting for an argument with idx '5' on stream with size '4'
] waiting for an argument with idx '5' on stream with size '4'
waiting for an argument with idx '5' on stream with size '5'
waiting for an argument with idx '5' on stream with size '5'
[
"Hi, jim",
"Hi, jim",
"Hi, john",
"Hi, john",
"Hi, james",
"Hi, james"
] ]
``` ```
@ -424,9 +436,10 @@ gives us the updated result:
"Hi, john", "Hi, john",
"Hi, james" "Hi, james"
] ]
]
``` ```
With a very minor modification, i.e., the placement of `par`, we can drastically later the (re-)use of deployed services! With a very minor modification, i.e., the placement of `par`, we can drastically improve the (re-)use of deployed services!
With some additional modifications to our Aqua function, we can further improve readability by supplying the *greet* parameter for each service. Let's add a `GreetingServiceInput` struct and update the function signatures and bodies: With some additional modifications to our Aqua function, we can further improve readability by supplying the *greet* parameter for each service. Let's add a `GreetingServiceInput` struct and update the function signatures and bodies:
@ -455,32 +468,42 @@ Run the workflow with the updated json string:
```bash ```bash
fldist run_air \ aqua run\
-p aqua-compiled/echo_greeter.echo_greeting_par_improved.air \ -a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-d '{"echo_service":{"names":["jim", "john", "james"], -i aqua \
"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", -f 'echo_greeting_par_improved(echo_service, greeting_services)' \
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b"}, -d '{ "echo_service":{"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b",
"names":["jim", "john", "james"]
},
"greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
"service_id":"5a03906b-3217-40a2-93fb-7e83be735408", "service_id":"5a03906b-3217-40a2-93fb-7e83be735408", "greet":true},
"greet":true}, {"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", "service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede", "greet":false}]
"service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede", }'
"greet":false}]}' \
--generated
``` ```
Which gives us: Which gives us:
```json ```bash
[Your peerId: 12D3KooWBSiX3g472QQ5TAhoffUy1F1f6mjEPcsYH6BT5qrXV6iH
waiting for an argument with idx '5' on stream with size '0'
waiting for an argument with idx '5' on stream with size '3'
waiting for an argument with idx '5' on stream with size '3'
waiting for an argument with idx '5' on stream with size '3'
waiting for an argument with idx '5' on stream with size '3'
waiting for an argument with idx '5' on stream with size '3'
waiting for an argument with idx '5' on stream with size '4'
waiting for an argument with idx '5' on stream with size '4'
waiting for an argument with idx '5' on stream with size '5'
waiting for an argument with idx '5' on stream with size '5'
[ [
[ "Hi, jim",
"Hi, jim", "Bye, jim",
"Bye, jim", "Hi, john",
"Hi, john", "Bye, john",
"Bye, john", "Hi, james",
"Hi, james", "Bye, james"
"Bye, james"
]
] ]
``` ```

View File

@ -88,7 +88,7 @@ func echo_greeting_par_alternative(greet: bool, echo_service: EchoServiceInput,
GreetingService greeting_service.service_id GreetingService greeting_service.service_id
par on greeting_service.node: par on greeting_service.node:
res <- GreetingService.greeting(result.echo, greet) res <- GreetingService.greeting(result.echo, greet)
Op.noop() Op.noop()
join res[5] join res[5]
<- res <- res
@ -111,6 +111,5 @@ func echo_greeting_par_improved(echo_service: EchoServiceInput, greeting_service
on greeting_service.node: on greeting_service.node:
res <- GreetingService.greeting(result.echo, greeting_service.greet) res <- GreetingService.greeting(result.echo, greeting_service.greet)
Op.noop() Op.noop()
--OpString.identity(res!5)
join res[5] join res[5]
<- res <- res

View File

@ -100,9 +100,15 @@
"integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg=="
}, },
"node_modules/@fluencelabs/aqua": { "node_modules/@fluencelabs/aqua": {
<<<<<<< HEAD
"version": "0.6.0-275", "version": "0.6.0-275",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-275.tgz", "resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-275.tgz",
"integrity": "sha512-w/nwEp1y7kMgMXA0ZcKxePMOHsG569xY72h2BuFM0hfWPViFRtX9iBJXn8u52yZB5mVT4D1DbkBwP5IcH48AHw==", "integrity": "sha512-w/nwEp1y7kMgMXA0ZcKxePMOHsG569xY72h2BuFM0hfWPViFRtX9iBJXn8u52yZB5mVT4D1DbkBwP5IcH48AHw==",
=======
"version": "0.6.0-273",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-273.tgz",
"integrity": "sha512-vjGI1kRbglKcyMaAWdUndcLowfKobqpcAAyc3a2tb/HI3Hm0uy0hm13a+WAe55MM0yrSmt68oXSNu1lyNFWDjw==",
>>>>>>> 37c97df (update fldist to qua)
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@fluencelabs/aqua-ipfs": "0.5.2", "@fluencelabs/aqua-ipfs": "0.5.2",
@ -3904,9 +3910,9 @@
} }
}, },
"node_modules/rxjs": { "node_modules/rxjs": {
"version": "7.5.3", "version": "7.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.3.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz",
"integrity": "sha512-6162iC/N7L7K8q3UvdOMWix1ju+esADGrDaPrTu5XJmCv69YNdYoUaop/iatN8GHK+YHOdszPP+qygA0yi04zQ==", "integrity": "sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==",
"dependencies": { "dependencies": {
"tslib": "^2.1.0" "tslib": "^2.1.0"
} }
@ -4367,9 +4373,15 @@
} }
}, },
"@fluencelabs/aqua": { "@fluencelabs/aqua": {
<<<<<<< HEAD
"version": "0.6.0-275", "version": "0.6.0-275",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-275.tgz", "resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-275.tgz",
"integrity": "sha512-w/nwEp1y7kMgMXA0ZcKxePMOHsG569xY72h2BuFM0hfWPViFRtX9iBJXn8u52yZB5mVT4D1DbkBwP5IcH48AHw==", "integrity": "sha512-w/nwEp1y7kMgMXA0ZcKxePMOHsG569xY72h2BuFM0hfWPViFRtX9iBJXn8u52yZB5mVT4D1DbkBwP5IcH48AHw==",
=======
"version": "0.6.0-273",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-273.tgz",
"integrity": "sha512-vjGI1kRbglKcyMaAWdUndcLowfKobqpcAAyc3a2tb/HI3Hm0uy0hm13a+WAe55MM0yrSmt68oXSNu1lyNFWDjw==",
>>>>>>> 37c97df (update fldist to qua)
"dev": true, "dev": true,
"requires": { "requires": {
"@fluencelabs/aqua-ipfs": "0.5.2", "@fluencelabs/aqua-ipfs": "0.5.2",
@ -7515,9 +7527,9 @@
"integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==" "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg=="
}, },
"rxjs": { "rxjs": {
"version": "7.5.3", "version": "7.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.3.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz",
"integrity": "sha512-6162iC/N7L7K8q3UvdOMWix1ju+esADGrDaPrTu5XJmCv69YNdYoUaop/iatN8GHK+YHOdszPP+qygA0yi04zQ==", "integrity": "sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==",
"requires": { "requires": {
"tslib": "^2.1.0" "tslib": "^2.1.0"
} }

View File

@ -136,13 +136,6 @@ async function main() {
); );
console.log("par result : ", par_result); console.log("par result : ", par_result);
par_result = await echo_greeting_par_alternative(
true,
echo_service,
greeting_services
);
console.log("par alternative result : ", par_result);
par_result = await echo_greeting_par_improved( par_result = await echo_greeting_par_improved(
echo_service, echo_service,
greeting_services greeting_services

View File

@ -0,0 +1,20 @@
{
"echo-greeter": {
"name": "greeting-service",
"modules": [
{
"name": "greeting-service",
"path": "./artifacts/greeting.wasm"
}
]
},
"echo-service": {
"name": "echo-service",
"modules": [
{
"name": "echo",
"path": "./artifacts/echo_service.wasm"
}
]
}
}