Closed pangteckchun closed 4 months ago
Hi - from your error message it seems IF is throwing an exception due to the outputs
block, not the shell model.
IF doesn't like that you have commented out # - yaml
only. Either uncomment it, or comment out the outputs:
field as well.
The shell model expects an array of output data to be piped back into IF via stdin. The demo script sampler
is a minimal implementation.
Tagging in @pazbardanl who has been the main user of the shell model so far to help answer your questions!
Hi. I was able to reproduce the outputs: []
issue with the following:
npm run ie -- --manifest manifests/plugins/shell/success.yml --stdout
looking into it.
Hi @pangteckchun . Sorry for the delay. I've addressed your issues and questions below. If you need more help or the answers aren't clear, let me know, and we can set up a call.
running sampler with --stdout flag
manifests/plugins/shell/success.yml
under global-config.command
executes standalone successfully on your machine before running it from IF. You might find the default command isn't working and might need to be tweaked to fit your env. /usr/local/bin/sampler
is obviously irrelevant, and I'm using python and not python3. So I had to tweak manifests/plugins/shell/success.yml
to get it to work.pbarda@pbarda-mobl MINGW64 /c/dev/if (main)
$ npm run ie -- --manifest manifests/plugins/shell/success.yml --stdout
> @grnsft/if@v0.3.2 ie
> npx ts-node src/index.ts --manifest manifests/plugins/shell/success.yml --stdout
[2024-05-16 05:38:45.728 PM] info:
[!important] Incubation Project
This project is an incubation project being run inside the Green Software Foundation; as such, we DON’T recommend using it in any critical use case.
Incubation projects are experimental, offer no support guarantee, have minimal governance and process, and may be retired at any moment. This project may one day graduate, in which case this disclaimer will be removed.
name: shell
description: successful path
tags: null
initialize:
plugins:
shell:
path: '@grnsft/if-plugins'
method: Shell
global-config:
command: python C:/dev/sampler
outputs:
- yaml
execution:
command: >-
C:\Users\pbarda\AppData\Local\npm-cache\_npx\1bf7c3c15bf47d04\node_modules\ts-node\dist\bin.js
C:\dev\if\src\index.ts --manifest manifests/plugins/shell/success.yml
--stdout
environment:
if-version: v0.3.2
os: "Microsoft Windows 11 Enterprise\r"
os-version: 10.0.22631 N/A Build 22631
node-version: 20.13.1
date-time: 2024-05-16T14:38:53.822Z (UTC)
dependencies:
- '@babel/core@7.22.10'
- '@babel/preset-typescript@7.23.3'
- '@commitlint/cli@18.6.0'
- '@commitlint/config-conventional@18.6.0'
- '@grnsft/if-plugins@v0.3.2 extraneous -> file:../../../if-models'
- '@jest/globals@29.7.0'
- '@types/jest@29.5.8'
- '@types/js-yaml@4.0.9'
- '@types/luxon@3.4.2'
- '@types/node@20.9.0'
- csv-stringify@6.4.6
- fixpack@4.0.0
- gts@5.2.0
- husky@8.0.3
- jest@29.7.0
- js-yaml@4.1.0
- luxon@3.4.4
- release-it@16.3.0
- rimraf@5.0.5
- ts-command-line-args@2.5.1
- ts-jest@29.1.1
- typescript@5.2.2
- winston@3.11.0
- zod@3.22.4
tree:
children:
child:
pipeline:
- shell
inputs:
- timestamp: '2023-11-02T10:35:31.820Z'
duration: 3600
cpu/energy: 0.002
memory/energy: 0.000005
outputs:
- - cpu/energy: 0.002
duration: 3600
energy: 1
memory/energy: 0.000005
timestamp: '2023-11-02T10:35:31.820Z'
C:\dev\if\src\util\errors.js:46
var _this = _super.call(this, message) || this;
^
Error: Output path is required.
at new class_1 (C:\dev\if\src\util\errors.js:46:32)
at Object.execute (C:\dev\if\src\builtins\export-yaml.ts:18:13)
at exhaust (C:\dev\if\src\lib\exhaust.ts:64:18)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Notice that the output block at the end isn't empty. Also there's an error there about missing output path: @jmcook1186 is this expected in --stdout mode?
running sampler with --verbose flag
Notice here you need the --output
arg:
pbarda@pbarda-mobl MINGW64 /c/dev/if (main)
$ npm run ie -- --manifest manifests/plugins/shell/success.yml --verbose --output /c/dev/out
> @grnsft/if@v0.3.2 ie
> npx ts-node src/index.ts --manifest manifests/plugins/shell/success.yml --verbose --output C:/dev/out
[2024-05-16 05:49:32.210 PM] info:
[!important] Incubation Project
This project is an incubation project being run inside the Green Software Foundation; as such, we DON’T recommend using it in any critical use case.
Incubation projects are experimental, offer no support guarantee, have minimal governance and process, and may be retired at any moment. This project may one day graduate, in which case this disclaimer will be removed.
Here you won't see any output in the console, as all is dumped into the file you provided.
Looking at the code sample provided in sampler
script, as well as what I recall from writing a custom shell script few months ago in Python:
Hi @pazbardanl - Thank you for the detailed responses to both y questions! Really appreciate this. For question #1 - I will give it a try based on your suggestion. Which brings me to my last query around question #2:
shell
plugin need to interact via STDIN and STDOUT;shell
plugin as an intermediary?
IF plugin --> some output array --> shell
plugin (which would use this upstream plugin output as input array - correct?) --> processes and output via STDOUT --> how can we obtain the STDOUT outputs for another IF plugin use from here ?FYI, I have pivoted from using an external program with shell
plugin but instead wrote my own plugin using IF guidelines to make the pipeline works well throughout.
Thank you for your attention!
TC
Hi @pangteckchun
Regarding clarification in #2 above: The flow you describe seems right, let me recap:
IF --[calls]--> IF Shell plugin --[pass inputs via STDIN]--> External process (=your custom plugin) IF <-- IF Shell plugin <--[return outputs via STDOUT]-- External process (=your custom plugin)
hopes that clears things
cheers Paz
Hi, I have the following questions regarding the
shell
plug-in.Question 1 - how to run the example given (can't seemed to achieve the output per illustrated
Attempted to run the
shell.yml
provided and also downloadedsampler.py
from the repo.. I can't seemed to get the sample output per illustrated and these are the observations:--verbose
flag the following error was observed:This project is an incubation project being run inside the Green Software Foundation; as such, we DON’T recommend using it in any critical use case. Incubation projects are experimental, offer no support guarantee, have minimal governance and process, and may be retired at any moment. This project may one day graduate, in which case this disclaimer will be removed.
[2024-05-01 05:34:10.078 PM] error: "initialize.outputs" parameter is expected array, received null. Error code: invalid_type. ManifestValidationError: "initialize.outputs" parameter is expected array, received null. Error code: invalid_type. at validate (C:\Users\p1337447\AppData\Roaming\npm\node_modules\@grnsft\if\build\util\validations.js:61:15) at validateManifest (C:\Users\p1337447\AppData\Roaming\npm\node_modules\@grnsft\if\build\util\validations.js:53:61) at load (C:\Users\p1337447\AppData\Roaming\npm\node_modules\@grnsft\if\build\lib\load.js:14:69) at async impactEngine (C:\Users\p1337447\AppData\Roaming\npm\node_modules\@grnsft\if\build\index.js:23:47)
name: shell-demo description: tags: initialize: outputs:
- yaml
plugins: sampler: method: Shell path: "@grnsft/if-plugins" global-config: command: python ./samples.manifest/sampler.py tree: children: child: pipeline:
Question 2 - how does IF support the yaml processing if I use my own shell program?
I will be writing a custom go program for my needs to call from
shell
plug-in. Can I know:shell
plug-in expect my custom program to process the entire manifest file (i.e. each line) or otherwise, which means we would just need to handleinputs
section?outputs
section - do we write the entire yaml manifest out line by line or just need to handle writing foroutputs
?Thank you for your attention!