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
# deploy greeting service
fldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
new_service \
--ms artifacts/greeting.wasm:configs/greeting_cfg.json \
--name greeting-demo
aqua dist deploy \
--addr /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
--data-path configs/echo_greeter_deploy_cfg.json \
--service echo-greeter
```
Which gives us the service id for the greeting service:
```text
service id: 9436af06-86ab-4df3-ba2a-ad29e37043c2
service created successfully
Your peerId: 12D3KooWG65EzhW66PFpFGr79CQdMdif4THbkp6CVoQwbwaSM2aq
"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
```text
# deploy echo service
fldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
new_service \
--ms artifacts/echo_service.wasm:configs/echo_service_cfg.json \
--name echo-demo
aqua dist deploy \
--addr /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
--data-path configs/echo_greeter_deploy_cfg.json \
--service echo-service
```
Which gives as the id for the echo service:
```text
service id: ff3f3aa0-daeb-4555-b596-0f653df2ace9
service created successfully
Your peerId: 12D3KooWR58xvHD7nLKfnHVeqWL4MQ9dmnyq4sTLu4ENabHSmEwn
"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.
@ -239,30 +255,21 @@ In the function body we:
7. Call the Greeting service with a name and the greet parameters in sequence
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
fldist run_air \
-p aqua-compiled/echo_greeter.echo_greeting_seq.air \
-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"
}' \
--generated
aqua run\
-a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-i aqua \
-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"}'
```
`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, john",
"Hi, james"
]
"Hi, jim",
"Hi, john",
"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:
```shell
fldist run_air \
-p aqua-compiled/echo_greeter.echo_greeting_seq_2.air \
-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"}}' \
--generated
```bash
aqua run\
-a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-i aqua \
-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"}}'
```
Regardless of the difference in service hosts, we of course get the expected result:
```json
```bash
Your peerId: 12D3KooWPvTHyy7AyDAYqKdUiMJ5gcMUMBN8vdWJrFjoVMCZAb3t
[
[
"Hi, jim",
"Hi, john",
"Hi, james"
]
"Hi, jim",
"Hi, john",
"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
@ -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.
Our updated `fldist` reads:
Our updated `aqua run` reads:
```bash
fldist run_air \
-p aqua-compiled/echo_greeter.echo_greeting_par.air \
-d '{"echo_service":{"names":["jim", "john", "james"],
"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b"},
aqua run\
-a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-i aqua \
-f 'echo_greeting_par(greet, echo_service, greeting_services)' \
-d '{"greet":true, "echo_service":{"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b",
"names":["jim", "john", "james"]
},
"greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
"service_id":"5a03906b-3217-40a2-93fb-7e83be735408"},
{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede"}],
"greet": true}' \
--generated
"service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede"}]
}'
```
And our result is:
```json
[
"Hi, jim",
"Hi, jim",
"Hi, john",
"Hi, john",
"Hi, james",
"Hi, james"
]
```bash
Your peerId: 12D3KooWNjhhb1rgpgmthU6U1eRQMUDkKU5FayZ53hFzm2GV7Rcs
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",
"Hi, john",
"Hi, john",
"Hi, james",
"Hi, james"
]
```
@ -424,9 +436,10 @@ gives us the updated result:
"Hi, john",
"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:
@ -455,32 +468,42 @@ Run the workflow with the updated json string:
```bash
fldist run_air \
-p aqua-compiled/echo_greeter.echo_greeting_par_improved.air \
-d '{"echo_service":{"names":["jim", "john", "james"],
"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b"},
aqua run\
-a /dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE \
-i aqua \
-f 'echo_greeting_par_improved(echo_service, greeting_services)' \
-d '{ "echo_service":{"node": "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id": "fb5f7126-e1ee-4ecf-81e7-20804cb7203b",
"names":["jim", "john", "james"]
},
"greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
"service_id":"5a03906b-3217-40a2-93fb-7e83be735408",
"greet":true},
{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede",
"greet":false}]}' \
--generated
"service_id":"5a03906b-3217-40a2-93fb-7e83be735408", "greet":true},
{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
"service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede", "greet":false}]
}'
```
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",
"Bye, jim",
"Hi, john",
"Bye, john",
"Hi, james",
"Bye, james"
]
"Hi, jim",
"Bye, jim",
"Hi, john",
"Bye, john",
"Hi, james",
"Bye, james"
]
```

View File

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

View File

@ -100,9 +100,15 @@
"integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg=="
},
"node_modules/@fluencelabs/aqua": {
<<<<<<< HEAD
"version": "0.6.0-275",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-275.tgz",
"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,
"dependencies": {
"@fluencelabs/aqua-ipfs": "0.5.2",
@ -3904,9 +3910,9 @@
}
},
"node_modules/rxjs": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.3.tgz",
"integrity": "sha512-6162iC/N7L7K8q3UvdOMWix1ju+esADGrDaPrTu5XJmCv69YNdYoUaop/iatN8GHK+YHOdszPP+qygA0yi04zQ==",
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz",
"integrity": "sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==",
"dependencies": {
"tslib": "^2.1.0"
}
@ -4367,9 +4373,15 @@
}
},
"@fluencelabs/aqua": {
<<<<<<< HEAD
"version": "0.6.0-275",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.6.0-275.tgz",
"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,
"requires": {
"@fluencelabs/aqua-ipfs": "0.5.2",
@ -7515,9 +7527,9 @@
"integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg=="
},
"rxjs": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.3.tgz",
"integrity": "sha512-6162iC/N7L7K8q3UvdOMWix1ju+esADGrDaPrTu5XJmCv69YNdYoUaop/iatN8GHK+YHOdszPP+qygA0yi04zQ==",
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz",
"integrity": "sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==",
"requires": {
"tslib": "^2.1.0"
}

View File

@ -136,13 +136,6 @@ async function main() {
);
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(
echo_service,
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"
}
]
}
}