sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Importing kadi events sets SKA #174

Closed jeanconn closed 4 years ago

jeanconn commented 4 years ago

This behavior is probably fine for our purposes, and we've probably been over it, but today I was still surprised by it as an unexpected side-effect in my environment:

In [1]: import os                                                                           

In [2]: os.environ.get('SKA')                                                               

In [3]: from kadi import events                                                             

In [4]: os.environ.get('SKA')                                                               
Out[4]: '/proj/sot/ska'
taldcroft commented 4 years ago

This may be needed for the current production web server to work but need to check. In general nothing in Ska3 works without previously setting SKA so this should basically never happen to users. I'm curious how you even ran into this.

jeanconn commented 4 years ago

For me, I started a new terminal, forgot to set SKA, and then didn't understand why my script still "worked".

taldcroft commented 4 years ago

From: https://modwsgi.readthedocs.io/en/develop/user-guides/configuration-guidelines.html#application-configuration

" The SetEnv directive has no effect on ‘os.environ’ and there is no way through Apache configuration directives to affect what is in the process environment."

So I think the answer is that leaving the setdefault in place that sets SKA is OK. I think @jeanconn is in a small minority of folks that don't have SKA hardwired into their setup files. I don't quite see what that wins you.

jeanconn commented 4 years ago

I use a different SKA depending on the test environment and I haven't quite stabilized with the new conda (what is your process for activating your environment @taldcroft ).

taldcroft commented 4 years ago

On Mac I have export SKA=${HOME}/ska in my .bash_profile (which gets called by my .zshrc). I use conda activate <env> to activate an environment, with the default being to start the (base) environment.

On HEAD: export SKA=/proj/sot/ska, with

if [ "$HOSTNAME" == "kady.cfa.harvard.edu" ]; then
  export PATH="/export/tom/miniconda3/bin:$PATH"  # commented out by conda initialize
fi

This last bit is not terribly clever but I don't seem to have any problems.