-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: add demo functionality to Reana cli script #19
Conversation
For now, hardcoded to run only helloworld-workflow with 'atlas' as experiment.
|
scripts/reana
Outdated
@@ -135,6 +222,7 @@ usage () { | |||
echo " install-minikube Installs and starts local minikube instance" | |||
echo " init Initialize REANA system" | |||
echo " down Delete REANA components" | |||
echo " demo helloworld Runs a helloworld demo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run helloworld
so that we are ready for the future run myanalysis
without having to change the CLI.
scripts/reana
Outdated
#kubectl logs -f $(kubectl get pods | grep -Po 'yadage-atlas-worker[^ ]+') | ||
|
||
# Open workflow-monitor web-interface | ||
firefox "http://$controller_url/$workflow_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to take commands like firefox
out of the script (and use them only in docs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to open
and xdg-open
.
.gitignore
Outdated
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out
needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to check if this is copy-paste error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legit but not needed. I'll remove it.
IntelliJ -specific folder for generated .class files and artifacts
scripts/reana
Outdated
# The code to check for flags is from http://stackoverflow.com/q/2875424 | ||
# Not sure if this is a good way or not. | ||
flag_verbose=$(echo "$*" | grep -e "--verbose" -o) | ||
flag_devel=$(echo "$*" | grep -e "--devel" -o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simple quotes to prevent command execution:
$ echo "$(date)"
Thu 27 Apr 18:40:02 CEST 2017
$ echo '$(date)'
$(date)
or rely on the flag being present last in $3 some place, or use environment variable...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change this to flag_devel=$(echo $* | grep -e "--devel" -o)
, shellcheck complains:
- SC2048: Use "$@" (with quotes) to prevent whitespace problems.
- SC2086: Double quote to prevent globbing and word splitting.
With flag_devel=$(echo $@ | grep -e "--devel" -o)
shellcheck complains:
- SC2068: Double quote array expansions, otherwise they're like $* and break on spaces.
If I use flag_devel=$(echo "$@" | grep -e "--devel" -o)
shellcheck doesn't complain.
I understand your point though.
I don't know enough about shell scripting to be able to say if any of these is good.
Should we change from sh
to bash
to use if [[ "$@" != *"--devel"* ]]; then
if that would be a better alternative?
scripts/reana
Outdated
-H "Content-Type: application/json" \ | ||
-X POST -d \ | ||
"{\"experiment\":\"atlas\", | ||
\"toplevel\":\"github:diegodelemos/reana-demo-helloworld@2-add-helloworld-workflow\", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diegodelemos/...
image location not needed anymore? Use central one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see reanahub/reana-demo-helloworld#4. Once it is merged \"toplevel\":\"github:diegodelemos/reana-demo-helloworld@2-add-helloworld-workflow\"
should be changed for \"toplevel\":\"github:reanahub/reana-demo-helloworld\"
.
scripts/reana
Outdated
|
||
if [ "$flag_verbose" != "" ]; then | ||
echo "[INFO] Open http://$controller_url/$workflow_id to see visual representation of your workflow and it's progress." | ||
echo "[INFO] You can 'cat' or 'tail' /reana/atlas/$workflow_id/yadage/helloworld/greetings.txt -file" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of reanahub/reana-workflow-engine-yadage#20 only ATLAS workflows are currently working, however, it would be nice to use something line $(experiment)
instead of the string atlas
. Since in reana-resources-X
we are following the pattern /reana/<experiment>
(see here) it would match perfectly
scripts/reana
Outdated
echo "[INFO] Open http://$controller_url/$workflow_id to see visual representation of your workflow and it's progress." | ||
echo "[INFO] You can 'cat' or 'tail' /reana/atlas/$workflow_id/yadage/helloworld/greetings.txt -file" | ||
echo " from shared storage of REANA cluster to see how helloworld workflow progresses." | ||
echo "[INFO] (e.g. minikube ssh \"tail -c+1 -F /reana/atlas/$workflow_id/yadage/helloworld/greetings.txt\")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(experiment)
rather than atlas
scripts/reana
Outdated
echo "" | ||
echo "Workflow_id: $workflow_id" | ||
echo "Monitor: http://$controller_url/$workflow_id" | ||
echo "Output: /reana/atlas/$workflow_id/yadage/helloworld/greetings.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same about atlas
scripts/reana
Outdated
# Tail output-file of the workflow | ||
echo "[INFO] Tailing...hit Ctrl+C when done." | ||
echo "" | ||
minikube ssh "tail -c+1 -F /reana/atlas/$workflow_id/yadage/helloworld/greetings.txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same about atlas
scripts/reana
Outdated
\"preset_pars\": {\"name\": \"J.Doe\", \"delay\": \"2\"} | ||
}" \ | ||
http://"$(reana get reana-workflow-controller)"/yadage \ | ||
| grep -oP '(?<="workflow_id": ")[^"]*') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-P
option is not available in BSD, so something like grep -oE '"workflow_id"\:[[:space:]]*\"[^\"]*\"'| cut -d ":" -f 2 | tr -d "\""
would support both GNU and BSD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't update yet. I will look into this next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not yet update, it prevents successful execution on Mac
scripts/reana
Outdated
|
||
if [ "$flag_devel" != "" ]; then | ||
# Start tailing of job-controller logs | ||
#kubectl logs -f $(kubectl get pods | grep -Po 'job-controller[^ ]+') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see more practical to have some developer documentation where we explain which logs would be nice to follow as well as which endpoints should be opened. If you use i3
, tmux
or something else you have your own setup for doing this kind of things
ee2b97c
to
5c8b4ab
Compare
echo "Output: /reana/$experiment/$workflow_id/yadage/helloworld/greetings.txt" | ||
echo "" | ||
|
||
if [ "$flag_devel" != "" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I get rid of the whole --devel part of the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could leave it there if we find it useful for development, all in all it is an option..
scripts/reana
Outdated
|
||
# The code to check for flags is from http://stackoverflow.com/q/2875424 | ||
# Not sure if this is a good way (POSIX compliant?) or not. | ||
flag_verbose=$(echo "$@" | grep -e "--verbose" -o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change this to flag_devel=$(echo $* | grep -e "--devel" -o)
, shellcheck complains:
- SC2048: Use "$@" (with quotes) to prevent whitespace problems.
- SC2086: Double quote to prevent globbing and word splitting.
With flag_devel=$(echo $@ | grep -e "--devel" -o)
shellcheck complains:
- SC2068: Double quote array expansions, otherwise they're like $* and break on spaces.
If I use flag_devel=$(echo "$@" | grep -e "--devel" -o)
shellcheck doesn't complain.
I understand your point though.
I don't know enough about shell scripting to be able to say if any of these is good.
Should we change from sh
to bash
to use if [[ "$@" != *"--devel"* ]]; then
if that would be a better alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag_devel=$(echo "$@" | grep -qe "--\<verbose\>")
flag_devel=$(echo "$@" | grep -qe "--\<devel\>")
might be better because current one would allow providing --dev
or --verbo
. So we could stick to sh
which is more standard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got your point. Have to admit that I'm not sure if I'm actually restricting matches with -o
. It should show only the part which matches pattern.
Tested based on suggestion and I couldn't get grep -qe "--\<verbose\>"
to work.
How about flag_verbose=$(echo "$@" | grep -oe "--\<verbose\>")
?
scripts/reana
Outdated
@@ -26,6 +26,8 @@ reana-workflow-monitor | |||
reana-message-broker | |||
reana-workflow-engine-yadage" | |||
|
|||
experiment_list=$(find ./configuration-manifests/namespaces/ -name \*.yaml -printf '%f\n' | sed -e 's/\.yaml$//') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I just use hardcoded experiment list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be ok, in the future we can grab it from configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is what you actually do, sorry about that 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-printf
is not supported on BSD, something like:
find ./configuration-manifests/namespaces/ -name \*.yaml -type f -exec basename {} .yaml ";"
should be more portable
scripts/reana
Outdated
if [ "$3" = "-e" ]; then | ||
experiment=$4 | ||
else | ||
experiment=${REANA_EXPERIMENT-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the trailing -
necessary? In -h
it doesn't include it
Runs a helloworld demo in namespace of
specified experiment (e.g. '-e atlas').
Specify experiment with '-e' flag or
$REANA_EXPERIMENT environment variable.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote from some SO-post:
"${var:-} and ${var-} mean different things. ${var:-} will expand to empty string if var unset or null and ${var-} will expand to empty string only if unset"
BUT now that I think of it, it might be better with ${REANA_EXPERIMENT:-} so it will default to empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we warn the user to either set -e <experiment>
or the REANA_EXPERIMENT
env var? otherwise the request could contain an empty string
7ba0d4f
to
d7f22a1
Compare
* add cli command to run reana-demo-helloworld example easily `reana run helloworld` * prepare for run syntax ('reana run myworkflow') described in reanahub/reana-demo-helloworld/issues/2 Signed-off-by: Harri Hirvonsalo <harri.hirvonsalo@cern.ch>
d7f22a1
to
b37ccfe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
reana run helloworld
Signed-off-by: Harri Hirvonsalo harri.hirvonsalo@cern.ch