<div dir="ltr">Hello Stephen,<div><br></div><div>According to the documentation, <a href="http://docs.astropy.org/en/stable/config/index.html">http://docs.astropy.org/en/stable/config/index.html</a>, <span style="font-size:12.8px">$XDG_CONFIG_HOME/astropy must *already* exist. You can take a look at <a href="https://github.com/astropy/astropy/blob/master/astropy/config/paths.py">https://github.com/astropy/astropy/blob/master/astropy/config/paths.py</a> to see the logic, but to summarize:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">1. $XDG_CONFIG_HOME must be set.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">2. $XDG_CONFIG_HOME/astropy/ must *exist*.  Note that's 'astropy' not '.astropy'.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">3. The configuration files go in $XDG_CONFIG_HOME/astropy/, NOT $XDG_CONFIG_HOME/astropy/config/.  This one confused me!</span></div><div><br></div><div><span style="font-size:12.8px">You might also want to consider setting XDG_CONFIG_CACHE, so that cache files are written to some other filesystem than $HOME.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Kia ora koe,</span></div><div><span style="font-size:12.8px">Benjamin Alan Weaver</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 31, 2017 at 12:01 PM, Stephen Bailey <span dir="ltr"><<a href="mailto:stephenbailey@lbl.gov" target="_blank">stephenbailey@lbl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">For the record: setting $XDG_CONFIG_HOME did not work but I don't know why.  It didn't create any .astropy/ config files in the new location, and when I moved my $HOME/.astropy out of the way, it still created a new $HOME/.astropy/config/ directory upon import even though $XDG_CONFIG_HOME was set to a different location.  I didn't try debugging beyond that.<div><br></div><div>In the meantime we've moved on with a pragmatic hack that performs a random sleep between 0 and 60 seconds per rank before doing any astropy imports, thus spreading out the load.  That buys us a bit more time for development work; we still plan to use docker/shifter for production work with a redefined $HOME.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Stephen</div><div><br></div></font></span></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Oct 26, 2017 at 11:45 PM, Benjamin Alan Weaver <span dir="ltr"><<a href="mailto:baweaver@lbl.gov" target="_blank">baweaver@lbl.gov</a>></span> wrote:<br></span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Stephen,<div><br></div><div>It looks like XDG_CONFIG_HOME is a possibility, as discussed here: <a href="http://docs.astropy.org/en/stable/config/index.html" target="_blank">http://docs.astropy.org/<wbr>en/stable/config/index.html</a>, but I'd be concerned that other services & applications outside of Python might also see that environment variable and look for config files in the directory it specifies.  Then again, maybe that's not a bad thing, since the fewer things that touch the real $HOME the better.</div><div><br></div><div>Kia ora koe,</div><div>Benjamin Alan Weaver</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-848281194153230161h5">On Thu, Oct 26, 2017 at 8:30 PM, Stephen Bailey <span dir="ltr"><<a href="mailto:stephenbailey@lbl.gov" target="_blank">stephenbailey@lbl.gov</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-848281194153230161h5"><div dir="ltr">We're using astropy in a massively parallel mpi4py program where 4800 ranks wake up simultaneously and try to import astropy.  The code itself is installed to a filesystem optimized for the millions (literally!) of tiny file accesses that this causes.  But we're having trouble with all 4800 ranks trying to read the astropy config file under our home directory, which is not optimized for such a load.  This intermittently produces the traceback below when one of them gets a corrupted read.<div><br></div><div>Although one could blame the filesystem for not being able to handle an arbitrarily large load, is there any way to mitigate this, e.g.</div><div><br></div><div>* some environment variable to tell astropy not to load the config file upon import, plus some way of setting the config by hand</div><div>* some environment variable to tell astropy to load it from a different location than $HOME</div><div>* other ideas?</div><div><br></div><div>For those less familiar with MPI, this is a "feature" of MPI that all ranks need to independently load the modules that they need, and they all start nearly simultaneously.  Unlike other parallel programming paradigms, it isn't an option with MPI itself to have one process wake up and import stuff, and then fork other processes that inherit the same environment.  (For those who are MPI experts, I'm aware of MPI_Comm_spawn, but that isn't widely implemented/deployed yet.)</div><div><br></div><div>Our full scale option is to use docker with astropy installed into the image, but even there we have to create a fake $HOME in the docker image so that astropy will get its config files from there instead of reaching out of the container to get them from the real $HOME directory.  It works, but yuck, because it means that nothing else in the program can access $HOME because we've hidden that from the container just to keep astropy imports from abusing it.</div><div><br></div><div>Thanks for the help,</div><div><br></div><div>Stephen</div><div><br></div><div><br></div><div><br></div><div><div id="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-:205" class="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-ii m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-gt m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-adP m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-adO" style="font-size:12.800000190734863px;margin-bottom:0px;margin-left:0px;padding-bottom:5px"><div id="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-:204" class="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-a3s m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-aXjCH m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-m15f5aefd5c27c8ba"><div dir="ltr">  File "/global/common/software/desi/<wbr>users/jguy/desispec/py/desispe<wbr>c/io/brick.py", line 21, in <module><br>    import astropy.io.fits<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/__init__.py<wbr>", line 287, in <module><br>    log = _init_log()<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/logger.py", line 100, in _init_log<br>    log._set_defaults()<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/logger.py", line 493, in _set_defaults<br>    self.setLevel(conf.log_level)<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/config/conf<wbr>iguration.py", line 278, in __get__<br>    return self()<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/config/conf<wbr>iguration.py", line 401, in __call__<br>    sec = get_config(self.module)<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/config/conf<wbr>iguration.py", line 535, in get_config<br>    cobj = configobj.ConfigObj(cfgfn, interpolation=False)<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/extern/conf<wbr>igobj/configobj.py", line 1231, in __init__<br>    self._load(infile, configspec)<br>  File "/global/common/software/desi/<wbr>edison/desiconda/20170920-1.2.<wbr>0-spec/conda/lib/python3.6/sit<wbr>e-packages/astropy/extern/conf<wbr>igobj/configobj.py", line 1320, in _load<br>    raise error<br>astropy.extern.configobj.confi<wbr>gobj.ParseError: Invalid line ('\x00\x00<div class="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-yj6qo"></div></div><div><br></div></div></div><div class="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-hq m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-gt m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-a10" id="m_-848281194153230161m_-1287895647314442546m_-4585717210994566082gmail-:20t" style="font-size:12.800000190734863px"></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org" target="_blank">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/astropy</a><br>
<br></blockquote></div><span class="m_-848281194153230161HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-848281194153230161m_-1287895647314442546gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">With great responsibility seldom comes great power.</div></div></div></div></div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org" target="_blank">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/astropy</a><br>
<br></blockquote></div></div></div><br></div>
<br>______________________________<wbr>_________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/astropy</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">With great responsibility seldom comes great power.</div></div></div></div></div></div></div>
</div>