tensorlab / tensorfx

TensorFlow framework for training and serving machine learning models
Apache License 2.0
196 stars 41 forks source link

tfx during development #10

Closed brandondutra closed 7 years ago

brandondutra commented 7 years ago

source init.sh does not map the tfx command, so I think the samples are un-runable without installing this package.

I played with putting an alias in init.sh, but I learned bash scripts don't respect alias.

nikhilk commented 7 years ago

http://unix.stackexchange.com/questions/1496/why-doesnt-my-bash-script-recognize-aliases provided a solution. Fixing...

brandondutra commented 7 years ago

Yea, I found that online answer too, but it didn't work for me. I pulled in your changes and that solution doesn't work for me.

$ cat init.sh

#!/bin/sh

ln -s src tensorfx

export REPO=$(git rev-parse --show-toplevel)
export PYTHONPATH=$REPO:$REPO/samples:$PYTHONPATH
export PYTHONDONTWRITEBYTECODE=1

# Setup aliases to simulate console entrypoints created in setup for use in
# development use-cases.
shopt -s expand_aliases
alias tfx="python -m tensorfx.tools.tfx"

# Optionally install python packages
if [ "$1" == "pip" ]; then
  pip install -r requirements.txt
fi

$ source init.sh $ cd samples/ $ ./iris/run.sh ./iris/run.sh: line 3: tfx: command not found $ type tfx tfx is aliased to `python -m tensorfx.tools.tfx' $ shopt autocd off cdable_vars off cdspell off checkhash on checkjobs off checkwinsize on cmdhist on compat31 off compat32 off compat40 off compat41 off compat42 off complete_fullquote on direxpand off dirspell off dotglob off execfail off expand_aliases on extdebug off extglob on extquote on failglob off force_fignore on globstar off globasciiranges off gnu_errfmt off histappend on histreedit off histverify off hostcomplete off huponexit off interactive_comments on lastpipe off lithist off login_shell on mailwarn off no_empty_cmd_completion on nocaseglob off nocasematch off nullglob off progcomp on promptvars on restricted_shell off shift_verbose off sourcepath on xpg_echo off

brandondutra commented 7 years ago

this works for me: make an exe in tmp to call python -m

# simulate script entrypoint created in setup for use in development use-cases.
echo $PATH | grep -q "/tmp/tensorfx/bin"
if [[ $? -ne 0 ]]; then
  export PATH=/tmp/tensorfx/bin:$PATH
  mkdir -p /tmp/tensorfx/bin
  echo "#! /bin/sh
  python -m tensorfx.tools.tfx \$@
  " > /tmp/tensorfx/bin/tfx
  chmod u+x /tmp/tensorfx/bin/tfx
fi
nikhilk commented 7 years ago

Maybe mac is different, where things work :)

The script you have seems to be too much effort. Maybe the thing to do is just to use python -m tensorfx.tools.tfx in non-installed scenarios?

brandondutra commented 7 years ago

yea, that's what I have been doing. I was getting tired of having to change samples/*/run.sh to run them, and I disliked how they would always show up in modified state in git.

I'll keep my init.sh in my repo and deal with it.