Skip to content
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

source conda_setup from within script - error with command line arguments #9

Closed
davidslac opened this issue Jan 12, 2017 · 2 comments
Closed

Comments

@davidslac
Copy link
Collaborator

@koglin ran into an issue using conda_setup from a script.

Users may write scripts like

#!/bin/bash

source conda_setup
# process command line arguments

However, per http://superuser.com/questions/1029431/how-to-prevent-source-in-a-bash-script-from-passing-the-scripts-arguments, conda_setup will see the scripts command line argument, and currently error out when it processes them.

Looks like the best practice is for users to do

source conda_setup ""

to not pass the scripts command line arguments.

I could also look into

http://stackoverflow.com/questions/12818146/python-argparse-ignore-unrecognised-arguments

to not complain about unrecognized arguments, but this doesn't seem as robust. Some of the user script arguments may coincidentally be the same as those of conda_setup, and outside the script, we'd rather throw an error.

@davidslac
Copy link
Collaborator Author

I updated documentation at https://confluence.slac.stanford.edu/display/PSDMInternal/User+Documentation
will close.

@davidslac
Copy link
Collaborator Author

davidslac commented Jan 13, 2017

Jason reports there is still trouble calling bsub, bsub/script + conda_setup leads to messed up envrionment. Workaround, don't use conda_setup, get into the ana-current environment directly. You can read which environment is ana-current, but you need to set which OS, i.e, rhel7, rhel6, rhel5 yourself (batch jobs should only be run on rhel7), so you could start your script like:

#!/usr/bin/bash

_CONDA_DIR=/reg/g/psdm/sw/conda
PATH=$_CONDA_DIR/inst/miniconda2-prod-rhel7/bin:$PATH
_ANA_CURRENT=`cat $_CONDA_DIR/ana-current/ana-current`
unset PYTHONPATH
unset LD_LIBRARY_PATH
source activate $_ANA_CURRENT
unset _ANA_CURRENT
unset _CONDA_DIR

This mechanism for reading ana-current from the path /reg/g/psdm/sw/conda/ana-current/ana-current is subject to change, we really should have an API for it so we can put the information elsewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant